11"""Run an example script to quickly test any SimpliSafe system."""
2+ # pylint: disable=protected-access
3+
24import asyncio
35
46from aiohttp import ClientSession
57
6- import simplipy
8+ from simplipy import API
79from simplipy .errors import SimplipyError
810
911
@@ -13,18 +15,19 @@ async def exercise_client(
1315 print ('{0}' .format (email ))
1416 print ('========================' )
1517
16- systems = await simplipy .get_systems (email , password , websession )
18+ simplisafe = await API .login_via_credentials (email , password , websession )
19+ systems = await simplisafe .get_systems ()
1720 for idx , system in enumerate (systems ):
1821 print ()
1922 print ('System #{0}' .format (idx + 1 ))
2023 print ('------------------------' )
2124 print ('Version: {0}' .format (system .version ))
22- print ('User ID: {0}' .format (system .account .user_id ))
23- print ('Access Token: {0}' .format (system .account . access_token ))
24- print ('Refresh Token: {0}' .format (system .account .refresh_token ))
25+ print ('User ID: {0}' .format (system .api .user_id ))
26+ print ('Access Token: {0}' .format (system .api . _access_token ))
27+ print ('Refresh Token: {0}' .format (system .api .refresh_token ))
2528
2629 events = await system .get_events ()
27- print ('Number of Events: {0}' .format ((len (events [ 'events' ] ))))
30+ print ('Number of Events: {0}' .format ((len (events ))))
2831
2932 print ()
3033 print ('Sensors:' )
@@ -34,16 +37,9 @@ async def exercise_client(
3437 serial , sensor_attrs .name , sensor_attrs .type ,
3538 sensor_attrs .triggered ))
3639
37- print ()
38- print ('Refreshing Access Token:' )
39- await system .account .refresh_access_token ()
40- print ('Access Token: {0}' .format (system .account .access_token ))
41- print ('Refresh Token: {0}' .format (system .account .refresh_token ))
42-
4340 print ()
4441 print ('Setting System to "Home":' )
4542 await system .set_home ()
46- await asyncio .sleep (5 )
4743
4844 print ()
4945 print ('Setting System to "Off":' )
@@ -57,7 +53,7 @@ async def main() -> None:
5753 async with ClientSession () as websession :
5854 try :
5955 print ()
60- await exercise_client ('EMAIL' , 'PASSWORD' , websession )
56+ await exercise_client ('< EMAIL> ' , '< PASSWORD> ' , websession )
6157 except SimplipyError as err :
6258 print (err )
6359
0 commit comments