Skip to content

Commit

Permalink
Add alarm_code for JS, HTML and JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Sep 6, 2022
1 parent e6899be commit a7e22f7
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ You can read the following data with this package:
- Inverter Model
- Firmware Version - Main
- Firmware Version - Slave
- Alarm Code
- Rated Power (W)
- Current Power Production (W)
- Day Energy Production (kWh)
Expand Down
1 change: 1 addition & 0 deletions examples/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async def main() -> None:
print(f"Firmware Main: {inverter.firmware}")
print(f"Firmware Slave: {inverter.firmware_slave}")
print(f"Rated Power: {inverter.solar_rated_power}")
print(f"Alarm Code: {inverter.alarm_code}")
print(f"Current Power: {inverter.solar_current_power}")
print(f"Energy Production Today: {inverter.solar_energy_today}")
print(f"Energy Production Total: {inverter.solar_energy_total}")
Expand Down
6 changes: 5 additions & 1 deletion omnikinverter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Inverter:
solar_current_power: int | None
solar_energy_today: float | None
solar_energy_total: float | None
alarm_code: str | None = None

# TCP only
inverter_active: bool | None = None
Expand Down Expand Up @@ -77,7 +78,8 @@ def validation(data_list: list[Any]) -> bool:
model=get_value("i_modle"),
firmware=get_value("i_ver_m"),
firmware_slave=get_value("i_ver_s"),
solar_rated_power=get_value("i_pow"),
alarm_code=get_value("i_alarm"),
solar_rated_power=int(get_value("i_pow")),
solar_current_power=int(get_value("i_pow_n")),
solar_energy_today=float(get_value("i_eday")),
solar_energy_total=float(get_value("i_eall")),
Expand Down Expand Up @@ -117,6 +119,7 @@ def get_value(search_key: str) -> Any:
model=get_value("webdata_pv_type"),
firmware=get_value("webdata_msvn"),
firmware_slave=get_value("webdata_ssvn"),
alarm_code=get_value("webdata_alarm"),
solar_rated_power=get_value("webdata_rate_p"),
solar_current_power=get_value("webdata_now_p"),
solar_energy_today=get_value("webdata_today_e"),
Expand Down Expand Up @@ -174,6 +177,7 @@ def get_value(position: int) -> Any:
model=get_value(3),
firmware=get_value(1),
firmware_slave=get_value(2),
alarm_code=get_value(8),
solar_rated_power=get_value(4),
solar_current_power=get_value(5),
solar_energy_today=get_value(6),
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/status.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var webdata_sn = "12345678910";var webdata_msvn = "V5.07Build245";var webdata_ssvn = "";var webdata_pv_type = "Omnik2500tl ";var webdata_rate_p = "2500";var webdata_now_p = "219";var webdata_today_e = "0.23";var webdata_total_e = "6454.5";var webdata_alarm = "";var webdata_utime = "1";var cover_mid = "902000501";var cover_ver = "ME_08_0102_2.03";var cover_wmode = "";var cover_ap_ssid = "";var cover_ap_ip = "";var cover_ap_mac = "F0FE6B79BA5B";var cover_sta_ssid = "";var cover_sta_rssi = "";var cover_sta_ip = "192.168.0.106";var cover_sta_mac = "F0FE6B79BA5A";var status_a = "1";var status_b = "0";var status_c = "0";
var webdata_sn = "12345678910";var webdata_msvn = "V5.07Build245";var webdata_ssvn = "";var webdata_pv_type = "Omnik2500tl ";var webdata_rate_p = "2500";var webdata_now_p = "219";var webdata_today_e = "0.23";var webdata_total_e = "6454.5";var webdata_alarm = "F13";var webdata_utime = "1";var cover_mid = "902000501";var cover_ver = "ME_08_0102_2.03";var cover_wmode = "";var cover_ap_ssid = "";var cover_ap_ip = "";var cover_ap_mac = "F0FE6B79BA5B";var cover_sta_ssid = "";var cover_sta_rssi = "";var cover_sta_ip = "192.168.0.106";var cover_sta_mac = "F0FE6B79BA5A";var status_a = "1";var status_b = "0";var status_c = "0";
6 changes: 4 additions & 2 deletions tests/fixtures/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"i_ver_m":"V1.25Build23261",
"i_ver_s":"V1.40Build52927",
"i_modle":"omnik2000tl2",
"i_pow":"",
"i_pow":"2000",
"i_pow_n":1225,
"i_eday":"10.90",
"i_eall":"8674.0"
"i_eall":"8674.0",
"i_alarm":"F23",
"i_last_t":0
}
2 changes: 1 addition & 1 deletion tests/fixtures/status_webdata.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var version="H4.01.38Y1.0.09W1.0.08";var m2mRssi="96%";var wanIp="192.168.0.10";var webData="12345678910,NL2-V9.8-5931,V5.3-00157,omnik2000tl2,,1010,488,105319,,4,";
var version="H4.01.38Y1.0.09W1.0.08";var m2mRssi="96%";var wanIp="192.168.0.10";var webData="12345678910,NL2-V9.8-5931,V5.3-00157,omnik4000tl2,4000,140,30,153637,F13,0,";
16 changes: 10 additions & 6 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ async def test_inverter_js_webdata(aresponses: ResponsesMockServer) -> None:
assert inverter.serial_number == "12345678910"
assert inverter.firmware == "NL2-V9.8-5931"
assert inverter.firmware_slave == "V5.3-00157"
assert inverter.model == "omnik2000tl2"
assert inverter.solar_rated_power is None
assert inverter.solar_current_power == 1010
assert inverter.solar_energy_today == 4.88
assert inverter.solar_energy_total == 10531.9
assert inverter.model == "omnik4000tl2"
assert inverter.alarm_code == "F13"
assert inverter.solar_rated_power == 4000
assert inverter.solar_current_power == 140
assert inverter.solar_energy_today == 0.3
assert inverter.solar_energy_total == 15363.7


@pytest.mark.asyncio
Expand Down Expand Up @@ -96,6 +97,7 @@ async def test_inverter_html(aresponses: ResponsesMockServer) -> None:
assert inverter.firmware == "V5.07Build245"
assert inverter.firmware_slave is None
assert inverter.model == "Omnik2500tl"
assert inverter.alarm_code == "F13"
assert inverter.solar_rated_power == 2500
assert inverter.solar_current_power == 219
assert inverter.solar_energy_today == 0.23
Expand Down Expand Up @@ -157,6 +159,7 @@ async def test_inverter_without_session(aresponses: ResponsesMockServer) -> None
assert inverter.firmware == "001F"
assert inverter.firmware_slave == "002F"
assert inverter.model == "0079"
assert inverter.alarm_code is None
assert inverter.solar_rated_power is None
assert inverter.solar_current_power == 5850
assert inverter.solar_energy_today == 9.80
Expand Down Expand Up @@ -263,7 +266,8 @@ async def test_inverter_json(aresponses: ResponsesMockServer) -> None:
assert inverter.firmware == "V1.25Build23261"
assert inverter.firmware_slave == "V1.40Build52927"
assert inverter.model == "omnik2000tl2"
assert inverter.solar_rated_power is None
assert inverter.alarm_code == "F23"
assert inverter.solar_rated_power == 2000
assert inverter.solar_current_power == 1225
assert inverter.solar_energy_today == 10.90
assert inverter.solar_energy_total == 8674.0
Expand Down

0 comments on commit a7e22f7

Please sign in to comment.