mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Change devolo Home Control entity naming (#38275)
* adding suffix after the entity name just in case the device class is not known * remove if else
This commit is contained in:
parent
b226a7183f
commit
569caf9e40
@ -50,10 +50,21 @@ class DevoloBinaryDeviceEntity(DevoloDeviceEntity, BinarySensorEntity):
|
||||
|
||||
def __init__(self, homecontrol, device_instance, element_uid):
|
||||
"""Initialize a devolo binary sensor."""
|
||||
if device_instance.binary_sensor_property.get(element_uid).sub_type != "":
|
||||
name = f"{device_instance.itemName} {device_instance.binary_sensor_property.get(element_uid).sub_type}"
|
||||
else:
|
||||
name = f"{device_instance.itemName} {device_instance.binary_sensor_property.get(element_uid).sensor_type}"
|
||||
self._binary_sensor_property = device_instance.binary_sensor_property.get(
|
||||
element_uid
|
||||
)
|
||||
|
||||
self._device_class = DEVICE_CLASS_MAPPING.get(
|
||||
self._binary_sensor_property.sub_type
|
||||
or self._binary_sensor_property.sensor_type
|
||||
)
|
||||
name = device_instance.itemName
|
||||
|
||||
if self._device_class is None:
|
||||
if device_instance.binary_sensor_property.get(element_uid).sub_type != "":
|
||||
name += f" {device_instance.binary_sensor_property.get(element_uid).sub_type}"
|
||||
else:
|
||||
name += f" {device_instance.binary_sensor_property.get(element_uid).sensor_type}"
|
||||
|
||||
super().__init__(
|
||||
homecontrol=homecontrol,
|
||||
@ -63,15 +74,6 @@ class DevoloBinaryDeviceEntity(DevoloDeviceEntity, BinarySensorEntity):
|
||||
sync=self._sync,
|
||||
)
|
||||
|
||||
self._binary_sensor_property = self._device_instance.binary_sensor_property.get(
|
||||
self._unique_id
|
||||
)
|
||||
|
||||
self._device_class = DEVICE_CLASS_MAPPING.get(
|
||||
self._binary_sensor_property.sub_type
|
||||
or self._binary_sensor_property.sensor_type
|
||||
)
|
||||
|
||||
self._state = self._binary_sensor_property.state
|
||||
|
||||
self._subscriber = None
|
||||
|
@ -53,13 +53,19 @@ class DevoloMultiLevelDeviceEntity(DevoloDeviceEntity):
|
||||
self._device_class = DEVICE_CLASS_MAPPING.get(
|
||||
self._multi_level_sensor_property.sensor_type
|
||||
)
|
||||
|
||||
name = device_instance.itemName
|
||||
|
||||
if self._device_class is None:
|
||||
name += f" {self._multi_level_sensor_property.sensor_type}"
|
||||
|
||||
self._unit = self._multi_level_sensor_property.unit
|
||||
|
||||
super().__init__(
|
||||
homecontrol=homecontrol,
|
||||
device_instance=device_instance,
|
||||
element_uid=element_uid,
|
||||
name=f"{device_instance.itemName} {self._multi_level_sensor_property.sensor_type}",
|
||||
name=name,
|
||||
sync=self._sync,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user