Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert ISY994 dusk/dawn sensors to match expected state #92035

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions homeassistant/components/isy994/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,18 @@ def is_on(self) -> bool | None:
Insteon leak sensors set their primary node to On when the state is
DRY, not WET, so we invert the binary state if the user indicates
that it is a moisture sensor.

Dusk/Dawn sensors set their node to On when DUSK, not light detected,
so this is inverted as well.
"""
if self._computed_state is None:
# Do this first so we don't invert None on moisture sensors
# Do this first so we don't invert None on moisture or light sensors
return None

if self.device_class == BinarySensorDeviceClass.MOISTURE:
if self.device_class in (
BinarySensorDeviceClass.LIGHT,
BinarySensorDeviceClass.MOISTURE,
):
return not self._computed_state

return self._computed_state
Expand Down