Skip to content

Commit 9dbbecd

Browse files
Remove battery device_class from Fox SOH sensor to prevent HA low-battery false alerts (#4490)
* Initial plan * Fix Fox SOH sensor to avoid low-battery device class Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
1 parent 2adaa76 commit 9dbbecd

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

apps/predbat/fox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ async def publish_data(self):
17921792
self.dashboard_item(
17931793
entity_name_sensor + "_" + sn.lower() + "_battery_soh",
17941794
state=soh_fraction,
1795-
attributes={"friendly_name": f"Fox {sn} Battery State of Health", "unit_of_measurement": "*", "device_class": "battery", "state_class": "measurement", "icon": "mdi:battery-heart"},
1795+
attributes={"friendly_name": f"Fox {sn} Battery State of Health", "unit_of_measurement": "*", "state_class": "measurement", "icon": "mdi:battery-heart"},
17961796
app="fox",
17971797
)
17981798

apps/predbat/tests/test_fox_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5538,7 +5538,7 @@ def test_publish_data_battery_soh(my_predbat):
55385538
assert soh_entity in fox.dashboard_items, f"battery_soh entity not found in {list(fox.dashboard_items.keys())}"
55395539
assert fox.dashboard_items[soh_entity]["state"] == 0.95, f"Expected 0.95, got {fox.dashboard_items[soh_entity]['state']}"
55405540
assert fox.dashboard_items[soh_entity]["attributes"]["unit_of_measurement"] == "*"
5541-
assert fox.dashboard_items[soh_entity]["attributes"]["device_class"] == "battery"
5541+
assert "device_class" not in fox.dashboard_items[soh_entity]["attributes"]
55425542
assert fox.dashboard_items[soh_entity]["attributes"]["state_class"] == "measurement"
55435543
assert fox.dashboard_items[soh_entity]["attributes"]["icon"] == "mdi:battery-heart"
55445544

0 commit comments

Comments
 (0)