From 6a0c1a78aa218a694aa7eea01b20a8095e613509 Mon Sep 17 00:00:00 2001 From: Marvin Wichmann Date: Fri, 5 Nov 2021 15:31:32 +0100 Subject: [PATCH] Address venstar review comments (#59151) * Address venstar review comments * Apply review suggestions * Address review suggestions --- homeassistant/components/venstar/__init__.py | 2 +- .../components/venstar/binary_sensor.py | 23 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/venstar/__init__.py b/homeassistant/components/venstar/__init__.py index 8c46df66a91..72e8b3e32d9 100644 --- a/homeassistant/components/venstar/__init__.py +++ b/homeassistant/components/venstar/__init__.py @@ -19,7 +19,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import _LOGGER, DOMAIN, VENSTAR_TIMEOUT -PLATFORMS = ["climate", "binary_sensor"] +PLATFORMS = ["binary_sensor", "climate"] async def async_setup_entry(hass, config): diff --git a/homeassistant/components/venstar/binary_sensor.py b/homeassistant/components/venstar/binary_sensor.py index d7b1a69c4cb..1d6c8f49bd8 100644 --- a/homeassistant/components/venstar/binary_sensor.py +++ b/homeassistant/components/venstar/binary_sensor.py @@ -14,12 +14,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities) -> None: if coordinator.client.alerts is None: return - sensors = [ + async_add_entities( VenstarBinarySensor(coordinator, config_entry, alert["name"]) for alert in coordinator.client.alerts - ] - - async_add_entities(sensors, True) + ) class VenstarBinarySensor(VenstarEntity, BinarySensorEntity): @@ -31,19 +29,8 @@ class VenstarBinarySensor(VenstarEntity, BinarySensorEntity): """Initialize the alert.""" super().__init__(coordinator, config) self.alert = alert - self._config = config - self._unique_id = f"{self._config.entry_id}_{self.alert.replace(' ', '_')}" - self._name = f"{self._client.name} {self.alert}" - - @property - def unique_id(self): - """Return the unique id.""" - return self._unique_id - - @property - def name(self): - """Return the name of the device.""" - return self._name + self._attr_unique_id = f"{config.entry_id}_{alert.replace(' ', '_')}" + self._attr_name = f"{self._client.name} {alert}" @property def is_on(self): @@ -51,3 +38,5 @@ class VenstarBinarySensor(VenstarEntity, BinarySensorEntity): for alert in self._client.alerts: if alert["name"] == self.alert: return alert["active"] + + return None