Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SOFAR 2200TL #311

Merged
merged 6 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ A python package with which you can read the data from your Omnik Inverter. Keep
| Bosswerk | BW-MI300 | HTML |
| Bosswerk | BW-MI600 | HTML |
| Sofar | 3600TLM | HTML |
| Sofar | 2200TL | JS |
| Huayu | HY-600-Pro | HTML |

## Installation
Expand Down
2 changes: 1 addition & 1 deletion omnikinverter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_value(position: int) -> Any:
if matches[position] != "":
if position in [4, 5, 6, 7]:
if position in [4, 5]:
return int(matches[position])
return int(matches[position].replace(" ", ""))

if position == 6:
energy_value = float(matches[position]) / 100
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/status_devicearray_sofar220tl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var version= "H4.01.51MW.2.01W1.0.64(2018-01-251-D)";var m2mRssi= "39%";var wanIp= "";var myDeviceArray=new Array();myDeviceArray[0]="1234567890 ,V450,,SOFAR2200TL,2 000,400,567,123070,,1,";
30 changes: 30 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ async def test_inverter_js_devicearray(aresponses: ResponsesMockServer) -> None:
assert inverter.solar_energy_total == 5200.2


@pytest.mark.asyncio
async def test_inverter_js_devicearray_sofar2200tl(
aresponses: ResponsesMockServer,
) -> None:
"""Test request from an SOFAR 2200TL Inverter - JS DeviceArray source."""
aresponses.add(
"example.com",
"/js/status.js",
"GET",
aresponses.Response(
status=200,
headers={"Content-Type": "application/x-javascript"},
text=load_fixtures("status_devicearray_sofar220tl.js"),
),
)

async with aiohttp.ClientSession() as session:
client = OmnikInverter(host="example.com", session=session)
inverter: Inverter = await client.inverter()
assert inverter
assert inverter.serial_number == "1234567890"
assert inverter.firmware == "V450"
assert inverter.firmware_slave is None
assert inverter.model == "SOFAR2200TL"
assert inverter.solar_rated_power == 2000
assert inverter.solar_current_power == 400
assert inverter.solar_energy_today == 5.67
assert inverter.solar_energy_total == 12307.0


@pytest.mark.asyncio
async def test_device_js_devicearray(aresponses: ResponsesMockServer) -> None:
"""Test request from a Device - JS DeviceArray source."""
Expand Down