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
Prev Previous commit
Next Next commit
Refactors state() to use turn_on() and turn_off()
  • Loading branch information
kirichkov committed Oct 13, 2016
commit 77d524ecf2150dfef35e38229f3123a5b007d4e1
22 changes: 2 additions & 20 deletions pyHS100/pyHS100.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,10 @@ def state(self, value):
:param value: Future state (either ON or OFF)
"""
if value.upper() == 'ON':
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ip, self.port))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ip, self.port))
on_str = ('0000002ad0f281f88bff9af7d5'
'ef94b6c5a0d48bf99cf091e8b7'
'c4b0d1a5c0e2d8a381f286e793'
'f6d4eedfa2dfa2')
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 :)


elif value.upper() == 'OFF':
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ip, self.port))
off_str = ('0000002ad0f281f88bff9af7d5'
'ef94b6c5a0d48bf99cf091e8b7'
'c4b0d1a5c0e2d8a381f286e793'
'f6d4eedea3dea3')
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


else:
raise TypeError("State %s is not valid." % str(value))
Expand Down