Device support for the xiaomi power strip added.#32
Device support for the xiaomi power strip added.#32rytilahti merged 8 commits intorytilahti:masterfrom
Conversation
|
|
||
| class StripStatus: | ||
| """Container for status reports from the strip.""" | ||
| def __init__(self, data: Dict[str, Any]) -> None: |
There was a problem hiding this comment.
undefined name 'Dict'
undefined name 'Any'
| return StripStatus(dict(zip(properties, values))) | ||
|
|
||
| def set_power_mode(self, mode: str): | ||
| """Set mode.""" |
There was a problem hiding this comment.
What kind of modes are accepted?
There was a problem hiding this comment.
"green" (aka eco) and "normal".
There was a problem hiding this comment.
Ok. Would it be worth expose this as an enum too?
There was a problem hiding this comment.
Could you provide an example? I'm confused.
There was a problem hiding this comment.
For example something like this:
import enum
class PowerMode(enum.Enum):
Eco = "green"
Normal = "normal"
and calling set_power_mode(PowerMode.Eco)
There was a problem hiding this comment.
Got it! This is nice. I will update the PRs asap.
There was a problem hiding this comment.
Btw, you can then simply use mode.value to get the value on the right hand side insie set_mode(), and other way around when reading it, PowerMode('green') will give you back the PowerMode.Eco :-)
|
|
||
| def status(self): | ||
| """Retrieve properties.""" | ||
| properties = ['power', 'temperature', 'current', 'mode'] |
There was a problem hiding this comment.
Do you have an example response? It would be nice to be added either here or into the Status class.
There was a problem hiding this comment.
Great! (I saw this was added, but the "todo" is still open.
PowerMode class introduced.
| return self.data["current"] | ||
|
|
||
| @property | ||
| def mode(self) -> PowerMode: |
| ) | ||
| return StripStatus(dict(zip(properties, values))) | ||
|
|
||
| def set_power_mode(self, mode: PowerMode): |
There was a problem hiding this comment.
I don't understand the complain. :-(
There was a problem hiding this comment.
The PowerMode is being used before it has been defined (see my comment in another PR :))
| from typing import Any, Dict | ||
| import enum | ||
|
|
||
| class Strip(Device): |
mirobo/strip.py
Outdated
| """Container for status reports from the strip.""" | ||
|
|
||
| def __init__(self, data: Dict[str, Any]) -> None: | ||
| # {'power': 'on', 'temperature': 48.11, 'current': 0.06, 'mode': 'green'} |
There was a problem hiding this comment.
line too long (81 > 79 characters)
|
Looks good, let's merge it! |
|
Known models: 'qmi.powerstrip.v1', 'zimi.powerstrip.v2' |
No description provided.