Open jadolg opened 3 years ago
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!"
Same issue here. All I get is "Grace period activated!"
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!")
You can't use app and python at the same time with same credentials. Create another account and share access to your device.
The new account approach won't work for me either :disappointed: I created a new account, logged out, logged in on mine, and shared the devices with the new one. I get the same behavior.
I have also tried this one https://github.com/skydiver/ewelink-api/ and it works with the same credentials.
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@example.com", "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.
Hi everyone, I have the same issue here. Any solution in sight ?
Same issue here!
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).
So... I guess this project is a dead end? Any other working python Sonoff packages out there?
Check #27. I have posted there my code which works for me.
I managed to correctly log in, but the list of devices is empty. This is what I'm doing:
And I'm actively using the devices on the ewelink application and with google home. Maybe something changed in the API?