pycupra 0.1.12__py3-none-any.whl → 0.1.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
example/PyCupra.py ADDED
@@ -0,0 +1,611 @@
1
+ #!/usr/bin/env python3
2
+ """ Sample program to show the features of pycupra"""
3
+ import asyncio
4
+ import logging
5
+ import inspect
6
+ import sys
7
+ import os
8
+ import json
9
+ import pandas as pd
10
+ from aiohttp import ClientSession
11
+ from datetime import datetime
12
+
13
+ currentframe = inspect.currentframe()
14
+ if currentframe != None:
15
+ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(currentframe)))
16
+ parentdir = os.path.dirname(currentdir)
17
+ sys.path.insert(0, parentdir)
18
+
19
+ try:
20
+ from pycupra import Connection
21
+ except ModuleNotFoundError as e:
22
+ print(f"Unable to import library: {e}")
23
+ sys.exit(1)
24
+
25
+ logging.basicConfig(level=logging.DEBUG)
26
+ _LOGGER = logging.getLogger(__name__)
27
+ BRAND = 'cupra' # or 'seat' (Change it to 'seat' if you want to connect to the My Seat portal)
28
+
29
+ PRINTRESPONSE = True
30
+ INTERVAL = 5
31
+ TOKEN_FILE_NAME_AND_PATH='./pycupra_token.json'
32
+ CREDENTIALS_FILE_NAME_AND_PATH='./pycupra_credentials.json'
33
+ FIREBASE_CREDENTIALS_FILE_NAME_AND_PATH='./pycupra_firebase_credentials.json'
34
+ ALL_ATTRIBUTES_FILE_NAME_AND_PATH='./pycupra_all_attributes.txt'
35
+
36
+
37
+ COMPONENTS = {
38
+ 'sensor': 'sensor',
39
+ 'binary_sensor': 'binary_sensor',
40
+ 'lock': 'lock',
41
+ 'device_tracker': 'device_tracker',
42
+ 'switch': 'switch',
43
+ }
44
+
45
+ RESOURCES = [
46
+ "adblue_level",
47
+ "area_alarm",
48
+ "auxiliary_climatisation",
49
+ "battery_level",
50
+ "charge_max_ampere",
51
+ "charger_action_status",
52
+ "charging",
53
+ "charge_max_ampere",
54
+ "charge_rate",
55
+ "charging_power",
56
+ "charging_state",
57
+ "charging_cable_connected",
58
+ "charging_cable_locked",
59
+ "charging_time_left",
60
+ "climater_action_status",
61
+ "climatisation_target_temperature",
62
+ "climatisation_without_external_power",
63
+ "combined_range",
64
+ "combustion_range",
65
+ "departure1",
66
+ "departure2",
67
+ "departure3",
68
+ "departure_profile1",
69
+ "departure_profile2",
70
+ "departure_profile3",
71
+ "distance",
72
+ "door_closed_left_back",
73
+ "door_closed_left_front",
74
+ "door_closed_right_back",
75
+ "door_closed_right_front",
76
+ "door_locked",
77
+ "electric_climatisation",
78
+ "electric_range",
79
+ "energy_flow",
80
+ "external_power",
81
+ "fuel_level",
82
+ "hood_closed",
83
+ "last_connected",
84
+ "last_full_update",
85
+ "lock_action_status",
86
+ "oil_inspection",
87
+ "oil_inspection_distance",
88
+ "outside_temperature",
89
+ "parking_light",
90
+ "parking_time",
91
+ "pheater_heating",
92
+ "pheater_status",
93
+ "pheater_ventilation",
94
+ "position",
95
+ "refresh_action_status",
96
+ "refresh_data",
97
+ "request_flash",
98
+ "request_honkandflash",
99
+ "request_in_progress",
100
+ "request_results",
101
+ "requests_remaining",
102
+ "service_inspection",
103
+ "service_inspection_distance",
104
+ "slow_charge",
105
+ "sunroof_closed",
106
+ "target_soc",
107
+ "trip_last_average_auxillary_consumption",
108
+ "trip_last_average_electric_consumption",
109
+ "trip_last_average_fuel_consumption",
110
+ "trip_last_average_speed",
111
+ "trip_last_duration",
112
+ "trip_last_entry",
113
+ "trip_last_length",
114
+ "trip_last_recuperation",
115
+ "trip_last_total_electric_consumption",
116
+ "trip_last_cycle_average_auxillary_consumption",
117
+ "trip_last_cycle_average_electric_consumption",
118
+ "trip_last_cycle_average_fuel_consumption",
119
+ "trip_last_cycle_average_speed",
120
+ "trip_last_cycle_duration",
121
+ "trip_last_cycle_entry",
122
+ "trip_last_cycle_length",
123
+ "trip_last_cycle_recuperation",
124
+ "trip_last_cycle_total_electric_consumption",
125
+ "trunk_closed",
126
+ "trunk_locked",
127
+ "vehicle_moving",
128
+ "warnings",
129
+ "window_closed_left_back",
130
+ "window_closed_left_front",
131
+ "window_closed_right_back",
132
+ "window_closed_right_front",
133
+ "window_heater",
134
+ "windows_closed",
135
+ "seat_heating"
136
+ ]
137
+
138
+ def is_enabled(attr):
139
+ """Return true if the user has enabled the resource."""
140
+ return attr in RESOURCES
141
+
142
+ def readCredentialsFile():
143
+ try:
144
+ with open(CREDENTIALS_FILE_NAME_AND_PATH, "r") as f:
145
+ credentialsString=f.read()
146
+ credentials=json.loads(credentialsString)
147
+ return credentials
148
+ except:
149
+ _LOGGER.info('readCredentialsFile not successful. Perhaps no credentials file present.')
150
+ return None
151
+
152
+ def exportToCSV(vehicle, csvFileName, dataType='short'):
153
+ df= pd.DataFrame(vehicle._states['tripstatistics'][dataType])
154
+ _LOGGER.debug('Exporting trip data to csv')
155
+ df.to_csv(csvFileName)
156
+ return True
157
+
158
+ def exportAllAttributes(vehicle, exportFileName):
159
+ try:
160
+ with open(exportFileName, "w") as f:
161
+ print(vehicle.attrs, file=f)
162
+ f.close()
163
+ return True
164
+ except Exception as e:
165
+ _LOGGER.warning(f'exportAllAttributes() not successful. Error: {e}')
166
+ return False
167
+
168
+ async def demo_set_charger(vehicle, action="start"):
169
+ print('########################################')
170
+ print('# Start/Stop charging #')
171
+ print('########################################')
172
+ success= await vehicle.set_charger(action) # mode = "start", "stop", "on" or "off".
173
+ if success:
174
+ print(" Request completed successfully.")
175
+ else:
176
+ print(" Request failed.")
177
+ return success
178
+
179
+ async def demo_set_charger_current(vehicle, value="reduced"):
180
+ print('########################################')
181
+ print('# Change charging current #')
182
+ print('########################################')
183
+ success= await vehicle.set_charger_current(value)
184
+ if success:
185
+ print(" Request completed successfully.")
186
+ else:
187
+ print(" Request failed.")
188
+ return success
189
+
190
+ async def demo_set_charger_target_soc(vehicle, value=80):
191
+ print('########################################')
192
+ print('# Change target state of charge #')
193
+ print('########################################')
194
+ success= await vehicle.set_charger_target_soc(value)
195
+ if success:
196
+ print(" Request completed successfully.")
197
+ else:
198
+ print(" Request failed.")
199
+ return success
200
+
201
+ async def demo_set_timer_schedule(vehicle):
202
+ print('########################################')
203
+ print('# Change one timer schedule #')
204
+ print('########################################')
205
+ success= await vehicle.set_timer_schedule(id = 3, # id = 1, 2, 3
206
+ schedule = { # Set the departure time, date and periodicity
207
+ "enabled": True, # Set the timer active or not, True or False, required
208
+ "recurring": False, # True or False for recurring, required
209
+ "date": "2025-03-21", # Date for departure, required if recurring=False
210
+ "time": "12:34", # Time for departure, required
211
+ "days": "nyynnnn", # Days (mon-sun) for recurring schedule (n=disable, y=enable), required if recurring=True
212
+ "nightRateActive": True, # True or False Off-peak hours, optional
213
+ "nightRateStart": "23:00", # Off-peak hours start (HH:mm), optional
214
+ "nightRateEnd": "06:00", # Off-peak hours end (HH:mm), optional
215
+ "operationCharging": True, # True or False for charging, optional
216
+ "operationClimatisation": False, # True or False fro climatisation, optional
217
+ "targetTemp": 22, # Target temperature for climatisation, optional
218
+ }
219
+ )
220
+ if success:
221
+ print(" Request completed successfully.")
222
+ else:
223
+ print(" Request failed.")
224
+ return success
225
+
226
+ async def demo_set_departure_profile_schedule(vehicle):
227
+ print('########################################')
228
+ print('# Change one departure profile #')
229
+ print('########################################')
230
+ success= await vehicle.set_departure_profile_schedule(id = 3, # id = 1, 2, 3
231
+ schedule = { # Set the departure time, date and periodicity
232
+ "enabled": True, # Set the timer active or not, True or False, required
233
+ "recurring": True, # True or False for recurring, required
234
+ "time": "12:34", # Time for departure, required
235
+ "days": "nyynnnn", # Days (mon-sun) for recurring schedule (n=disable, y=enable), required if recurring=True
236
+ "chargingProgramId": 2, # Id of the charging program to be used for the departure profile
237
+ }
238
+ )
239
+ if success:
240
+ print(" Request completed successfully.")
241
+ else:
242
+ print(" Request failed.")
243
+ return success
244
+
245
+ async def demo_set_timer_active(vehicle, id=1, action="off"):
246
+ print('########################################')
247
+ print('# (De-)Activate one timer #')
248
+ print('########################################')
249
+ success= await vehicle.set_timer_active(id, action) # id = 1, 2, 3, action = "on" or "off".
250
+ if success:
251
+ print(" Request completed successfully.")
252
+ else:
253
+ print(" Request failed.")
254
+ return success
255
+
256
+ async def demo_set_departure_profile_active(vehicle, id=1, action="off"):
257
+ print('########################################')
258
+ print('# (De-)Activate one departure profile #')
259
+ print('########################################')
260
+ success= await vehicle.set_departure_profile_active(id, action) # id = 1, 2, 3, action = "on" or "off".
261
+ if success:
262
+ print(" Request completed successfully.")
263
+ else:
264
+ print(" Request failed.")
265
+ return success
266
+
267
+ async def demo_set_charge_limit(vehicle, limit=30):
268
+ print('########################################')
269
+ print('# Change minimum charge limit #')
270
+ print('########################################')
271
+ success= await vehicle.set_charge_limit(limit) # limit = 0,10,20,30,40,50
272
+ if success:
273
+ print(" Request completed successfully.")
274
+ else:
275
+ print(" Request failed.")
276
+ return success
277
+
278
+ async def demo_set_climatisation(vehicle, action="start", temp=18.0):
279
+ print('########################################')
280
+ print('# Start/Stop climatisation #')
281
+ print('########################################')
282
+ success= await vehicle.set_climatisation(action, temp) # mode = "auxilliary", "electric" or "off". spin is S-PIN and only needed for aux heating
283
+ if success:
284
+ print(" Request completed successfully.")
285
+ else:
286
+ print(" Request failed.")
287
+ return success
288
+
289
+ async def demo_set_climatisation_temp(vehicle, temp=18.0):
290
+ print('########################################')
291
+ print('# Change climatisation temperature #')
292
+ print('########################################')
293
+ success= await vehicle.set_climatisation_temp(temp) # temperature = integer from 16 to 30
294
+ if success:
295
+ print(" Request completed successfully.")
296
+ else:
297
+ print(" Request failed.")
298
+ return success
299
+
300
+ async def demo_set_battery_climatisation(vehicle, mode=True):
301
+ print('########################################')
302
+ print('# Set battery climatisation setting #')
303
+ print('########################################')
304
+ success= await vehicle.set_battery_climatisation(mode) # mode = False or True
305
+ if success:
306
+ print(" Request completed successfully.")
307
+ else:
308
+ print(" Request failed.")
309
+ return success
310
+
311
+ async def demo_set_windowheating(vehicle, action="stop"):
312
+ print('########################################')
313
+ print('# Start/Stop window heating #')
314
+ print('########################################')
315
+ success= await vehicle.set_window_heating(action) # action = "start" or "stop"
316
+ if success:
317
+ print(" Request completed successfully.")
318
+ else:
319
+ print(" Request failed.")
320
+ return success
321
+
322
+ async def demo_set_honkandflash(vehicle, action="flash"):
323
+ print('########################################')
324
+ print('# Initiate (honk and) flash #')
325
+ print('########################################')
326
+ success= await vehicle.set_honkandflash(action)
327
+ if success:
328
+ print(" Request completed successfully.")
329
+ else:
330
+ print(" Request failed.")
331
+ return success
332
+
333
+ async def demo_set_lock(vehicle, action="lock", spin="1234"):
334
+ print('########################################')
335
+ print('# Lock/unlock vehicle #')
336
+ print('########################################')
337
+ success= await vehicle.set_lock(action, spin)
338
+ if success:
339
+ print(" Request completed successfully.")
340
+ else:
341
+ print(" Request failed.")
342
+ return success
343
+
344
+ async def demo_show_last_honkandflash_info(vehicle):
345
+ print('########################################')
346
+ print('# Show info of last honk&flash request #')
347
+ print('########################################')
348
+ status= vehicle.honkandflash_action_status
349
+ timestamp= vehicle.honkandflash_action_timestamp
350
+ if True: #success:
351
+ print(f" Last honk and flash was at {timestamp}. Status: {status}")
352
+ else:
353
+ print(" No honk and flash request was found.")
354
+ return timestamp
355
+
356
+ async def demo_send_destination(vehicle):
357
+ print('########################################')
358
+ print('# Send destination to vehicle #')
359
+ print('########################################')
360
+ success= await vehicle.send_destination(
361
+ destination = { # Send destination address
362
+ "address": { # address data optional
363
+ "city":"Weiterstadt",
364
+ "country":"Germany",
365
+ "stateAbbreviation":"Hessen",
366
+ "street":"Max-Planck-Straße",
367
+ "houseNumber":"3-5",
368
+ "zipCode":"64331"
369
+ },
370
+ "poiProvider":"google", # poiProvider mandatory
371
+ "geoCoordinate":{"latitude":49.89824,"longitude":8.59465}, # geoCoordinate mandatory
372
+ "destinationName":"Seat/Cupra Deutschland"
373
+ }
374
+ )
375
+ if success:
376
+ print(" Request completed successfully.")
377
+ else:
378
+ print(" Request failed.")
379
+ return success
380
+
381
+
382
+ async def main():
383
+ """Main method."""
384
+ credentials= readCredentialsFile()
385
+ if credentials==None or credentials.get('username','')=='' or (credentials.get('password','')==''):
386
+ _LOGGER.warning('Can not use the credentials read from the credentials file.')
387
+ raise
388
+ if credentials.get('brand','')!='':
389
+ BRAND = credentials.get('brand','')
390
+ print('Read brand from the credentials file.')
391
+ else:
392
+ print('No brand found in the credentials file. Using the default value.')
393
+ print(f'Now working with brand={BRAND}')
394
+ async with ClientSession(headers={'Connection': 'keep-alive'}) as session:
395
+ print('')
396
+ print('######################################################')
397
+ print('# Logging on to ola.prod.code.seat.cloud.vwgroup.com #')
398
+ print('######################################################')
399
+ print(f"Initiating new session to Cupra/Seat Cloud with {credentials.get('username')} as username")
400
+ connection = Connection(session, BRAND, credentials.get('username'), credentials.get('password'), PRINTRESPONSE, nightlyUpdateReduction=False, anonymise=True, tripStatisticsStartDate='1970-01-01')
401
+ print("Attempting to login to the Seat Cloud service")
402
+ print(datetime.now())
403
+ if await connection.doLogin(tokenFile=TOKEN_FILE_NAME_AND_PATH, apiKey=credentials.get('apiKey',None)):
404
+ print('Login or token refresh success!')
405
+ print(datetime.now())
406
+ print('Fetching user information for account.')
407
+ await connection.get_userData()
408
+ print(f"\tName: {connection._userData.get('name','')}")
409
+ print(f"\tNickname: {connection._userData.get('nickname','')}")
410
+ print(f"\tEmail: {connection._userData.get('email','')}")
411
+ print(f"\tPicture: {connection._userData.get('picture','')}")
412
+ print("")
413
+ print('Fetching vehicles associated with account.')
414
+ await connection.get_vehicles()
415
+
416
+ instruments = set()
417
+ for vehicle in connection.vehicles:
418
+ txt = vehicle.vin
419
+ if vehicle == connection.vehicles[0]: # Firebase can only be activated for one vehicle. So we use it for the first one
420
+ newStatus = await vehicle.initialiseFirebase(FIREBASE_CREDENTIALS_FILE_NAME_AND_PATH, vehicle.update)
421
+ print('########################################')
422
+ print('# Initialisation of firebase #')
423
+ print(txt.center(40, '#'))
424
+ print(f"New status of firebase={newStatus}")
425
+
426
+ print('')
427
+ print('########################################')
428
+ print('# Setting up dashboard #')
429
+ print(txt.center(40, '#'))
430
+ dashboard = vehicle.dashboard(mutable=True)
431
+
432
+ """for instrument in (
433
+ instrument
434
+ for instrument in dashboard.instruments
435
+ if instrument.component in COMPONENTS
436
+ and is_enabled(instrument.slug_attr)):
437
+
438
+ instruments.add(instrument)
439
+ """
440
+ for instrument in dashboard.instruments:
441
+ if instrument.component in COMPONENTS and is_enabled(instrument.slug_attr):
442
+ instruments.add(instrument)
443
+ print('')
444
+ print('########################################')
445
+ print('# Vehicles discovered #')
446
+ print('########################################')
447
+ for vehicle in connection.vehicles:
448
+ print(f"\tVIN: {vehicle.vin}")
449
+ print(f"\tModel: {vehicle.model}")
450
+ print(f"\tManufactured: {vehicle.model_year}")
451
+ print(f"\tConnect service deactivated: {vehicle.deactivated}")
452
+ print("")
453
+ if vehicle.is_nickname_supported: print(f"\tNickname: {vehicle.nickname}")
454
+ print(f"\tObject attributes, and methods:")
455
+ for prop in dir(vehicle):
456
+ if not "__" in prop:
457
+ try:
458
+ func = f"vehicle.{prop}"
459
+ typ = type(eval(func))
460
+ print(f"\t\t{prop} - {typ}")
461
+ except:
462
+ pass
463
+
464
+ else:
465
+ return False
466
+
467
+ # Output all instruments and states
468
+ print('')
469
+ print('########################################')
470
+ print('# Instruments from dashboard #')
471
+ print('########################################')
472
+ inst_list = sorted(instruments, key=lambda x: x.attr)
473
+ for instrument in inst_list:
474
+ print(f'{instrument.full_name}|{instrument.attr} - {instrument.str_state}|{instrument.state} - attributes: {instrument.attributes}')
475
+
476
+ print('')
477
+ print(f"Sleeping for {INTERVAL} seconds")
478
+ await asyncio.sleep(INTERVAL)
479
+
480
+ print('')
481
+ print(datetime.now())
482
+ print('')
483
+ #print('########################################')
484
+ #print('# Updating all values from MyCupra/Seat#')
485
+ #print('########################################')
486
+ #print("Updating ALL values from My Cupra/Seat Cloud ....")
487
+ #if await connection.update_all():
488
+ # print("Success!")
489
+ #else:
490
+ # print("Failed")
491
+
492
+ # Sleep for a given amount of time and update individual API endpoints for each vehicle
493
+ #print('')
494
+ #print(f"Sleeping for {INTERVAL} seconds")
495
+ #await asyncio.sleep(INTERVAL)
496
+
497
+ for vehicle in connection.vehicles:
498
+ """print('')
499
+ print(datetime.now())
500
+ print('')
501
+ print('########################################')
502
+ print('# Update charger data #')
503
+ print(txt.center(40, '#'))
504
+ await vehicle.get_charger()
505
+ print('')
506
+ print('########################################')
507
+ print('# Update climater data #')
508
+ print(txt.center(40, '#'))
509
+ await vehicle.get_climater()
510
+ print('')
511
+ print('########################################')
512
+ print('# Update position data #')
513
+ print(txt.center(40, '#'))
514
+ await vehicle.get_position()
515
+ print('')
516
+ print('########################################')
517
+ print('# Update preheater data #')
518
+ print(txt.center(40, '#'))
519
+ await vehicle.get_preheater()
520
+ print('')
521
+ print('########################################')
522
+ print('# Update realcar data #')
523
+ print(txt.center(40, '#'))
524
+ await vehicle.get_realcardata()
525
+ print('')
526
+ print('########################################')
527
+ print('# Update status data #')
528
+ print(txt.center(40, '#'))
529
+ await vehicle.get_statusreport()
530
+ print('')
531
+ print('########################################')
532
+ print('# Update timer programming #')
533
+ print(txt.center(40, '#'))
534
+ await vehicle.get_timerprogramming()
535
+ print('')
536
+ print('########################################')
537
+ print('# Update trip statistics #')
538
+ print(txt.center(40, '#'))
539
+ await vehicle.get_trip_statistic()
540
+ print('')
541
+ print('Updates complete')
542
+
543
+ print(f"Sleeping for {INTERVAL} seconds")
544
+ await asyncio.sleep(INTERVAL)"""
545
+
546
+ print('########################################')
547
+ print('# Export driving data to csv #')
548
+ print(txt.center(40, '#'))
549
+ exportToCSV(vehicle, credentials.get('csvFileName','./drivingData.csv'), 'short') # possible value: short/cyclic
550
+ print('')
551
+ print('Export of driving data to csv complete')
552
+
553
+ # Examples for using set functions:
554
+
555
+ #await demo_set_charger(vehicle, action = "start") # action = "start" or "stop"
556
+ #await demo_set_charger_current(vehicle, value='reduced') # value = 1-255/Maximum/Reduced (PHEV: 252 for reduced and 254 for max, EV: Maximum/Reduced)
557
+ #await demo_set_charger_target_soc(vehicle, value=70) # value = 1-100
558
+
559
+ #await demo_set_climatisation(vehicle, action = "start", temp=18.0) # action = "auxilliary", "electric" or "off". spin is S-PIN and only needed for aux heating
560
+ #await demo_set_climatisation_temp(vehicle, temp = 18.0) # temp = integer from 16 to 30
561
+ #await demo_set_battery_climatisation(vehicle, mode=False) # mode = False or True
562
+ #await demo_set_windowheating(vehicle, action = "stop") # action = "start" or "stop"
563
+
564
+ #await demo_set_timer_schedule(vehicle) # arguments id and schedule can be found in the demo function
565
+ #await demo_set_timer_active(vehicle, id=3, action="off") # id = 1, 2, 3, action = "on" or "off".
566
+ #await demo_set_charge_limit(vehicle, 30) # limit = PHEV: 0/10/20/30/40/50, EV: 50/60/70/80/90/100
567
+
568
+ #await demo_set_departure_profile_schedule(vehicle) # arguments id and schedule can be found in the demo function
569
+ #await demo_set_departure_profile_active(vehicle, id=3, action="off") # id = 1, 2, 3, action = "on" or "off".
570
+
571
+ #await demo_set_lock(vehicle,action = "lock",
572
+ # spin = credentials.get('spin','')) # action = "unlock" or "lock". spin = SPIN, needed for both
573
+
574
+ #await vehicle.set_pheater(mode = "heating", spin = "1234") # action = "heating", "ventilation" or "off". spin = SPIN, not needed for off
575
+
576
+ #await demo_set_honkandflash(vehicle, action="flash") # action = "honkandflash" or "flash"
577
+
578
+ #await vehicle.set_refresh() # Takes no arguments, will trigger forced update
579
+
580
+ #print(f"Sleeping for {2*INTERVAL} seconds")
581
+ #await asyncio.sleep(2*INTERVAL)
582
+ #await demo_show_last_honkandflash_info(vehicle) # Returns the info of the last honkandflash_action
583
+
584
+ #await demo_send_destination(vehicle) # arguments can be found in the demo function
585
+
586
+ print('########################################')
587
+ print('# Export all attributes to file #')
588
+ print(txt.center(40, '#'))
589
+ rc= exportAllAttributes(vehicle, ALL_ATTRIBUTES_FILE_NAME_AND_PATH)
590
+ print('')
591
+ if rc:
592
+ print('Export of all attributes successfully completed')
593
+ else:
594
+ print('Export of all attributes failed')
595
+
596
+ if vehicle.firebaseStatus== 1: # firebase messaging activated
597
+ # Do an endless loop to wait and receive firebase messages
598
+ i=0
599
+ while True:
600
+ print(f"Sleeping for {6*INTERVAL} seconds")
601
+ await asyncio.sleep(6*INTERVAL)
602
+ i=i+1
603
+ _LOGGER.debug(f'Round {i}')
604
+
605
+ sys.exit(1)
606
+
607
+ if __name__ == "__main__":
608
+ loop = asyncio.new_event_loop()
609
+ asyncio.set_event_loop(loop)
610
+ loop.run_until_complete(main())
611
+