Skip to content

Commit

Permalink
refactor: Number of Phases by Rated Phases - Deye Hybrid
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 9, 2024
1 parent 8dc99c2 commit c719d3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def set_request(code, start, end):
return { REQUEST_CODE: code, REQUEST_START: start, REQUEST_END: end }

def lookup_profile(response, attr):
if response and (device_type := get_addr_value(response, *AUTODETECTION_TYPE_DEYE)):
if response and (device_type := get_addr_value(response, *AUTODETECTION_DEVICE_DEYE)):
f, m, c = next(iter([AUTODETECTION_TABLE_DEYE[i] for i in AUTODETECTION_TABLE_DEYE if device_type in i]))
if (t := get_addr_value(response, *AUTODETECTION_TYPE_DEYE)) and device_type in (0x0003, 0x0300):
attr[ATTR_TABLE[CONF_PHASE]] = min(t if t == 1 else 3, attr[ATTR_TABLE[CONF_PHASE]])
if (v := get_addr_value(response, AUTODETECTION_CODE_DEYE, c)) and (t := (v & 0x0F00) // 0x100) and (p := v & 0x000F):
attr[ATTR_TABLE[CONF_MOD]], attr[ATTR_TABLE[CONF_MPPT]], attr[ATTR_TABLE[CONF_PHASE]] = max(m, attr[ATTR_TABLE[CONF_MOD]]), min(t, attr[ATTR_TABLE[CONF_MPPT]]), min(p, attr[ATTR_TABLE[CONF_PHASE]])
return f
Expand Down
3 changes: 2 additions & 1 deletion custom_components/solarman/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
AUTODETECTION_REDIRECT_TABLE = [DEFAULT_TABLE[CONF_LOOKUP_FILE], "deye_string.yaml", "deye_p1.yaml", "deye_hybrid.yaml", "deye_micro.yaml", "deye_4mppt.yaml", "deye_2mppt.yaml", "deye_p3.yaml", "deye_sg04lp3.yaml", "deye_sg01hp3.yaml"]
AUTODETECTION_CODE_DEYE = 0x03
AUTODETECTION_REQUEST_DEYE = (AUTODETECTION_CODE_DEYE, 0x00, 0x16)
AUTODETECTION_TYPE_DEYE = (AUTODETECTION_CODE_DEYE, 0x00)
AUTODETECTION_DEVICE_DEYE = (AUTODETECTION_CODE_DEYE, 0x00)
AUTODETECTION_TYPE_DEYE = (AUTODETECTION_CODE_DEYE, 0x08)
AUTODETECTION_TABLE_DEYE = { (0x0002, 0x0200): ("deye_string.yaml", 0, 0x12), (0x0003, 0x0300): ("deye_hybrid.yaml", 0, 0x12), (0x0004, 0x0400): ("deye_micro.yaml", 0, 0x12), (0x0005, 0x0500): ("deye_p3.yaml", 0, 0x16), (0x0006, 0x0007, 0x0600, 0x0008, 0x0601): ("deye_p3.yaml", 1, 0x16) }

PROFILE_REDIRECT_TABLE = { "deye_4mppt.yaml": "deye_micro.yaml", "deye_2mppt.yaml": "deye_micro.yaml", "sofar_hyd3k-6k-es.yaml": "sofar_hyd-es.yaml", "hyd-zss-hp-3k-6k.yaml": "zcs_azzurro-hyd-zss-hp.yaml", "solis_1p8k-5g.yaml": "solis_1p-5g.yaml" }
Expand Down

0 comments on commit c719d3e

Please sign in to comment.