-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Device support for the xiaomi power strip added. #32
Conversation
mirobo/strip.py
Outdated
|
||
class StripStatus: | ||
"""Container for status reports from the strip.""" | ||
def __init__(self, data: Dict[str, Any]) -> None: |
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.
undefined name 'Dict'
undefined name 'Any'
mirobo/strip.py
Outdated
return StripStatus(dict(zip(properties, values))) | ||
|
||
def set_power_mode(self, mode: str): | ||
"""Set mode.""" |
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.
What kind of modes are accepted?
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.
"green" (aka eco) and "normal".
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.
Ok. Would it be worth expose this as an enum too?
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.
Could you provide an example? I'm confused.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! This is nice. I will update the PRs asap.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will care about.
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.
Great! (I saw this was added, but the "todo" is still open.
PowerMode class introduced.
return self.data["current"] | ||
|
||
@property | ||
def mode(self) -> PowerMode: |
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.
undefined name 'PowerMode'
) | ||
return StripStatus(dict(zip(properties, values))) | ||
|
||
def set_power_mode(self, mode: PowerMode): |
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.
undefined name 'PowerMode'
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.
I don't understand the complain. :-(
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 PowerMode is being used before it has been defined (see my comment in another PR :))
mirobo/strip.py
Outdated
from typing import Any, Dict | ||
import enum | ||
|
||
class Strip(Device): |
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.
expected 2 blank lines, found 1
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
Looks good, let's merge it! |
Known models: 'qmi.powerstrip.v1', 'zimi.powerstrip.v2' |
No description provided.