-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
AC Partner V3: Add socket support (Closes #337) #415
Conversation
miio/airconditioningcompanion.py
Outdated
return self.send("toggle_plug", ["on"]) | ||
|
||
@command( | ||
default_output = format_output("Powering socket off"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected spaces around keyword / parameter equals
miio/airconditioningcompanion.py
Outdated
@@ -284,6 +284,20 @@ def off(self): | |||
"""Turn the air condition off by infrared.""" | |||
return self.send("set_power", ["off"]) | |||
|
|||
@command( | |||
default_output = format_output("Powering socket on"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected spaces around keyword / parameter equals
def test_status(self): | ||
self.device._reset_state() | ||
|
||
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']))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (188 > 100 characters)
@@ -126,7 +128,7 @@ def test_off(self): | |||
def test_status(self): | |||
self.device._reset_state() | |||
|
|||
assert repr(self.state()) == repr(AirConditioningCompanionStatus(self.device.start_state)) | |||
assert repr(self.state()) == repr(AirConditioningCompanionStatus(dict(model_and_state=self.device.start_state))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (120 > 100 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a couple of nits. Feel free to merge as you wish!
miio/airconditioningcompanion.py
Outdated
@@ -208,7 +227,7 @@ def fan_speed(self) -> Optional[FanSpeed]: | |||
def mode(self) -> Optional[OperationMode]: | |||
"""Current operation mode.""" | |||
try: | |||
mode = int(self.data[1][3:4]) | |||
mode = int(self.data['model_and_state'][1][3:4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering all of these access the same structure, would it make sense to have a variable for it? Like self.state = self.data['model_and_state'][1]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
if model in MODELS_SUPPORTED: | ||
self.model = model | ||
else: | ||
self.model = MODEL_ACPARTNER_V2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This defaults to v2 if an unknown model is given? Maybe add a warning logging for that case.
No description provided.