Default naming for sensors

This commit is contained in:
Mark Hannon
2025-05-13 21:31:13 +00:00
parent eaf19b63c5
commit a6059ad0c9
2 changed files with 6 additions and 3 deletions

View File

@@ -21,7 +21,9 @@ class ZimiEntity(Entity):
_attr_should_poll = False _attr_should_poll = False
_attr_has_entity_name = True _attr_has_entity_name = True
def __init__(self, device: ControlPointDevice, api: ControlPoint) -> None: def __init__(
self, device: ControlPointDevice, api: ControlPoint, use_device_name=True
) -> None:
"""Initialize an HA Entity which is a ZimiDevice.""" """Initialize an HA Entity which is a ZimiDevice."""
self._device = device self._device = device
@@ -36,6 +38,7 @@ class ZimiEntity(Entity):
suggested_area=device.room, suggested_area=device.room,
via_device=(DOMAIN, api.mac), via_device=(DOMAIN, api.mac),
) )
if use_device_name:
self._attr_name = device.name.strip() self._attr_name = device.name.strip()
self._attr_suggested_area = device.room self._attr_suggested_area = device.room

View File

@@ -94,7 +94,7 @@ class ZimiSensor(ZimiEntity, SensorEntity):
) -> None: ) -> None:
"""Initialize an ZimiSensor with specified type.""" """Initialize an ZimiSensor with specified type."""
super().__init__(device, api) super().__init__(device, api, use_device_name=False)
self.entity_description = description self.entity_description = description
self._attr_unique_id = device.identifier + "." + self.entity_description.key self._attr_unique_id = device.identifier + "." + self.entity_description.key