Skip to content

Commit

Permalink
Improve naming of binary sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat931 committed Mar 17, 2024
1 parent 9de0d90 commit 788ac1e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions custom_components/digitalstrom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,20 @@ def set_type(self, sensor_type: int) -> None:
self.entity_description = BINARY_SENSORS_MAP.get(
sensor_type, BINARY_SENSORS_MAP[-1]
)
self._attr_name = self.entity_description.name
self._attr_name = f"{self.device.name} {self.entity_description.name}"
self._attr_device_class = self.entity_description.device_class
self._attr_entity_category = self.entity_description.entity_category
self._attr_has_entity_name = True
self._attr_has_entity_name = False
if self.entity_description.key == "unknown":
self._attr_name += f" (type {sensor_type})"
self._attr_entity_registry_enabled_default = True
if self.entity_description.key == "0":
self._attr_name = self.device.name
self._attr_has_entity_name = False
if (
(self.index == 0)
and (self.device.button is not None)
and (not self.device.button_used)
):
self._attr_entity_registry_enabled_default = False
if (
(self.entity_description.key == "0")
and (self.index == 0)
and (self.device.button is not None)
and (not self.device.button_used)
):
self._attr_entity_registry_enabled_default = False

async def async_added_to_hass(self) -> None:
self.update_callback(self.channel.last_value)
Expand Down

0 comments on commit 788ac1e

Please sign in to comment.