Skip to content

Commit

Permalink
wrap mode to avoid crashing on None, use __repr__ instead of __str__
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Nov 18, 2017
1 parent 243f14d commit 9d3fdcc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions miio/powerstrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<PowerStripStatus power=%s, temperature=%s, " \
"load_power=%s mode=%s>" % \
(self.power,
Expand Down

0 comments on commit 9d3fdcc

Please sign in to comment.