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`.
This commit is contained in:
Greg Laabs authored and Paulus Schoutsen committed 2018-09-24 11:43:00 +02:00
1 parent 589554ad16
commit dc1534c6d1
2 files changed
+3 -1

No files matched your search

+2
View File
@@ -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
+1 -1
View File
@@ -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: