Skip to content

Remove battery device_class from Fox SOH sensor to prevent HA low-battery false alerts - #4490

Merged
springfall2008 merged 2 commits into
mainfrom
copilot/fix-fox-battery-soh-sensor-class
Aug 12, 2026
Merged

Remove battery device_class from Fox SOH sensor to prevent HA low-battery false alerts#4490
springfall2008 merged 2 commits into
mainfrom
copilot/fix-fox-battery-soh-sensor-class

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fox battery SOH is published as a health factor (0.0–1.0), but it was tagged with device_class: battery, which Home Assistant Maintenance interprets as remaining charge %. This caused persistent false low-battery warnings (e.g., 1.0 interpreted as 1%).

  • Sensor metadata correction

    • Updated Fox SOH sensor publishing to stop advertising device_class: battery.
    • Kept existing SOH semantics (state remains normalized fraction; unit_of_measurement: "*", state_class: "measurement", and icon unchanged).
  • Test expectation alignment

    • Updated the Fox API SOH publishing test to assert device_class is absent for the SOH entity.
self.dashboard_item(
    entity_name_sensor + "_" + sn.lower() + "_battery_soh",
    state=soh_fraction,
    attributes={
        "friendly_name": f"Fox {sn} Battery State of Health",
        "unit_of_measurement": "*",
        "state_class": "measurement",
        "icon": "mdi:battery-heart",
    },
    app="fox",
)

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Fox Battery SOH sensor device class to prevent low battery alert Remove battery device_class from Fox SOH sensor to prevent HA low-battery false alerts Aug 12, 2026
Copilot AI requested a review from springfall2008 August 12, 2026 06:43
@springfall2008
springfall2008 marked this pull request as ready for review August 12, 2026 07:18
Copilot AI lite review requested due to automatic review settings August 12, 2026 07:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the Home Assistant metadata for the Fox Battery State of Health (SOH) sensor so it is no longer misclassified as a “battery remaining charge” sensor, preventing false low-battery warnings in the HA Maintenance dashboard.

Changes:

  • Removed device_class: battery from the Fox _battery_soh sensor attributes while keeping the SOH value as a normalized fraction (0.0–1.0) and preserving existing unit/state_class/icon metadata.
  • Updated the Fox API publishing test to assert that device_class is not present on the SOH sensor.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/predbat/fox.py Stops publishing device_class: battery for the Fox battery SOH sensor to avoid HA interpreting SOH as remaining charge %.
apps/predbat/tests/test_fox_api.py Aligns test expectations to require device_class be absent for the SOH entity attributes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@springfall2008
springfall2008 merged commit 9dbbecd into main Aug 12, 2026
3 checks passed
@springfall2008
springfall2008 deleted the copilot/fix-fox-battery-soh-sensor-class branch August 12, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fox Battery SOH sensor incorrectly uses device_class: battery, causing low battery alert on Home Assistant Maintenance dashboard

3 participants