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

Device support for the xiaomi power strip added. #32

Merged
merged 8 commits into from Jul 25, 2017

Conversation

syssi
Copy link
Collaborator

@syssi syssi commented Jul 23, 2017

No description provided.

mirobo/strip.py Outdated

class StripStatus:
"""Container for status reports from the strip."""
def __init__(self, data: Dict[str, Any]) -> None:

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."""
Copy link
Owner

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?

Copy link
Collaborator Author

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".

Copy link
Owner

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?

Copy link
Collaborator Author

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.

Copy link
Owner

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)

Copy link
Collaborator Author

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.

Copy link
Owner

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']
Copy link
Owner

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will care about.

Copy link
Owner

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:

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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'PowerMode'

Copy link
Collaborator Author

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. :-(

Copy link
Owner

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):

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'}

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)

@rytilahti
Copy link
Owner

Looks good, let's merge it!

@rytilahti rytilahti merged commit a28fab5 into rytilahti:master Jul 25, 2017
@syssi
Copy link
Collaborator Author

syssi commented Aug 4, 2017

Known models: 'qmi.powerstrip.v1', 'zimi.powerstrip.v2'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants