From dc1534c6d148d9a387f4b882980b864a81b4ffc7 Mon Sep 17 00:00:00 2001 From: Greg Laabs Date: Mon, 24 Sep 2018 02:43:00 -0700 Subject: [PATCH] Fix some unhandled exceptions due to missing null checks (#16812) Fixed a couple cases that would produce errors when the ISY node status was None or `-inf`. --- homeassistant/components/cover/isy994.py | 2 ++ homeassistant/components/light/isy994.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/cover/isy994.py b/homeassistant/components/cover/isy994.py index 428c1f326e4..4ead61e6b7a 100644 --- a/homeassistant/components/cover/isy994.py +++ b/homeassistant/components/cover/isy994.py @@ -44,6 +44,8 @@ class ISYCoverDevice(ISYDevice, CoverDevice): @property def current_cover_position(self) -> int: """Return the current cover position.""" + if self.is_unknown() or self.value is None: + return None return sorted((0, self.value, 100))[1] @property diff --git a/homeassistant/components/light/isy994.py b/homeassistant/components/light/isy994.py index 06507eaeca6..4349bfa1467 100644 --- a/homeassistant/components/light/isy994.py +++ b/homeassistant/components/light/isy994.py @@ -31,7 +31,7 @@ class ISYLightDevice(ISYDevice, Light): @property def is_on(self) -> bool: """Get whether the ISY994 light is on.""" - return self.value > 0 + return self.value != 0 @property def brightness(self) -> float: