diff --git a/custom_components/solarman/common.py b/custom_components/solarman/common.py index 0adbd10..e33fe6b 100644 --- a/custom_components/solarman/common.py +++ b/custom_components/solarman/common.py @@ -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 diff --git a/custom_components/solarman/const.py b/custom_components/solarman/const.py index 07e8560..fefd4f0 100644 --- a/custom_components/solarman/const.py +++ b/custom_components/solarman/const.py @@ -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" }