mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix Enphase dry contact binary sensor state updates (#98225)
Fix dry contact binary sensor state updates
This commit is contained in:
parent
86f94662eb
commit
b653d7f683
@ -212,15 +212,15 @@ class EnvoyRelayBinarySensorEntity(EnvoyBaseBinarySensorEntity):
|
||||
self,
|
||||
coordinator: EnphaseUpdateCoordinator,
|
||||
description: BinarySensorEntityDescription,
|
||||
relay: str,
|
||||
relay_id: str,
|
||||
) -> None:
|
||||
"""Init the Enpower base entity."""
|
||||
super().__init__(coordinator, description)
|
||||
enpower = self.data.enpower
|
||||
assert enpower is not None
|
||||
self.relay = self.data.dry_contact_status[relay]
|
||||
self.relay_id = relay_id
|
||||
self._serial_number = enpower.serial_number
|
||||
self._attr_unique_id = f"{self._serial_number}_relay_{self.relay.id}"
|
||||
self._attr_unique_id = f"{self._serial_number}_relay_{relay_id}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._serial_number)},
|
||||
manufacturer="Enphase",
|
||||
@ -229,11 +229,10 @@ class EnvoyRelayBinarySensorEntity(EnvoyBaseBinarySensorEntity):
|
||||
sw_version=str(enpower.firmware_version),
|
||||
via_device=(DOMAIN, self.envoy_serial_num),
|
||||
)
|
||||
self._attr_name = (
|
||||
f"{self.data.dry_contact_settings[self.relay.id].load_name} Relay"
|
||||
)
|
||||
self._attr_name = f"{self.data.dry_contact_settings[relay_id].load_name} Relay"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return the state of the Enpower binary_sensor."""
|
||||
return self.relay.status == DryContactStatus.CLOSED
|
||||
relay = self.data.dry_contact_status[self.relay_id]
|
||||
return relay.status == DryContactStatus.CLOSED
|
||||
|
Loading…
x
Reference in New Issue
Block a user