-
Notifications
You must be signed in to change notification settings - Fork 128
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
Adds energy monitoring functionality available in the HS110 plugs #2
Adds energy monitoring functionality available in the HS110 plugs #2
Conversation
Also adds turn_on() and turn_off() commands to supplement the state
Adds a shutdown to the socket used to send commands
data = codecs.decode(on_str, 'hex_codec') | ||
s.send(data) | ||
s.close() | ||
self.turn_on() |
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.
underindented, this project seems to use 4 spaces, please don't introduce mixed indentation :)
data = codecs.decode(off_str, 'hex_codec') | ||
s.send(data) | ||
s.close() | ||
self.turn_off() |
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.
underindented
Apologies, was overseas. Thanks for the added changes! Will review and merge it in a couple of days. |
Can you please test the code against HS100, because I have only the HS110 and I can't reliably test whether the energy monitoring functions reliably work with switches that don't support the energy monitoring. |
True: Success | ||
False: Failure or not supported by switch | ||
""" | ||
|
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 consistency, remove blankline
|
||
def current_consumption(self): | ||
"""Get the current power consumption in Watt.""" | ||
|
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.
Remove blankline, and also to check if smartplug supports function
if self.model == 100:
return False
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.
Sorry, not too familiar with the Github commenting / review process, but the new code works well.
Suggest to implement a function check to the current_consumption.
Lastly, the HS100_status is now redundant. I will remove it subsequently, or do you want to do this in this pull request? A modification to def_state(self) is required though -
sys_info = self.get_info()
response = sys_info["system"]["get_sysinfo"]["relay_state"]
Thanks for reviewing and spotting the issue with I've refactored the state property method and completely removed the hs100_status() method as you suggested. |
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.
Looks great! Thanks.
Besides retrieving data I've also refactored the code for setting state to use the turn_on() and turn_off() methods.