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
SP4 first commit #300
SP4 first commit #300
Conversation
Added support for SP4 type plugs. Tested with SP4L-EU type, seems to share alot with US and AU types, as EU plug was not present in IHC app but i could control my EU plug anyway. Added extra support functions check_power/set_power to comply with sp1,sp2,sp3 type controls. Also updated docs with some(small) info
Only tested on one device, but hopefully solves #299 |
Works for me although I had to add 'state = json.loads(payload[0x0c:0x0c+js_len].decode("utf-8"))', you see the decoding part there? 👍 |
@nihilus Cool! im guessing you use python2, i only tried it with python3. If you are using python 2, maybe i should add that to the PR for compability? |
I do use python 3.5 for the record. |
Hm. Now that you say that i think that i saw somewhere that after python 3.5, decode is implicit? So it's probably a good idea even for more complete python3 support. |
Amazing work, looking forward to this getting merged 🖒 |
Got this working with a Clas Ohlson 'WiFi Smart Plug'. Thumbs up for getting this merged. |
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.
Thanks for the contribution! I have a suggestion based on changes I made recently. From now on, error codes need to raise exceptions.
|
||
js = json.dumps(data).encode('utf8') | ||
packet = self._encode(2, js) | ||
response = self.send_packet(0x6a, packet) |
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.
Use this function to check for errors in the response:
check_error(response[0x22:0x24])
err = response[0x22] | (response[0x23] << 8) | ||
if err != 0: | ||
return None |
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 this.
I also think it is important to add the |
Ooh this is awesome. @skrutt will you be able to resolve the changes @felipediel requested? I have a few of these plugs as well and would love being able to integrate them with my (new) homeassistant setup :D Or would you prefer someone else pick it up if you don't have the time? |
Added support for SP4 type plugs. Tested with SP4L-EU type, seems to share alot with US and AU types, as EU plug was not present in IHC app but i could control my EU plug anyway.
Added extra support functions check_power/set_power to comply with sp1,sp2,sp3 type controls.
Also updated docs with some(small) info