Skip to content

Commit

Permalink
fix: Versions MAIN and HMI - Deye
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 21, 2024
1 parent 9e1dd3f commit 0050dc8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 110 deletions.
25 changes: 5 additions & 20 deletions custom_components/solarman/inverter_definitions/deye_hybrid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ parameters:
"Device Serial Number",
"Device Rated Phase",
"Device Chip Type",
"Device Communication Board Firmware Version 2",
"Device Control Board Helper Version",
"Device Control Board Firmware Version 2",
"Device Control Board Firmware Version",
"Device Communication Board Firmware Version",
"Device Rated Power",
Expand Down Expand Up @@ -101,30 +98,18 @@ parameters:
- key: 0x0003
value: "GD32F303"

- name: "Device Communication Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000A]

- name: "Device Control Board Helper Version"
attribute:
rule: 7
registers: [0x000B]

- name: "Device Control Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000C]

- name: "Device Control Board Firmware Version"
attribute:
rule: 7
registers: [0x000D]
delimiter: ""
registers: [0x000D, 0x000C, 0x000B]

- name: "Device Communication Board Firmware Version"
attribute:
rule: 7
registers: [0x000E]
hex:
delimiter: ""
registers: [0x000E, 0x000A]

- name: "Device Rated Power"
attribute:
Expand Down
25 changes: 5 additions & 20 deletions custom_components/solarman/inverter_definitions/deye_micro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ parameters:
"Device Serial Number",
"Device Flags",
"Device Chip Type",
"Device Communication Board Firmware Version 2",
"Device Control Board Helper Version",
"Device Control Board Firmware Version 2",
"Device Control Board Firmware Version",
"Device Communication Board Firmware Version",
"Device Rated Power",
Expand Down Expand Up @@ -99,30 +96,18 @@ parameters:
- key: 0x0003
value: "GD32F303"

- name: "Device Communication Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000A]

- name: "Device Control Board Helper Version"
attribute:
rule: 7
registers: [0x000B]

- name: "Device Control Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000C]

- name: "Device Control Board Firmware Version"
attribute:
rule: 7
registers: [0x000D]
delimiter: ""
registers: [0x000D, 0x000C, 0x000B]

- name: "Device Communication Board Firmware Version"
attribute:
rule: 7
registers: [0x000E]
hex:
delimiter: ""
registers: [0x000E, 0x000A]

- name: "Device Rated Power"
attribute:
Expand Down
61 changes: 13 additions & 48 deletions custom_components/solarman/inverter_definitions/deye_p3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,11 @@ parameters:
"Device Modbus Address",
"Device Protocol Version",
"Device Serial Number",
"Device Control Board Version",
"Device Control Board Auxiliary MCU Software Version",
"Device Control Board Bootloader Software Version",
"Device AFCI Version",
"Device Control Board Auxiliary MCU Board Version",
"Device Control Board Firmware Version 2",
"Device Control Board Firmware Version",
"Device Communication Board Firmware Version 1",
"Device Communication Board Firmware Version 2",
"Device Communication Board Firmware Version",
"Device MCU Board Version",
"Device MCU Version",
"Device AFCI Version",
"Device Rated Power",
"Device MPPTs",
"Device Phases",
Expand All @@ -81,66 +76,36 @@ parameters:
rule: 5
registers: [0x0003, 0x0004, 0x0005, 0x0006, 0x0007]

- name: "Device Control Board Version"
- name: "Device MCU Board Version"
attribute:
rule: 7
mask: 0x00FF
remove: "0."
delimiter: ""
registers: [0x000A]

- name: "Device Control Board Auxiliary MCU Software Version"
attribute:
rule: 1
mask: 0xFF00
registers: [0x000B]

- name: "Device Control Board Bootloader Software Version"
attribute:
rule: 1
mask: 0x00FF
registers: [0x000B]

- name: "Device AFCI Version"
attribute:
rule: 7
remove: "0."
delimiter: ""
registers: [0x000C]

- name: "Device Control Board Auxiliary MCU Board Version"
- name: "Device MCU Version"
attribute:
rule: 7
remove: "0."
delimiter: ""
registers: [0x000D]

- name: "Device Control Board Firmware Version 2"
attribute:
rule: 7
remove: "0."
registers: [0x000E]

- name: "Device Control Board Firmware Version"
attribute:
rule: 7
remove: "0."
registers: [0x000F]

- name: "Device Communication Board Firmware Version 1"
attribute:
rule: 7
remove: "0."
registers: [0x0010]

- name: "Device Communication Board Firmware Version 2"
attribute:
rule: 7
remove: "0."
registers: [0x0011]
delimiter: ""
registers: [0x000E, 0x000F, 0x000B]

- name: "Device Communication Board Firmware Version"
attribute:
rule: 7
remove: "0."
registers: [0x0012]
hex:
delimiter: ""
registers: [0x0011, 0x0012, 0x0010]

- name: "Device Rated Power"
attribute:
Expand Down
25 changes: 5 additions & 20 deletions custom_components/solarman/inverter_definitions/deye_string.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ parameters:
"Device Serial Number",
"Device Rated Phase",
"Device Chip Type",
"Device Communication Board Firmware Version 2",
"Device Control Board Helper Version",
"Device Control Board Firmware Version 2",
"Device Control Board Firmware Version",
"Device Communication Board Firmware Version",
"Device Rated Power",
Expand Down Expand Up @@ -101,30 +98,18 @@ parameters:
- key: 0x0003
value: "GD32F303"

- name: "Device Communication Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000A]

- name: "Device Control Board Helper Version"
attribute:
rule: 7
registers: [0x000B]

- name: "Device Control Board Firmware Version 2"
attribute:
rule: 7
registers: [0x000C]

- name: "Device Control Board Firmware Version"
attribute:
rule: 7
registers: [0x000D]
delimiter: ""
registers: [0x000D, 0x000C, 0x000B]

- name: "Device Communication Board Firmware Version"
attribute:
rule: 7
registers: [0x000E]
hex:
delimiter: ""
registers: [0x000E, 0x000A]

- name: "Device Rated Power"
attribute:
Expand Down
14 changes: 12 additions & 2 deletions custom_components/solarman/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,28 @@ def try_parse_bits(self, data, definition):

def try_parse_version(self, data, definition):
code = get_code(definition, "read")
f = "{:1x}" if "hex" in definition else "{:1d}"
delimiter_digit, delimiter_register = (d, "-") if (d := definition.get("delimiter", '.')) is not None and isinstance(d, str) else (d.get("digit", "."), d.get("register", "-"))
value = ""

registers_count = len(definition["registers"])

for r in definition["registers"]:
if (temp := get_addr_value(data, code, r)) is None:
return

value += str(temp >> 12) + "." + str(temp >> 8 & 0x0F) + "." + str(temp >> 4 & 0x0F) + "." + str(temp & 0x0F)
value += f.format(temp >> 12) + delimiter_digit + f.format(temp >> 8 & 0x0F) + delimiter_digit + f.format(temp >> 4 & 0x0F) + delimiter_digit + f.format(temp & 0x0F)

if registers_count > 1:
value += delimiter_register

if value.endswith(delimiter_register):
value = value[:-1]

if (remove := definition.get("remove")) is not None:
value = value.replace(remove, "")

self.set_state(definition["key"], value)
self.set_state(definition["key"], value.upper())

def try_parse_datetime(self, data, definition):
code = get_code(definition, "read")
Expand Down

0 comments on commit 0050dc8

Please sign in to comment.