mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Update ios.py (#9041)
Use battery icon util for charging condition also
This commit is contained in:
parent
bf66019c66
commit
84025e46ff
@ -84,22 +84,21 @@ class IOSSensor(Entity):
|
|||||||
device_battery = self._device[ios.ATTR_BATTERY]
|
device_battery = self._device[ios.ATTR_BATTERY]
|
||||||
battery_state = device_battery[ios.ATTR_BATTERY_STATE]
|
battery_state = device_battery[ios.ATTR_BATTERY_STATE]
|
||||||
battery_level = device_battery[ios.ATTR_BATTERY_LEVEL]
|
battery_level = device_battery[ios.ATTR_BATTERY_LEVEL]
|
||||||
|
charging = True
|
||||||
|
icon_state = DEFAULT_ICON_STATE
|
||||||
if (battery_state == ios.ATTR_BATTERY_STATE_FULL or
|
if (battery_state == ios.ATTR_BATTERY_STATE_FULL or
|
||||||
battery_state == ios.ATTR_BATTERY_STATE_UNPLUGGED):
|
battery_state == ios.ATTR_BATTERY_STATE_UNPLUGGED):
|
||||||
icon_level = icon_for_battery_level(battery_level=battery_level,
|
charging = False
|
||||||
charging=False)
|
|
||||||
icon_state = "{}-off".format(DEFAULT_ICON_STATE)
|
icon_state = "{}-off".format(DEFAULT_ICON_STATE)
|
||||||
elif battery_state == ios.ATTR_BATTERY_STATE_CHARGING:
|
|
||||||
icon_level = "{}-charging".format(DEFAULT_ICON_LEVEL)
|
|
||||||
icon_state = DEFAULT_ICON_STATE
|
|
||||||
elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN:
|
elif battery_state == ios.ATTR_BATTERY_STATE_UNKNOWN:
|
||||||
icon_level = icon_for_battery_level(battery_level=None,
|
battery_level = None
|
||||||
charging=False)
|
charging = False
|
||||||
icon_state = "{}-unknown".format(DEFAULT_ICON_LEVEL)
|
icon_state = "{}-unknown".format(DEFAULT_ICON_LEVEL)
|
||||||
|
|
||||||
if self.type == "state":
|
if self.type == "state":
|
||||||
return icon_state
|
return icon_state
|
||||||
return icon_level
|
return icon_for_battery_level(battery_level=battery_level,
|
||||||
|
charging=charging)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest state of the sensor."""
|
"""Get the latest state of the sensor."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user