Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream/general improvements #391

Merged
merged 11 commits into from
Jan 15, 2025
35 changes: 35 additions & 0 deletions src/ha_addon_sunsynk_multi/sensor_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,18 @@ def import_definitions() -> None:
"grid_l3_power", # 3PH LV & HV
"grid_power",
"grid_voltage",
"grid_current",
"inverter_current",
"inverter_power",
"inverter_voltage",
"load_frequency",
"load_power",
"load_l1_power",
"load_l2_power",
"load_l3_power",
"load_l1_voltage",
"load_l2_voltage",
"load_l3_voltage",
"non_essential_power",
"overall_state",
"priority_load",
Expand All @@ -196,6 +201,12 @@ def import_definitions() -> None:
"pv2_current",
"pv2_power",
"pv2_voltage",
"pv3_current",
"pv3_power",
"pv3_voltage",
"pv4_current",
"pv4_power",
"pv4_voltage",
"use_timer",
],
"settings": [
Expand Down Expand Up @@ -244,6 +255,7 @@ def import_definitions() -> None:
"grid_standard",
"configured_grid_frequency",
"configured_grid_phases",
"track_grid_phase",
"ups_delay_time",
],
"generator": [
Expand All @@ -259,6 +271,9 @@ def import_definitions() -> None:
"gen_signal_on",
],
"diagnostics": [
"inverter_l1_power",
"inverter_l2_power",
"inverter_l3_power",
"grid_voltage",
"grid_l1_voltage",
"grid_l2_voltage",
Expand All @@ -281,6 +296,26 @@ def import_definitions() -> None:
"lithium_battery_loss_warning",
"parallel_communication_quality_warning",
],
"battery": [
"battery_type",
"battery_capacity_current",
"battery_max_charge_current",
"battery_max_discharge_current",
"battery_shutdown_capacity",
"battery_restart_capacity",
"battery_low_capacity",
"battery_equalization_voltage",
"battery_absorption_voltage",
"battery_float_voltage",
"battery_shutdown_voltage",
"battery_low_voltage",
"battery_restart_voltage",
"battery_wake_up",
"battery_resistance",
"battery_charge_efficiency",
"battery_equalization_days",
"battery_equalization_hours",
],
}


Expand Down
1 change: 1 addition & 0 deletions src/sunsynk/definitions/single_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
# Settings
###########
SENSORS += (
SwitchRWSensor(43, "Inverter Power", on=1), # 0=off, 1=on
Sensor(200, "Control Mode"),
SwitchRWSensor(232, "Grid Charge enabled", "", bitmask=1),
SelectRWSensor(
Expand Down
86 changes: 47 additions & 39 deletions src/sunsynk/definitions/three_phase_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
# Inverter Power
#################
SENSORS += (
Sensor(636, "Inverter power", WATT, -1),
Sensor(633, "Inverter L1 power", WATT, -1),
Sensor(634, "Inverter L2 power", WATT, -1),
Sensor(635, "Inverter L3 power", WATT, -1),
Sensor((633, 691), "Inverter L1 power", WATT, -1),
Sensor((634, 692), "Inverter L2 power", WATT, -1),
Sensor((635, 693), "Inverter L3 power", WATT, -1),
Sensor((636, 694), "Inverter power", WATT, -1),
Sensor(627, "Inverter L1 voltage", VOLT, 0.1),
Sensor(628, "Inverter L2 voltage", VOLT, 0.1),
Sensor(629, "Inverter L3 voltage", VOLT, 0.1),
Expand All @@ -47,39 +47,57 @@
#############
SENSORS += (
Sensor(609, "Grid frequency", "Hz", 0.01),
Sensor(625, "Grid power", WATT, -1), # gridTotalPac
Sensor(622, "Grid L1 power", WATT, -1), # aPower
Sensor(623, "Grid L2 power", WATT, -1), # bPower
Sensor(624, "Grid L3 power", WATT, -1), # cPower
Sensor((622, 687), "Grid L1 power", WATT, -1), # aPower
Sensor((623, 688), "Grid L2 power", WATT, -1), # bPower
Sensor((624, 689), "Grid L3 power", WATT, -1), # cPow
Sensor((625, 690), "Grid power", WATT, -1), # gridTotalPac
Sensor(598, "Grid L1 voltage", VOLT, 0.1), # aLineVolt
Sensor(599, "Grid L2 voltage", VOLT, 0.1), # bLineVolt
Sensor(600, "Grid L3 voltage", VOLT, 0.1), # cLineVolt
Sensor(604, "A Phase Power on the Inner Side of the Grid", "W"),
Sensor(605, "B Phase Power on the Inner Side of the Grid", "W"),
Sensor(606, "C Phase Power on the Inner Side of the Grid", "W"),
Sensor(607, "Total Active Power from Side to Side of the Grid", "W", -1),
Sensor(608, "Grid Side - Inside Total Apparent Power", "W"),
Sensor((604, 700), "A Phase Power on the Inner Side of the Grid", "W", -1),
Sensor((605, 701), "B Phase Power on the Inner Side of the Grid", "W", -1),
Sensor((606, 702), "C Phase Power on the Inner Side of the Grid", "W", -1),
Sensor((607, 703), "Total Active Power from Side to Side of the Grid", "W", -1),
Sensor((608, 704), "Grid Side - Inside Total Apparent Power", "W", -1),
MathSensor(
(610, 611, 612), "Grid current", AMPS, factors=(0.01, 0.01, 0.01)
(610, 611, 612), "Grid current", AMPS, factors=(-0.01, -0.01, -0.01)
), # iac1,iac2,iac3
Sensor((616, 705), "Grid CT L1 power", WATT, -1), # aPower
Sensor((617, 706), "Grid CT L2 power", WATT, -1), # bPower
Sensor((618, 707), "Grid CT L3 power", WATT, -1), # cPower
Sensor((619, 708), "Grid CT power", WATT, -1), # totalPower
MathSensor(
(613, 614, 615), "Grid CT current", AMPS, factors=(-0.01, -0.01, -0.01)
), # iac1,iac2,iac3
Sensor(616, "Grid CT L1 power", WATT, -1), # aPower
Sensor(617, "Grid CT L2 power", WATT, -1), # bPower
Sensor(618, "Grid CT L3 power", WATT, -1), # cPower
Sensor(619, "Grid CT power", WATT, -1), # totalPower
)

#############
# Load Power
#############
SENSORS += (
Sensor(653, "Load power", WATT, -1),
Sensor(650, "Load L1 power", WATT, -1),
Sensor(651, "Load L2 power", WATT, -1),
Sensor(652, "Load L3 power", WATT, -1),
Sensor((650, 656), "Load L1 power", WATT, -1),
Sensor((651, 657), "Load L2 power", WATT, -1),
Sensor((652, 658), "Load L3 power", WATT, -1),
Sensor((653, 659), "Load power", WATT, -1),
Sensor(644, "Load L1 voltage", VOLT, 0.1),
Sensor(645, "Load L2 voltage", VOLT, 0.1),
Sensor(646, "Load L3 voltage", VOLT, 0.1),
Sensor(655, "Load frequency", "Hz", 0.01),
)

##############
# Gen Power
##############
SENSORS += (
Sensor(661, "Gen L1 voltage", VOLT, 0.1),
Sensor(662, "Gen L2 voltage", VOLT, 0.1),
Sensor(663, "Gen L3 voltage", VOLT, 0.1),
Sensor((664, 668), "Gen L1 power", WATT, -1),
Sensor((665, 669), "Gen L2 power", WATT, -1),
Sensor((666, 670), "Gen L3 power", WATT, -1),
Sensor((667, 671), "Gen power", WATT, -1),
Sensor(671, "Gen L1 current", AMPS, -0.01),
Sensor(672, "Gen L2 current", AMPS, -0.01),
Sensor(673, "Gen L3 current", AMPS, -0.01),
)

##############
Expand Down Expand Up @@ -127,20 +145,6 @@
Sensor(683, "PV4 current", AMPS, 0.1),
)


###################
# Power on Outputs (aka GEN - which has multiple modes on the deye 3 Phase )
###################
SENSORS += (
Sensor(661, "Gen L1 volts", VOLT, 0.1),
Sensor(662, "Gen L2 volts", VOLT, 0.1),
Sensor(663, "Gen L3 volts", VOLT, 0.1),
Sensor(664, "Gen L1 power", WATT, -1),
Sensor(665, "Gen L2 power", WATT, -1),
Sensor(666, "Gen L3 power", WATT, -1),
Sensor(667, "Gen power", WATT, -1),
)

###################
# Energy
###################
Expand Down Expand Up @@ -195,6 +199,7 @@
# Settings
###########
SENSORS += (
SwitchRWSensor(80, "Inverter Power", on=1), # 0=off, 1=on
NumberRWSensor(128, "Grid Charge Battery current", AMPS, max=240),
NumberRWSensor(127, "Grid Charge Start Battery SOC", "%"),
SwitchRWSensor(130, "Grid Charge enabled", on=1),
Expand Down Expand Up @@ -223,11 +228,13 @@
options={0: "Use Battery Voltage", 1: "Lithium (Use BMS)", 2: "No Battery"},
),
SelectRWSensor(
# according to docs, 0 is enabled for this one, but reported to be wrong:
# https://github.com/kellerza/sunsynk/issues/381#issuecomment-2568995917
112,
"Battery Wake Up",
options={0: "Enabled", 1 << 0: "Disabled"},
options={0: "Disabled", 1 << 0: "Enabled"},
bitmask=1 << 0,
), # according to docs, 0 is enabled for this one
),
NumberRWSensor(113, "Battery Resistance", "mΩ", max=6000),
Sensor(114, "Battery Charge Efficiency", "%", 0.1),
SelectRWSensor(
Expand Down Expand Up @@ -533,6 +540,7 @@
},
bitmask=0b11 << 14,
),
SwitchRWSensor(235,"Track Grid Phase",on=1),
NumberRWSensor(209, "UPS delay time", "s"),
)
############
Expand Down
23 changes: 21 additions & 2 deletions src/sunsynk/definitions/three_phase_hv.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@
5: "Deye_HV",
6: "BYD_HV",
7: "JINKOBSS_HV",
8: "Greenway_HV",
9: "WTS_HV",
10: "FNSPOWER_HV",
11: "SHOTOPOWER_HV",
12: "DOWELL_HV",
13: "WECO_HV",
14: "ZRGP_HV",
15: "CFE_HV",
16: "SUNWODA_HV",
17: "GENIX_HV",
18: "THANKSUN_HV",
19: "TURBO_HV",
20: "ENOVANCE_HV",
21: "MLS_HV",
22: "LDV_HV",
23: "VW_HV",
24: "CSE_HV",
25: "HUAFON_HV",
26: "OMLIKA_HV",
}
SENSORS += (
SelectRWSensor(
Expand Down Expand Up @@ -166,7 +185,7 @@
Sensor(213, "Battery 1 BMS discharging current limit", AMPS),
Sensor(214, "Battery 1 BMS SOC", "%"),
Sensor(215, "Battery 1 BMS voltage", VOLT, 0.1),
Sensor(216, "Battery 1 BMS current", AMPS, -0.1),
Sensor(216, "Battery 1 BMS current", AMPS, 0.1),
TempSensor(217, "Battery 1 BMS temperature", CELSIUS, 0.1),
Sensor(218, "Battery 1 BMS max charge current limit", AMPS),
Sensor(219, "Battery 1 BMS max discharge current limit", AMPS),
Expand Down Expand Up @@ -202,7 +221,7 @@
Sensor(244, "Battery 2 BMS discharging current limit", AMPS),
Sensor(245, "Battery 2 BMS SOC", "%"),
Sensor(246, "Battery 2 BMS voltage", VOLT, 0.1),
Sensor(247, "Battery 2 BMS current", AMPS, -0.1),
Sensor(247, "Battery 2 BMS current", AMPS, 0.1),
TempSensor(248, "Battery 2 BMS temperature", CELSIUS, 0.1),
Sensor(249, "Battery 2 BMS max charge current limit", AMPS),
Sensor(250, "Battery 2 BMS max discharge current limit", AMPS),
Expand Down
27 changes: 27 additions & 0 deletions src/sunsynk/definitions/three_phase_lv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Sensor,
TempSensor,
)
from sunsynk.rwsensors import SelectRWSensor

SENSORS = SENSORS.copy()

Expand All @@ -27,3 +28,29 @@
"grid_connected_status": "grid_status",
}
)

lv_battery_manufacturers = {
0: "HereYin",
1: "PYLON",
2: "SOLAX",
3: "DYNESS_L",
4: "CCGX",
5: "Alpha_ESS",
6: "SUNGO_CAN",
7: "VISION_CAN",
8: "WATTSONIC_CAN",
9: "KUNLAN",
10: "GSEnergy",
11: "GS_HUB",
12: "BYD_LV",
13: "AOBO",
14: "DEYE",
15: "CFE",
16: "DMEGC",
17: "UZENERGY",
18: "GROWATT",
}

SENSORS += (
SelectRWSensor(229, "Battery 1 Manufacturer", options=lv_battery_manufacturers),
)
37 changes: 34 additions & 3 deletions src/sunsynk/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,34 +281,65 @@ def reg_to_value(self, regs: RegType) -> ValType:
"""Decode HV Inverter faults."""
faults = {
1: "DC Inversed Failure",
2: "DC insula�on impedance permanent fault",
3: "DC leakage current fault",
4: "Ground fault GFDI",
5: "Read the memory error",
6: "Write the memory error",
7: "DC START Failure",
8: "GFDI grounding touch failure",
9: "IGBT damaged by excessive drop voltage",
10: "Auxiliary power supply failure",
11: "AC main contactor errors",
12: "AC auxiliary contactor errors",
13: "Working mode change",
14: "DC over current SW Failure",
15: "AC over current SW Failure",
10: "Aux Power Board Failure",
16: "DC Ground Leakage current fault",
18: "AC over current TZ",
19: "All hardware failure synthesis",
20: "DC over current",
21: "DC HV Bus over current",
22: "Remote Emergency stop",
23: "AC leakage current is transient over current",
24: "DC insulation impedance",
25: "DC feedback fault",
26: "DC busbar imbalanced",
29: "Parallel comms cable",
27: "DC end insula�on error",
28: "Inverter 1 DC high fault",
29: "Parallel comms cable/AC load switch failure",
30: "AC main contactor failure",
31: "Relay open circuit fault",
32: "Inverter 2 dc high fault",
33: "AC Overcurrent",
34: "AC Overload (backup)",
35: "No AC grid",
36: "AC grid phase error",
37: "AC three-phase voltage unbalance failure",
38: "AC three-phase current unbalance failure",
39: "AC over current (one cycle)",
40: "DC over current",
41: "Parallel system stopped",
42: "AC line low voltage",
43: "AC Line V,W over voltage",
44: "AC Line V,W low voltage",
45: "AC Line U,V over voltage",
46: "Battery 1 fault",
49: "Battery 2 fault",
47: "AC grid freq too high",
48: "AC grid freq too low",
49: "Battery 2 fault",
50: "V phase grid current DC component over current",
51: "W phase grid current DC component over current",
52: "DC voltage too high",
53: "DC voltage too low",
54: "battery 1 voltage high",
55: "battery 2 voltage high",
56: "battery 1 voltage low",
57: "battery 2 voltage low",
58: "bms communication lost",
59: "AC grid V over current",
60: "AC grid W over current",
61: "Reactor A phase over current",
62: "DRM stop activated",
63: "ARC fault",
64: "Heat sink tempfailure",
Expand Down
Loading
Loading