Skip to content

Fix: charge_limit and reserve dummy sensors incorrectly use device_class=battery#4271

Open
springfall2008 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-charge-limit-sensor
Open

Fix: charge_limit and reserve dummy sensors incorrectly use device_class=battery#4271
springfall2008 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-charge-limit-sensor

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Dummy entities created for non-GE inverters (FoxESS, etc.) used device_class="battery" for charge_limit and reserve, causing HA to treat charge targets as battery SoC — surfacing spurious "low battery" warnings in the Maintenance dashboard for normal targets like 10%.

Changes

  • inverter.pycreate_entity() call-sites: Remove device_class="battery" from charge_limit and reserve dummy entities; add appropriate icons (mdi:target, mdi:battery-lock)
  • inverter.pycreate_entity() signature: Add optional icon parameter so callers can set an icon without needing to manipulate attributes directly
# Before
self.create_entity("charge_limit", 100, device_class="battery", uom="%")
self.create_entity("reserve", self.reserve, device_class="battery", uom="%")

# After
self.create_entity("charge_limit", 100, device_class=None, uom="%", icon="mdi:target")
self.create_entity("reserve", self.reserve, device_class=None, uom="%", icon="mdi:battery-lock")

These entities are configuration targets, not battery state sensors — they should be generic percentage measurements with no device class.

… entities

The charge_limit and reserve entities created for non-GE inverters
(e.g. FoxESS) were incorrectly using device_class="battery", causing
Home Assistant to include them in the Maintenance dashboard and warn
about "low battery" when the charge target is set to a low percentage.

These are configuration target entities, not battery state sensors,
so they should not have device_class="battery". Changed to:
- charge_limit: device_class=None, icon="mdi:target"
- reserve: device_class=None, icon="mdi:battery-lock"

Also added icon parameter support to create_entity() to allow
meaningful icons for these entities.

Closes #4268
Copilot AI changed the title [WIP] Fix charge-limit target sensor exposure with battery device class Fix: charge_limit and reserve dummy sensors incorrectly use device_class=battery Jul 18, 2026
Copilot AI requested a review from springfall2008 July 18, 2026 11:28
@springfall2008
springfall2008 marked this pull request as ready for review July 18, 2026 14:01
Copilot AI review requested due to automatic review settings July 18, 2026 14:01

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 how Predbat creates dummy Home Assistant entities for non-GivEnergy inverters by ensuring configuration target sensors (reserve and charge limit) are not misclassified as battery state sensors, avoiding misleading “low battery” maintenance warnings.

Changes:

  • Removed device_class="battery" from dummy reserve and charge_limit sensors and added more appropriate icons.
  • Extended Inverter.create_entity() to accept an optional icon parameter and persist it into created entity attributes.

Comment thread apps/predbat/inverter.py
return {}

def create_entity(self, entity_name, value, uom=None, device_class="None"):
def create_entity(self, entity_name, value, uom=None, device_class="None", icon=None):
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.

Charge-limit target sensor is incorrectly exposed with battery device class

3 participants