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
31 changes: 22 additions & 9 deletions homeassistant/components/binary_sensor/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ def __init__(self, node) -> None:
# pylint: disable=protected-access
if _is_val_unknown(self._node.status._val):
self._computed_state = None
self._status_was_unknown = True
else:
self._computed_state = bool(self._node.status._val)
self._status_was_unknown = False

@asyncio.coroutine
def async_added_to_hass(self) -> None:
Expand Down Expand Up @@ -156,9 +158,13 @@ def add_negative_node(self, child) -> None:
# pylint: disable=protected-access
if not _is_val_unknown(self._negative_node.status._val):
# If the negative node has a value, it means the negative node is
# in use for this device. Therefore, we cannot determine the state
# of the sensor until we receive our first ON event.
self._computed_state = None
# in use for this device. Next we need to check to see if the
# negative and positive nodes disagree on the state (both ON or
# both OFF).
if self._negative_node.status._val == self._node.status._val:
# The states disagree, therefore we cannot determine the state
# of the sensor until we receive our first ON event.
self._computed_state = None

def _negative_node_control_handler(self, event: object) -> None:
"""Handle an "On" control event from the "negative" node."""
Expand Down Expand Up @@ -189,14 +195,21 @@ def _positive_node_control_handler(self, event: object) -> None:
self.schedule_update_ha_state()
self._heartbeat()

# pylint: disable=unused-argument
def on_update(self, event: object) -> None:
"""Ignore primary node status updates.

We listen directly to the Control events on all nodes for this
device.
"""Primary node status updates.

We MOSTLY ignore these updates, as we listen directly to the Control
events on all nodes for this device. However, there is one edge case:
If a leak sensor is unknown, due to a recent reboot of the ISY, the
status will get updated to dry upon the first heartbeat. This status
update is the only way that a leak sensor's status changes without
an accompanying Control event, so we need to watch for it.
"""
pass
if self._status_was_unknown and self._computed_state is None:
self._computed_state = bool(int(self._node.status))
self._status_was_unknown = False
self.schedule_update_ha_state()
self._heartbeat()

@property
def value(self) -> object:
Expand Down