Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions zha/application/platforms/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def __init__(
)

super().__init__(endpoint=endpoint, device=device, **kwargs)
self._state: bool = self.is_on
self.recompute_capabilities()

def _is_supported(self) -> bool:
Expand Down Expand Up @@ -145,7 +144,7 @@ def info_object(self) -> BinarySensorEntityInfo:
@property
def is_on(self) -> bool:
"""Return True if the switch is on based on the state machine."""
self._state = raw_state = self._cluster.get(self._attribute_name)
raw_state = self._cluster.get(self._attribute_name)
Comment on lines 145 to +147

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's unrelated to this PR but a good thing to fix.

if raw_state is None:
return False
if self._attribute_converter:
Expand All @@ -162,7 +161,6 @@ def handle_attribute_updated(
"""Handle attribute updates from the cluster."""
if self._attribute_name is None or self._attribute_name != event.attribute_name:
return
self._state = bool(event.value)
self.maybe_emit_state_changed_event()

async def async_update(self) -> None:
Expand All @@ -177,7 +175,6 @@ async def async_update(self) -> None:
)
attr_value = result.get(attribute)
if attr_value is not None:
self._state = attr_value
self.maybe_emit_state_changed_event()

@staticmethod
Expand Down
Loading