mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-20 09:00:09 -07:00
Handle the error
This commit is contained in:
parent
04b4c7a6ce
commit
5ffa880e80
@ -46,6 +46,7 @@ def example():
|
||||
if 'gateway' in state:
|
||||
gateway = wideq.Gateway.load(state['gateway'])
|
||||
else:
|
||||
print('Discovering gateway servers.')
|
||||
gateway = wideq.Gateway.discover()
|
||||
|
||||
state['gateway'] = gateway.dump()
|
||||
@ -65,16 +66,22 @@ def example():
|
||||
session = wideq.Session.load(auth, state['session'])
|
||||
devices = None
|
||||
else:
|
||||
print('Starting session.')
|
||||
session, devices = auth.start_session()
|
||||
|
||||
state['session'] = session.dump()
|
||||
save_state(state)
|
||||
|
||||
try:
|
||||
# Request a list of devices, if we didn't get them "for free"
|
||||
# already by starting the session.
|
||||
if not devices:
|
||||
devices = session.get_devices()
|
||||
|
||||
except wideq.NotLoggedInError:
|
||||
print('Session expired.')
|
||||
return
|
||||
|
||||
print_devices(devices)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user