mirror of
https://github.com/home-assistant/core.git
synced 2026-09-04 18:15:04 -05:00
Switchbot Cloud: Fixed binary sensors didn't update automatically (#158434)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
co-authored by
Joost Lekkerkerker
parent
70786a1d90
commit
1d289c0083
@@ -147,16 +147,16 @@ class SwitchBotCloudBinarySensor(SwitchBotCloudEntity, BinarySensorEntity):
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{device.device_id}_{description.key}"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
def _set_attributes(self) -> None:
|
||||
"""Set attributes from coordinator data."""
|
||||
if not self.coordinator.data:
|
||||
return None
|
||||
return
|
||||
|
||||
if self.entity_description.value_fn:
|
||||
return self.entity_description.value_fn(self.coordinator.data)
|
||||
self._attr_is_on = self.entity_description.value_fn(self.coordinator.data)
|
||||
return
|
||||
|
||||
return (
|
||||
self._attr_is_on = (
|
||||
self.coordinator.data.get(self.entity_description.key)
|
||||
== self.entity_description.on_value
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user