From 9d3fdcccc3be2c60fab2ef3b3f168abb53bd6cdd Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Sat, 18 Nov 2017 18:14:13 +0100 Subject: [PATCH] wrap mode to avoid crashing on None, use __repr__ instead of __str__ --- miio/powerstrip.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/miio/powerstrip.py b/miio/powerstrip.py index 6672c3a47..5ea707a4a 100644 --- a/miio/powerstrip.py +++ b/miio/powerstrip.py @@ -43,10 +43,12 @@ def load_power(self) -> Optional[float]: return None @property - def mode(self) -> PowerMode: - return PowerMode(self.data["mode"]) + def mode(self) -> Optional[PowerMode]: + if self.data["mode"] is not None: + return PowerMode(self.data["mode"]) + return None - def __str__(self) -> str: + def __repr__(self) -> str: s = "" % \ (self.power,