-
-
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 smart wifi socket added #29
Changes from 2 commits
311537d
cea4e70
e243faa
bea60f6
8c34d51
e331b9d
c8777c6
7b0829b
df9f45d
18f3c7e
401dee4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from .device import Device | ||
|
||
PROPERTY_POWER = 'power' | ||
PROPERTY_TEMPERATURE = 'temperature' | ||
PROPERTY_CURRENT = 'current' | ||
|
||
|
||
class Plug(Device): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expected 2 blank lines, found 1 |
||
"""Main class representing the smart wifi socket / plug.""" | ||
|
||
def __init__(self, ip: str, token: str, start_id: int = 0, debug: int = 0) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (87 > 79 characters) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to fix this. ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, I think hound should complain first after 100 characters.. |
||
super().__init__(ip, token, start_id, debug) | ||
self.manual_seqnum = -1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the |
||
|
||
def start(self): | ||
"""Power on.""" | ||
return self.send("set_power", ["on"]) | ||
|
||
def stop(self): | ||
"""Power off.""" | ||
return self.send("set_power", ["off"]) | ||
|
||
def status(self): | ||
"""Retrieve properties.""" | ||
status = self.send( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multiple spaces after operator |
||
"get_prop", | ||
[ PROPERTY_POWER, PROPERTY_TEMPERATURE, PROPERTY_CURRENT ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace after '[' |
||
) | ||
return { | ||
PROPERTY_POWER: status[0], | ||
PROPERTY_TEMPERATURE: status[1], | ||
PROPERTY_CURRENT: status[2] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of data is returned by these? Would it make sense to wrap it inside a class like PlugStatus? |
||
|
||
def raw_command(self, cmd, params): | ||
"""Send a raw command to the device.""" | ||
return self.send(cmd, params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
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