From 0d888947ba1c4a51d5e871edb535cd194d5ec366 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 5 Jan 2019 12:27:46 +0100 Subject: [PATCH 1/3] Expose power_socket property at AirConditioningCompanionStatus.__repr__() --- miio/airconditioningcompanion.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index 04c49d23e..a751bd954 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -238,6 +238,7 @@ def mode(self) -> Optional[OperationMode]: def __repr__(self) -> str: s = " str: "fan_speed=%s, " \ "mode=%s>" % \ (self.power, + self.power_socket, self.load_power, self.air_condition_model.hex(), self.model_format, From c48af09e1e0607d938c564978b8b36ed88eeae45 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 5 Jan 2019 12:55:27 +0100 Subject: [PATCH 2/3] Extract plug_state properly --- miio/airconditioningcompanion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index a751bd954..a1c98868e 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -483,4 +483,4 @@ def status(self) -> AirConditioningCompanionStatus: status = self.send("get_model_and_state") power_socket = self.send("get_device_prop", ["lumi.0", "plug_state"]) return AirConditioningCompanionStatus(dict( - model_and_state=status, power_socket=power_socket)) + model_and_state=status, power_socket=power_socket[0])) From 8b2aa2e7b4f278e3324991190071c00853c2e9a1 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 5 Jan 2019 12:59:49 +0100 Subject: [PATCH 3/3] Fix tests --- miio/tests/test_airconditioningcompanion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miio/tests/test_airconditioningcompanion.py b/miio/tests/test_airconditioningcompanion.py index c4f184655..d58d1e311 100644 --- a/miio/tests/test_airconditioningcompanion.py +++ b/miio/tests/test_airconditioningcompanion.py @@ -211,7 +211,7 @@ def test_send_configuration(self): class DummyAirConditioningCompanionV3(AirConditioningCompanionV3): def __init__(self, *args, **kwargs): self.state = ['010507950000257301', '011001160100002573', '807'] - self.device_prop = {'lumi.0': {'plug_state': 'on'}} + self.device_prop = {'lumi.0': {'plug_state': ['on']}} self.model = MODEL_ACPARTNER_V3 self.last_ir_played = None @@ -241,7 +241,7 @@ def _get_device_prop(self, props): def _toggle_plug(self, props): """Toggle the lumi.0 plug state""" - self.device_prop['lumi.0']['plug_state'] = props.pop() + self.device_prop['lumi.0']['plug_state'] = [props.pop()] @pytest.fixture(scope="class") @@ -277,7 +277,7 @@ def test_status(self): assert repr(self.state()) == repr(AirConditioningCompanionStatus(dict( model_and_state=self.device.start_state, - power_socket=self.device.start_device_prop['lumi.0']['plug_state']) + power_socket=self.device.start_device_prop['lumi.0']['plug_state'][0]) )) assert self.is_on() is True