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

Adds energy monitoring functionality available in the HS110 plugs #2

Merged
merged 8 commits into from
Oct 19, 2016
Merged

Adds energy monitoring functionality available in the HS110 plugs #2

merged 8 commits into from
Oct 19, 2016

Conversation

kirichkov
Copy link
Collaborator

Besides retrieving data I've also refactored the code for setting state to use the turn_on() and turn_off() methods.

data = codecs.decode(on_str, 'hex_codec')
s.send(data)
s.close()
self.turn_on()
Copy link
Collaborator

@mweinelt mweinelt Oct 18, 2016

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()
Copy link
Collaborator

Choose a reason for hiding this comment

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

underindented

@GadgetReactor
Copy link
Owner

Apologies, was overseas. Thanks for the added changes! Will review and merge it in a couple of days.

@kirichkov
Copy link
Collaborator Author

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

Copy link
Owner

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

Copy link
Owner

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

Copy link
Owner

@GadgetReactor GadgetReactor left a 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"]

@kirichkov
Copy link
Collaborator Author

Thanks for reviewing and spotting the issue with current_consumption()

I've refactored the state property method and completely removed the hs100_status() method as you suggested.

Copy link
Owner

@GadgetReactor GadgetReactor left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks.

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.

3 participants