lucien2k / sonoff-python

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

Update sonoff.py #17

Open AviPaperno opened 4 years ago

AviPaperno commented 4 years ago

Fixed error with get_devices()

It returned Error 400

VDigitall commented 4 years ago

I checked a few minutes ago and version in master branch works for me, this pr is redundant.

muhannad17 commented 4 years ago

Actually I had the same problem as (Snusmumrick), I managed to get it fixed by adding GET Parameters to the (api/user/device) Request ( find attached code ).

And the commit is necessary for the app to get the devices list. Maybe the api response is country dependant !

sonoff.txt

ndg63276 commented 4 years ago

In my testing I found that, when getting the list of devices, by sending params to /api/user/device:

So be careful and consistent.

This PR is pretty ugly though, URL parameters should be sent using the params keyword in requests.get(), not just appending to the URL.