mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 04:41:30 -04:00
Use UnitOfRatio.PERCENTAGE in igloohome sensor (#187800)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
397d20f0b0
commit
238d57dbc2
@@ -7,6 +7,7 @@ from aiohttp import ClientError
|
||||
from igloohome_api import Api as IgloohomeApi, ApiException, GetDeviceInfoResponse
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.const import UnitOfRatio
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
@@ -42,7 +43,7 @@ async def async_setup_entry(
|
||||
class IgloohomeBatteryEntity(IgloohomeBaseEntity, SensorEntity):
|
||||
"""Implementation of a device that has a battery."""
|
||||
|
||||
_attr_native_unit_of_measurement = "%"
|
||||
_attr_native_unit_of_measurement = UnitOfRatio.PERCENTAGE
|
||||
_attr_device_class = SensorDeviceClass.BATTERY
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'battery_OE1X123cbb11',
|
||||
'unit_of_measurement': '%',
|
||||
'unit_of_measurement': <UnitOfRatio.PERCENTAGE: '%'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.front_door_battery-state]
|
||||
@@ -41,7 +41,7 @@
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'battery',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Front Door Battery',
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: '%',
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfRatio.PERCENTAGE: '%'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.front_door_battery',
|
||||
|
||||
Reference in New Issue
Block a user