Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Air Conditioning Partner: Extract the return value of the plug_state request properly #448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
6 changes: 3 additions & 3 deletions miio/tests/test_airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down