diff --git a/custom_components/solarman/inverter_definitions/deye_2mppt.yaml b/custom_components/solarman/inverter_definitions/deye_2mppt.yaml index f10458a..4718836 100644 --- a/custom_components/solarman/inverter_definitions/deye_2mppt.yaml +++ b/custom_components/solarman/inverter_definitions/deye_2mppt.yaml @@ -610,17 +610,17 @@ parameters: registers: [0x0065, 0x0066] icon: "mdi:alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0002 + - bit: 1 value: "Fan failure" - - key: 0x0004 + - bit: 2 value: "Grid phase failure" - - key: 0x0008 + - bit: 3 value: "Meter communication failure" - - key: 0x40000000 + - bit: 30 value: "Battery loss" - - key: 0x80000000 + - bit: 31 value: "Parallel communication quality" - key: "default" value: "Error" diff --git a/custom_components/solarman/inverter_definitions/deye_4mppt.yaml b/custom_components/solarman/inverter_definitions/deye_4mppt.yaml index 3d1fa6a..02ec729 100644 --- a/custom_components/solarman/inverter_definitions/deye_4mppt.yaml +++ b/custom_components/solarman/inverter_definitions/deye_4mppt.yaml @@ -747,17 +747,17 @@ parameters: registers: [0x0065, 0x0066] icon: "mdi:alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0002 + - bit: 1 value: "Fan failure" - - key: 0x0004 + - bit: 2 value: "Grid phase failure" - - key: 0x0008 + - bit: 3 value: "Meter communication failure" - - key: 0x40000000 + - bit: 30 value: "Battery loss" - - key: 0x80000000 + - bit: 31 value: "Parallel communication quality" - key: "default" value: "Error" diff --git a/custom_components/solarman/inverter_definitions/deye_hybrid.yaml b/custom_components/solarman/inverter_definitions/deye_hybrid.yaml index 96c7563..0eb835d 100644 --- a/custom_components/solarman/inverter_definitions/deye_hybrid.yaml +++ b/custom_components/solarman/inverter_definitions/deye_hybrid.yaml @@ -678,17 +678,17 @@ parameters: registers: [0x0065, 0x0066] icon: "mdi:alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0002 + - bit: 1 value: "Fan failure" - - key: 0x0004 + - bit: 2 value: "Grid phase failure" - - key: 0x0008 + - bit: 3 value: "Meter communication failure" - - key: 0x40000000 + - bit: 30 value: "Battery loss" - - key: 0x80000000 + - bit: 31 value: "Parallel communication quality" - key: "default" value: "Error" diff --git a/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml b/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml index ee9bee2..39b897b 100644 --- a/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml +++ b/custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml @@ -1690,17 +1690,17 @@ parameters: registers: [0x0229, 0x022A] icon: "mdi:alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0002 + - bit: 1 value: "Fan failure" - - key: 0x0004 + - bit: 2 value: "Grid phase failure" - - key: 0x0008 + - bit: 3 value: "Meter communication failure" - - key: 0x40000000 + - bit: 30 value: "Battery loss" - - key: 0x80000000 + - bit: 31 value: "Parallel communication quality" - key: "default" value: "Error" @@ -1712,23 +1712,23 @@ parameters: registers: [0x22B, 0x022C, 0x022D, 0x022E] icon: "mdi:message-alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0040 + - bit: 6 value: "DC/DC Soft Start failure" - - key: 0x0200 + - bit: 9 value: "Auxiliary power supply failure" - - key: 0x1000 + - bit: 12 value: "Working mode changed" - - key: 0x00020000 + - bit: 17 value: "AC Over-current failure" - - key: 0x00040000 + - bit: 18 value: "Tz_Integ_Fault failure" - - key: 0x00080000 + - bit: 19 value: "DC Over-current failure" - - key: 0x00400000 + - bit: 22 value: "AC current leakage failure" - - key: 0x8000000000000000 + - bit: 63 value: "Temperature is too high" - key: "default" value: "Error" diff --git a/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml b/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml index 7e1b3d3..c0309b2 100644 --- a/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml +++ b/custom_components/solarman/inverter_definitions/deye_sg04lp3.yaml @@ -1655,17 +1655,17 @@ parameters: registers: [0x0229, 0x022A] icon: "mdi:alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0002 + - bit: 1 value: "Fan failure" - - key: 0x0004 + - bit: 2 value: "Grid phase failure" - - key: 0x0008 + - bit: 3 value: "Meter communication failure" - - key: 0x40000000 + - bit: 30 value: "Battery loss" - - key: 0x80000000 + - bit: 31 value: "Parallel communication quality" - key: "default" value: "Error" @@ -1677,23 +1677,23 @@ parameters: registers: [0x22B, 0x022C, 0x022D, 0x022E] icon: "mdi:message-alert-outline" lookup: - - key: 0x0000 + - key: 0 value: "OK" - - key: 0x0040 + - bit: 6 value: "DC/DC Soft Start failure" - - key: 0x0200 + - bit: 9 value: "Auxiliary power supply failure" - - key: 0x1000 + - bit: 12 value: "Working mode changed" - - key: 0x00020000 + - bit: 17 value: "AC Over-current failure" - - key: 0x00040000 + - bit: 18 value: "Tz_Integ_Fault failure" - - key: 0x00080000 + - bit: 19 value: "DC Over-current failure" - - key: 0x00400000 + - bit: 22 value: "AC current leakage failure" - - key: 0x8000000000000000 + - bit: 63 value: "Temperature is too high" - key: "default" value: "Error" diff --git a/custom_components/solarman/inverter_definitions/deye_string.yaml b/custom_components/solarman/inverter_definitions/deye_string.yaml index 3cb0a1b..cde9ec6 100644 --- a/custom_components/solarman/inverter_definitions/deye_string.yaml +++ b/custom_components/solarman/inverter_definitions/deye_string.yaml @@ -172,6 +172,27 @@ parameters: - key: 0x0004 value: "Fault" + - name: "Device Alarm" + class: "enum" + rule: 3 + registers: [0x0065, 0x0066] + icon: "mdi:alert-outline" + lookup: + - key: 0 + value: "OK" + - bit: 1 + value: "Fan failure" + - bit: 2 + value: "Grid phase failure" + - bit: 3 + value: "Meter communication failure" + - bit: 30 + value: "Battery loss" + - bit: 31 + value: "Parallel communication quality" + - key: "default" + value: "Error" + - group: PV items: - name: PV Power diff --git a/custom_components/solarman/parser.py b/custom_components/solarman/parser.py index 8b60478..5988468 100644 --- a/custom_components/solarman/parser.py +++ b/custom_components/solarman/parser.py @@ -153,13 +153,17 @@ def in_range(self, value, definition): def lookup_value(self, value, keyvaluepairs): for o in keyvaluepairs: - key = o["key"] - if isinstance(key, list): - for k in key: - if k == value: - return o["value"] - elif key == value or "default" in o or key == "default": - return o["value"] + if "bit" in o: + if 1 << o["bit"] == value or "default": + return o["value"] + else: + key = o["key"] + if isinstance(key, list): + for k in key: + if k == value: + return o["value"] + elif key == value or "default" in o or key == "default": + return o["value"] return keyvaluepairs[0]["value"]