handle none power raw (#250)

This commit is contained in:
Daniel Høyer Iversen 2019-06-10 09:12:50 +02:00 committed by GitHub
parent c94838f561
commit 9ec2da834b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -357,6 +357,8 @@ class mp1(device):
def check_power(self): def check_power(self):
"""Returns the power state of the smart power strip.""" """Returns the power state of the smart power strip."""
state = self.check_power_raw() state = self.check_power_raw()
if state is None:
return {'s1': None, 's2': None, 's3': None, 's4': None}
data = {} data = {}
data['s1'] = bool(state & 0x01) data['s1'] = bool(state & 0x01)
data['s2'] = bool(state & 0x02) data['s2'] = bool(state & 0x02)