mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Add Battery sensor regardless if the battery_percent_remaining attribute is supported or not (#59264)
This commit is contained in:
parent
b75476e844
commit
cc82976d15
@ -226,6 +226,22 @@ class Battery(Sensor):
|
|||||||
_unit = PERCENTAGE
|
_unit = PERCENTAGE
|
||||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create_entity(
|
||||||
|
cls,
|
||||||
|
unique_id: str,
|
||||||
|
zha_device: ZhaDeviceType,
|
||||||
|
channels: list[ChannelType],
|
||||||
|
**kwargs,
|
||||||
|
) -> ZhaEntity | None:
|
||||||
|
"""Entity Factory.
|
||||||
|
|
||||||
|
Unlike any other entity, PowerConfiguration cluster may not support
|
||||||
|
battery_percent_remaining attribute, but zha-device-handlers takes care of it
|
||||||
|
so create the entity regardless
|
||||||
|
"""
|
||||||
|
return cls(unique_id, zha_device, channels, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def formatter(value: int) -> int:
|
def formatter(value: int) -> int:
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user