mirror of
https://github.com/home-assistant/core.git
synced 2025-08-11 08:35:15 +02:00
Default naming for sensors
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user