From 9e1467402fa290f8da9782ba5ae3a093d0364eca Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 17 Mar 2018 11:08:17 +0100 Subject: [PATCH 1/3] LED setting fixed --- miio/airconditioningcompanion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index 69c499ab4..a141aba53 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -98,12 +98,12 @@ def air_condition_model(self) -> str: @property def power(self) -> str: """Current power state.""" - return 'on' if (self.data[1][2:3] == '1') else 'off' + return 'on' if (self.data[1][2:3] == Power.On.value) else 'off' @property def led(self) -> str: """Current LED state.""" - return 'on' if (self.data[1][8:9] == '1') else 'off' + return 'on' if (self.data[1][8:9] == Led.On.value) else 'off' @property def is_on(self) -> bool: @@ -121,7 +121,7 @@ def temperature(self) -> Optional[int]: @property def swing_mode(self) -> bool: """True if swing mode is enabled.""" - return self.data[1][5:6] == '0' + return self.data[1][5:6] == SwingMode.On.value @property def fan_speed(self) -> Optional[FanSpeed]: From 1061f8a0b40adab90196e921fd8a73a176b03b62 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 17 Mar 2018 14:01:31 +0100 Subject: [PATCH 2/3] Types fixed --- miio/airconditioningcompanion.py | 6 +++--- miio/tests/test_airconditioningcompanion.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index a141aba53..50c05b592 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -98,12 +98,12 @@ def air_condition_model(self) -> str: @property def power(self) -> str: """Current power state.""" - return 'on' if (self.data[1][2:3] == Power.On.value) else 'off' + return 'on' if (int(self.data[1][2:3]) == Power.On.value) else 'off' @property def led(self) -> str: """Current LED state.""" - return 'on' if (self.data[1][8:9] == Led.On.value) else 'off' + return 'on' if (int(self.data[1][8:9]) == Led.On.value) else 'off' @property def is_on(self) -> bool: @@ -121,7 +121,7 @@ def temperature(self) -> Optional[int]: @property def swing_mode(self) -> bool: """True if swing mode is enabled.""" - return self.data[1][5:6] == SwingMode.On.value + return int(self.data[1][5:6]) == SwingMode.On.value @property def fan_speed(self) -> Optional[FanSpeed]: diff --git a/miio/tests/test_airconditioningcompanion.py b/miio/tests/test_airconditioningcompanion.py index e56311dd9..1706f76c7 100644 --- a/miio/tests/test_airconditioningcompanion.py +++ b/miio/tests/test_airconditioningcompanion.py @@ -87,7 +87,7 @@ def test_status(self): assert self.state().swing_mode is False assert self.state().fan_speed == FanSpeed.Low assert self.state().mode == OperationMode.Auto - assert self.state().led == 'off' + assert self.state().led == 'on' def test_status_without_temperature(self): self.device._reset_state() From 061566d890a6ab393c313158b899f1c48a5c96d2 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 17 Mar 2018 16:52:32 +0100 Subject: [PATCH 3/3] State mixed up. --- miio/tests/test_airconditioningcompanion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miio/tests/test_airconditioningcompanion.py b/miio/tests/test_airconditioningcompanion.py index 1706f76c7..e56311dd9 100644 --- a/miio/tests/test_airconditioningcompanion.py +++ b/miio/tests/test_airconditioningcompanion.py @@ -87,7 +87,7 @@ def test_status(self): assert self.state().swing_mode is False assert self.state().fan_speed == FanSpeed.Low assert self.state().mode == OperationMode.Auto - assert self.state().led == 'on' + assert self.state().led == 'off' def test_status_without_temperature(self): self.device._reset_state()