mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Address venstar review comments (#59151)
* Address venstar review comments * Apply review suggestions * Address review suggestions
This commit is contained in:
parent
c0801c1233
commit
6a0c1a78aa
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user