From 3f132b2447056cd685936e51afee64e59ec3c526 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Tue, 5 Jun 2018 07:56:54 +0200 Subject: [PATCH] Fan: Fix a KeyError if button_pressed isn't available (#333) --- miio/fan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miio/fan.py b/miio/fan.py index 76163b01d..3b18a03d6 100644 --- a/miio/fan.py +++ b/miio/fan.py @@ -175,7 +175,7 @@ def use_time(self) -> int: @property def button_pressed(self) -> Optional[str]: """Last pressed button.""" - if self.data["button_pressed"] is not None: + if "button_pressed" in self.data and self.data["button_pressed"] is not None: return self.data["button_pressed"] return None