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

Make sensor groups inverter model aware #309

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/ha_addon_sunsynk_multi/sensor_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,72 @@
],
}

SENSOR_GROUPS_3PH_LV = {
"power_flow_card": [
"battery_current",
"battery_power",
"battery_soc",
"battery_voltage",
"day_battery_charge",
"day_battery_discharge",
"day_grid_export",
"day_grid_import",
"day_load_energy",
"day_pv_energy",
"grid_connected",
"grid_ct_power",
"grid_frequency",
"grid_power",
"grid_l1_voltage",
"grid_l2_voltage",
"grid_l3_voltage",
"grid_l1_power",
"grid_l2_power",
"grid_l3_power",
"inverter_power",
"inverter_frequency",
"overall_state",
"priority_load",
"pv1_current",
"pv1_power",
"pv1_voltage",
"use_timer",
],
}

SENSOR_GROUPS_3PH_HV = {
"power_flow_card": [
"battery_1_current",
"battery_1_power",
"battery_1_soc",
"battery_1_voltage",
"day_battery_charge",
"day_battery_discharge",
"day_grid_export",
"day_grid_import",
"day_load_energy",
"day_pv_energy",
"grid_connected",
"grid_ct_power",
"grid_frequency",
"grid_power",
"grid_l1_voltage",
"grid_l2_voltage",
"grid_l3_voltage",
"grid_l1_power",
"grid_l2_power",
"grid_l3_power",
"inverter_power",
"inverter_frequency",
"overall_state",
"priority_load",
"pv1_current",
"pv1_power",
"pv1_voltage",
"use_timer",
],
}


def get_sensors(
*, target: Iterable[Sensor], names: list[str], warn_once: bool = True
Expand All @@ -213,6 +279,12 @@

name = slug(name)

# Merge sensor groups
if OPT.sensor_definitions == "three-phase":
SENSOR_GROUPS.update(SENSOR_GROUPS_3PH_LV)

Check warning on line 284 in src/ha_addon_sunsynk_multi/sensor_options.py

View check run for this annotation

Codecov / codecov/patch

src/ha_addon_sunsynk_multi/sensor_options.py#L284

Added line #L284 was not covered by tests
elif OPT.sensor_definitions == "three-phase-hv":
SENSOR_GROUPS.update(SENSOR_GROUPS_3PH_HV)

Check warning on line 286 in src/ha_addon_sunsynk_multi/sensor_options.py

View check run for this annotation

Codecov / codecov/patch

src/ha_addon_sunsynk_multi/sensor_options.py#L286

Added line #L286 was not covered by tests

# Recursive add for groups
if name in SENSOR_GROUPS:
yield from get_sensors(
Expand Down
Loading