Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix object detection sensor going on/off in a loop when not available #625

Merged
merged 1 commit into from
Feb 16, 2023
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
17 changes: 12 additions & 5 deletions custom_components/reolink_dev/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,15 @@ async def async_added_to_hass(self) -> None:
async def handle_event(self, event):
"""Handle incoming event for motion detection and availability."""

new_availability = self._available

try:
new_availability = event.data["available"]
if new_availability != self._available:
self._available = new_availability
self.async_schedule_update_ha_state()
if not new_availability:
if new_availability != self._available:
self._available = new_availability
self.async_schedule_update_ha_state()
return
except KeyError:
pass

Expand Down Expand Up @@ -330,8 +334,11 @@ async def handle_event(self, event):
break

if not object_found:
self._available = False
self.async_schedule_update_ha_state()
new_availability = False

if new_availability != self._available:
self._available = new_availability
self.async_schedule_update_ha_state()



Expand Down