Skip to content

Commit a560117

Browse files
authored
Fix AC charger switch state by using numeric system state values (#284)
The AC charger system state is stored internally as a numeric enum value, not a mapped string. The previous switch logic compared the state against string values ("Initializing", "Fault", etc.), which caused the switch to never correctly reflect the charger state. This change updates is_on_fn to rely on the numeric system state values reported by the charger. Currently treating states 3, 4, and 5 as ON. This aligns the AC charger switch behavior with how other switches (e.g. plant_start_stop) determine their state.
1 parent 8104cd6 commit a560117

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

custom_components/sigen/switch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class SigenergySwitchEntityDescription(SwitchEntityDescription):
102102
name="AC Charger Power",
103103
icon="mdi:ev-station",
104104
# identifier here will be ac_charger_name
105-
is_on_fn=lambda data, identifier: data.get("ac_chargers", {}).get(identifier, {}).get("ac_charger_system_state") not in ("Initializing", "Fault", "Error", "Not Connected"),
105+
is_on_fn=lambda data, identifier: data.get("ac_chargers", {}).get(identifier, {}).get("ac_charger_system_state") in (3,4,5),
106106
turn_on_fn=lambda coordinator, identifier: coordinator.async_write_parameter("ac_charger", identifier, "ac_charger_start_stop", 0),
107107
turn_off_fn=lambda coordinator, identifier: coordinator.async_write_parameter("ac_charger", identifier, "ac_charger_start_stop", 1),
108108
),

0 commit comments

Comments
 (0)