lucien2k / sonoff-python

Make use of your sonoff smart switches without flashing them via the cloud APIs
MIT License
51 stars 32 forks source link

Unable to switch sockets - error 406 #27

Open marcinlubojanski opened 3 years ago

marcinlubojanski commented 3 years ago

Since yesterday I'm able to list devices but switching sockets end with error. If I print output of wsresponse I'm getting this: {"error":406,"sequence":"16043159535"}

Maybe it has something to do with the old appid and secret as mentioned on other issue ?

pawisoon commented 3 years ago

Im facing the same issue.

marcinlubojanski commented 3 years ago

I've found new appid and apikey here https://github.com/AlexxIT/SonoffLAN/blob/master/custom_components/sonoff/sonoff_cloud.py

payload for "userOnline" was changed also a bit.

Once I've changed it it works now

marcinlubojanski commented 3 years ago

Here is my edited sonoff.py that seems to work now. sonoff.zip

Shisir99 commented 2 years ago

@marcinlubojanski sometimes it work and the other time it shows the error

failed to create the websocket invalid websocket, state cannot be changed

marcinlubojanski commented 2 years ago

That looks like network issue. Try using different DNS server and maybe increase timeout in socket creation.

wt., 10 maj 2022, 08:22 użytkownik Shishir Chauhan @.***> napisał:

@marcinlubojanski https://github.com/marcinlubojanski sometimes it work and the other time it shows the error

failed to create the websocket invalid websocket, state cannot be changed

— Reply to this email directly, view it on GitHub https://github.com/lucien2k/sonoff-python/issues/27#issuecomment-1121976576, or unsubscribe https://github.com/notifications/unsubscribe-auth/APFJRO6OVUGWAWU2K6NB2QLVJH6A3ANCNFSM4THLAFVA . You are receiving this because you were mentioned.Message ID: @.***>

fgplastina commented 1 year ago

@marcinlubojanski which version of Websocket are you using? i can't find any with "create_connection" function.

EDIT: it seems to be https://pypi.org/project/websocket-client/. Now Marcin's script works like a charm. Thank you very much mate!

marcinlubojanski commented 1 year ago

@fgplastina good to hear that :)

vissieGP commented 1 year ago

Worked for me thx.