Use UnitOfRatio.PERCENTAGE in igloohome sensor (#187800)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Joost Lekkerkerker
2026-10-21 11:46:33 +01:00
committed by GitHub
co-authored by Claude
parent 397d20f0b0
commit 238d57dbc2
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -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',