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
Xiaomi Air Conditioner Companion support #129
Conversation
miio/airconditioningcompanion.py
Outdated
import enum | ||
from typing import Any, Dict, Optional | ||
from collections import defaultdict | ||
from .device import Device, DeviceException |
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.
'.device.DeviceException' imported but unused
miio/airconditioningcompanion.py
Outdated
import logging | ||
import enum | ||
from typing import Any, Dict, Optional | ||
from collections import defaultdict |
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.
'collections.defaultdict' imported but unused
miio/airconditioningcompanion.py
Outdated
@@ -0,0 +1,102 @@ | |||
import logging | |||
import enum | |||
from typing import Any, Dict, Optional |
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.
'typing.Any' imported but unused
'typing.Dict' imported but unused
'typing.Optional' imported but unused
miio/airconditioningcompanion.py
Outdated
@@ -0,0 +1,102 @@ | |||
import logging | |||
import enum |
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.
'enum' imported but unused
miio/airconditioningcompanion.py
Outdated
@@ -0,0 +1,102 @@ | |||
import logging |
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.
'logging' imported but unused
@rytilahti Do you like to take a look into the unit test? The response format of the AC companion is unusual, so the device dummy implementation isn't sufficient. |
There's a WIP PR on homeassistant for this, which contains additional features if I'm not mistaken: home-assistant/core#10761 . @syssi do you think it'd make sense to merge this now, and do incremental changes assuming the authors of that PR are interested doing that? |
miio/airconditioningcompanion.py
Outdated
|
||
def learn(self): | ||
"""Learn an infrared command.""" | ||
return self.send("start_ir_learn", [30]) |
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.
The magic 30 should be extracted into a constant and/or documented some other way.
# Device model: lumi.acpartner.v2 | ||
# | ||
# Response of "get_model_and_state": | ||
# ['010500978022222102', '010201190280222221', '2'] |
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.
It would be nice to have some sort of description for specific byte indexes (and include a short, informal description of the protocol if possible) already here for readability.
@syssi considering that the protocol is that much different, it may make sense to avoid using the dummydevice and make the tests specific for this device? Although if it works like it is currently, that's fine too :-) |
@rytilahti I'm aware of home-assistant/core#10761 and we are in contact already cp. #76 |
from unittest import TestCase | ||
from miio import AirConditioningCompanion | ||
from miio.airconditioningcompanion import OperationMode, FanSpeed | ||
from .dummies import DummyDevice |
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.
'.dummies.DummyDevice' imported but unused
@rytilahti Could you check the sendcmd method of home-assistant/core#10761? There is a proper state needed to assemble a full featured command. Do you think the method can be migrated to python-miio? Where should be maintained the state? |
I would be happy about an early merge. |
Yes, the part definitely should be merged (after cleaning it up!). I'm unsure what type of state maintaining is required here, if it's just the state to do a new request, I think that detail can be hidden / a cached state message can be used? For now I think we can merge this. |
No description provided.