Skip to content

Commit

Permalink
fix: battery icon not shown when below 10 percent
Browse files Browse the repository at this point in the history
  • Loading branch information
opsiorobinostlund committed Jul 25, 2022
1 parent 8ecddec commit dd7a8a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/ferroamp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_registry import async_get as async_get_entity_reg
from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.util import slugify

Expand Down Expand Up @@ -751,7 +752,7 @@ def update_state_from_events(self, events):
if self.state is not None and self.state != "unknown":
pct = int(float(self.state) / 10) * 10
if pct <= 90:
self._attr_icon = f"mdi:battery-{pct}"
self._attr_icon = icon_for_battery_level(battery_level=pct)
else:
self._attr_icon = "mdi:battery"
return res
Expand Down

0 comments on commit dd7a8a5

Please sign in to comment.