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

SP4 first commit #300

Closed
wants to merge 1 commit into from
Closed

SP4 first commit #300

wants to merge 1 commit into from

Conversation

skrutt
Copy link

@skrutt skrutt commented Nov 19, 2019

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

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
@skrutt skrutt mentioned this pull request Nov 19, 2019
@skrutt
Copy link
Author

skrutt commented Nov 19, 2019

Only tested on one device, but hopefully solves #299

@nihilus
Copy link

nihilus commented Nov 19, 2019

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? 👍

@skrutt
Copy link
Author

skrutt commented Nov 19, 2019

@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?

@nihilus
Copy link

nihilus commented Nov 21, 2019

I do use python 3.5 for the record.

@skrutt
Copy link
Author

skrutt commented Dec 3, 2019

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.

@andwaal
Copy link

andwaal commented Dec 8, 2019

Amazing work, looking forward to this getting merged 🖒

@ristohelkio
Copy link

Got this working with a Clas Ohlson 'WiFi Smart Plug'. Thumbs up for getting this merged.

Copy link
Collaborator

@felipediel felipediel left a 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)
Copy link
Collaborator

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])

Comment on lines +363 to +365
err = response[0x22] | (response[0x23] << 8)
if err != 0:
return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this.

@felipediel
Copy link
Collaborator

I also think it is important to add the .decode("utf-8") mentioned above, so as not to break Python 2 support.

@yusijs
Copy link

yusijs commented Jun 6, 2020

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?

@Tamarinen
Copy link
Contributor

As I have one of those switches, I've taken the liberty of porting @skrutt 's code to the new structure in #414 . I believe I've incorporated all changes suggested here in that.

@Tamarinen Tamarinen mentioned this pull request Sep 22, 2020
@felipediel
Copy link
Collaborator

We resolved conflicts and merged here. Thank you very much @skrutt!

@felipediel felipediel closed this Jan 11, 2021
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.

None yet

7 participants