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

Cant get the list of devices #26

Open
jadolg opened this issue Sep 27, 2020 · 12 comments
Open

Cant get the list of devices #26

jadolg opened this issue Sep 27, 2020 · 12 comments

Comments

@jadolg
Copy link

jadolg commented Sep 27, 2020

I managed to correctly log in, but the list of devices is empty.
This is what I'm doing:

import sonoff

s = sonoff.Sonoff("[email protected]", "mypassword", "eu")
devices = s.get_devices()

And I'm actively using the devices on the ewelink application and with google home.
Maybe something changed in the API?

@amiltonjr
Copy link

I am having the same issue. The only thing it prints out is:

WARNING:sonoff.sonoff:Grace period activated!

Does anybody know why it is happening?

import json
import datetime

import logging
logging.basicConfig()
logger = logging.getLogger('logger')

import sonoff

def serialize(obj):
    """JSON serializer for objects not serializable by default json code"""

    if isinstance(obj, datetime.date):
        serial = obj.isoformat()
        return serial

    if isinstance(obj, datetime.time):
        serial = obj.isoformat()
        return serial
        
    if isinstance(obj, datetime.timedelta):
        return obj.total_seconds()

    return obj.__dict__

username		= 'username_goes_here'
password		= 'password_goes_here'
api_region		= 'us'

s			= sonoff.Sonoff(username, password, api_region)

print ("\nSonoff object: " + json.dumps(s, default=serialize) + "\n")

devices	= s.get_devices(True)

if devices:
	device_id = devices[0]['deviceid']
	print("Device example:" + device_id)
else:
	print "No device was found!"

@Tahutipai
Copy link

Same issue here. All I get is "Grace period activated!"

@laurobmb
Copy link

laurobmb commented Oct 19, 2020

Does it have to do with the wrong call at ewelink login?

    if 'error' in resp and resp['error'] in [HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED]:
        # @IMPROVE add maybe a service call / switch to deactivate sonoff component
        if self.is_grace_period():
            _LOGGER.warning("Grace period activated!")

@marcinlubojanski
Copy link

You can't use app and python at the same time with same credentials. Create another account and share access to your device.

@jadolg
Copy link
Author

jadolg commented Nov 21, 2020

The new account approach won't work for me either 😞
I created a new account, logged out, logged in on mine, and shared the devices with the new one.
I get the same behavior.

@jadolg
Copy link
Author

jadolg commented Nov 21, 2020

I have also tried this one https://github.com/skydiver/ewelink-api/ and it works with the same credentials.

@jadolg
Copy link
Author

jadolg commented Nov 21, 2020

The problem seems to go a bit further than this grace period message. I do not fully understand the purpose but I decided to wait for it.
The code to get the devices list does this:

        # we are in the grace period, no updates to the devices
        if self._skipped_login and self.is_grace_period():
            _LOGGER.info("Grace period active")
            return self._devices

So I decided to wait in my code to see what happens:

s = sonoff.Sonoff("[email protected]", "mypassword", "eu")
while s.is_grace_period():
    print(".")
    time.sleep(1)
devices = s.get_devices(force_update=True)
pprint(devices)

And I got this:

.
Grace period activated!
.
.
.
.
.
.
.
.
{'error': 400, 'msg': 'params incomplete'}
Grace period activated!

Note that I added a . per retry every second.
Looks like the API changed and this project is not up to date.

@mattmofr
Copy link

Hi everyone,
I have the same issue here.
Any solution in sight ?

@henrykozhaya
Copy link

Same issue here!

@bertpig
Copy link

bertpig commented Oct 1, 2021

This is most likely due to the app ID and secret not being update - see issue #24 which is direct outreach from the guys at eWelink. If you use a valid app ID / secret then listing and on/off switching appears to work - although this might only apply to VIP/paid accounts now (I don't have an unpaid account to test with).

@tvdsluijs
Copy link

So... I guess this project is a dead end? Any other working python Sonoff packages out there?

@marcinlubojanski
Copy link

Check #27. I have posted there my code which works for me.

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

No branches or pull requests

9 participants