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

When trying to list devices I'm getting error "params incomplete" #20

Open marcinlubojanski opened 4 years ago

marcinlubojanski commented 4 years ago

I'm logging in properly, then when I try to get list of devices I'm getting error in response

('response :', {u'msg': u'params incomplete', u'error': 400})

Response code: 200

Tried with 2 accounts, one has 2 devices (POW R2 and 4CH), the other has just one shared from the first one (POW R2). If it makes any difference, both were created from Android app, not iPhone.

lucien2k commented 4 years ago

Do you have the right region selected? I seem to remember getting this when I changed region to the wrong one

marcinlubojanski commented 4 years ago

Yes, it was correct. I've managed to get list of devices by using the request from HASS-sonoff-ewelink project. r = requests.get('https://{}-api.coolkit.cc:8080/api/user/device?lang=en&apiKey={}&getTags=1&version=6&ts=%s&nonce=%s&appid=oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq&imei=%s&os=iOS&model=%s&romVersion=%s&appVersion=%s'.format( self._api_region, self.get_user_apikey(), str(int(time.time())), ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)), self._imei, self._model, self._romVersion, self._appVersion ), headers=self._headers) Also modified the do_login to include those variables.

Now I'm fighting with websocket issues... but it might be that my python is missing something (like f.e. logger - I had to remove it from the code) as I'm trying to run it on a WiFi router with entware

mrave commented 4 years ago

@marcinlubojanski did you manage to get this to work? I still get empty lists...

marcinlubojanski commented 4 years ago

yes, it work for me with the change as written above. Do you also get "params incomplete" error message ?

mrave commented 4 years ago

yes, it work for me with the change as written above. Do you also get "params incomplete" error message ?

I do indeed get the message. I used your PR and it worked, this should be merged - thanks!