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.
pycupra/dashboard.py CHANGED
@@ -26,7 +26,7 @@ class Instrument:
26
26
  def slug_attr(self):
27
27
  return camel2slug(self.attr.replace(".", "_"))
28
28
 
29
- def setup(self, vehicle, **config):
29
+ def setup(self, vehicle, **config) -> bool:
30
30
  self.vehicle = vehicle
31
31
  if not self.is_supported:
32
32
  return False
@@ -78,7 +78,7 @@ class Sensor(Instrument):
78
78
  self.unit = unit
79
79
  self.convert = False
80
80
 
81
- def configurate(self, **config):
81
+ def configurate(self, **config) -> None:
82
82
  if self.unit and config.get('miles', False) is True:
83
83
  if "km" == self.unit:
84
84
  self.unit = "mi"
@@ -109,7 +109,7 @@ class Sensor(Instrument):
109
109
  self.vehicle.pheater_duration = setValue
110
110
 
111
111
  @property
112
- def is_mutable(self):
112
+ def is_mutable(self) -> bool:
113
113
  return False
114
114
 
115
115
  @property
@@ -147,7 +147,7 @@ class BinarySensor(Instrument):
147
147
  self.reverse_state = reverse_state
148
148
 
149
149
  @property
150
- def is_mutable(self):
150
+ def is_mutable(self) -> bool:
151
151
  return False
152
152
 
153
153
  @property
@@ -191,11 +191,11 @@ class Switch(Instrument):
191
191
  super().__init__(component="switch", attr=attr, name=name, icon=icon)
192
192
 
193
193
  @property
194
- def is_mutable(self):
194
+ def is_mutable(self) -> bool:
195
195
  return True
196
196
 
197
197
  @property
198
- def str_state(self):
198
+ def str_state(self) -> str:
199
199
  return "On" if self.state else "Off"
200
200
 
201
201
  def is_on(self):
@@ -208,7 +208,7 @@ class Switch(Instrument):
208
208
  pass
209
209
 
210
210
  @property
211
- def assumed_state(self):
211
+ def assumed_state(self) -> bool:
212
212
  return True
213
213
 
214
214
 
@@ -221,13 +221,13 @@ class Climate(Instrument):
221
221
  pass
222
222
 
223
223
  @property
224
- def target_temperature(self):
224
+ def target_temperature(self) -> None:
225
225
  pass
226
226
 
227
- def set_temperature(self, **kwargs):
227
+ def set_temperature(self, **kwargs) -> None:
228
228
  pass
229
229
 
230
- def set_hvac_mode(self, hvac_mode):
230
+ def set_hvac_mode(self, hvac_mode) -> None:
231
231
  pass
232
232
 
233
233
 
@@ -284,7 +284,7 @@ class Position(Instrument):
284
284
  super().__init__(component="device_tracker", attr="position", name="Position")
285
285
 
286
286
  @property
287
- def is_mutable(self):
287
+ def is_mutable(self) -> bool:
288
288
  return False
289
289
 
290
290
  @property
@@ -298,7 +298,7 @@ class Position(Instrument):
298
298
  )
299
299
 
300
300
  @property
301
- def str_state(self):
301
+ def str_state(self) -> tuple:
302
302
  state = super().state #or {}
303
303
  ts = state.get("timestamp", None)
304
304
  if isinstance(ts, str):
@@ -323,11 +323,11 @@ class DoorLock(Instrument):
323
323
  self.spin = config.get('spin', '')
324
324
 
325
325
  @property
326
- def is_mutable(self):
326
+ def is_mutable(self) -> bool:
327
327
  return True
328
328
 
329
329
  @property
330
- def str_state(self):
330
+ def str_state(self) -> str:
331
331
  return "Locked" if self.state else "Unlocked"
332
332
 
333
333
  @property
@@ -400,21 +400,21 @@ class RequestHonkAndFlash(Switch):
400
400
  def state(self):
401
401
  return self.vehicle.request_honkandflash
402
402
 
403
- async def turn_on(self):
403
+ async def turn_on(self) -> None:
404
404
  await self.vehicle.set_honkandflash('honkandflash')
405
405
  #await self.vehicle.update()
406
406
  if self.callback is not None:
407
407
  self.callback()
408
408
 
409
- async def turn_off(self):
409
+ async def turn_off(self) -> None:
410
410
  pass
411
411
 
412
412
  @property
413
- def assumed_state(self):
413
+ def assumed_state(self) -> bool:
414
414
  return False
415
415
 
416
416
  @property
417
- def attributes(self):
417
+ def attributes(self) -> dict:
418
418
  return dict(last_result = self.vehicle.honkandflash_action_status)
419
419
 
420
420
 
@@ -426,21 +426,21 @@ class RequestFlash(Switch):
426
426
  def state(self):
427
427
  return self.vehicle.request_flash
428
428
 
429
- async def turn_on(self):
429
+ async def turn_on(self) -> None:
430
430
  await self.vehicle.set_honkandflash('flash')
431
431
  #await self.vehicle.update()
432
432
  if self.callback is not None:
433
433
  self.callback()
434
434
 
435
- async def turn_off(self):
435
+ async def turn_off(self) -> None:
436
436
  pass
437
437
 
438
438
  @property
439
- def assumed_state(self):
439
+ def assumed_state(self) -> bool:
440
440
  return False
441
441
 
442
442
  @property
443
- def attributes(self):
443
+ def attributes(self) -> dict:
444
444
  return dict(last_result = self.vehicle.honkandflash_action_status)
445
445
 
446
446
 
@@ -452,22 +452,22 @@ class RequestRefresh(Switch):
452
452
  def state(self):
453
453
  return self.vehicle.refresh_data
454
454
 
455
- async def turn_on(self):
455
+ async def turn_on(self) -> None:
456
456
  _LOGGER.debug('User has called RequestRefresh().')
457
457
  await self.vehicle.set_refresh()
458
458
  #await self.vehicle.update(updateType=1) #full update after set_refresh
459
459
  if self.callback is not None:
460
460
  self.callback()
461
461
 
462
- async def turn_off(self):
462
+ async def turn_off(self) -> None:
463
463
  pass
464
464
 
465
465
  @property
466
- def assumed_state(self):
466
+ def assumed_state(self) -> bool:
467
467
  return False
468
468
 
469
469
  @property
470
- def attributes(self):
470
+ def attributes(self) -> dict:
471
471
  return dict(last_result = self.vehicle.refresh_action_status)
472
472
 
473
473
 
@@ -476,20 +476,20 @@ class RequestUpdate(Switch):
476
476
  super().__init__(attr="update_data", name="Request full update", icon="mdi:timer-refresh")
477
477
 
478
478
  @property
479
- def state(self):
479
+ def state(self) -> bool:
480
480
  return False #self.vehicle.update
481
481
 
482
- async def turn_on(self):
482
+ async def turn_on(self) -> None:
483
483
  _LOGGER.debug('User has called RequestUpdate().')
484
484
  await self.vehicle.update(updateType=1) #full update after set_refresh
485
485
  if self.callback is not None:
486
486
  self.callback()
487
487
 
488
- async def turn_off(self):
488
+ async def turn_off(self) -> None:
489
489
  pass
490
490
 
491
491
  @property
492
- def assumed_state(self):
492
+ def assumed_state(self) -> bool:
493
493
  return False
494
494
 
495
495
  #@property
@@ -514,11 +514,11 @@ class ElectricClimatisation(Switch):
514
514
  #await self.vehicle.update()
515
515
 
516
516
  @property
517
- def assumed_state(self):
517
+ def assumed_state(self) -> bool:
518
518
  return False
519
519
 
520
520
  @property
521
- def attributes(self):
521
+ def attributes(self) -> dict:
522
522
  attrs = {}
523
523
  if self.vehicle.is_electric_climatisation_attributes_supported:
524
524
  attrs = self.vehicle.electric_climatisation_attributes
@@ -539,20 +539,20 @@ class AuxiliaryClimatisation(Switch):
539
539
  def state(self):
540
540
  return self.vehicle.auxiliary_climatisation
541
541
 
542
- async def turn_on(self):
542
+ async def turn_on(self) -> None:
543
543
  await self.vehicle.set_climatisation(mode = 'auxiliary', spin = self.spin)
544
544
  #await self.vehicle.update()
545
545
 
546
- async def turn_off(self):
546
+ async def turn_off(self) -> None:
547
547
  await self.vehicle.set_climatisation(mode = 'off')
548
548
  #await self.vehicle.update()
549
549
 
550
550
  @property
551
- def assumed_state(self):
551
+ def assumed_state(self) -> bool:
552
552
  return False
553
553
 
554
554
  @property
555
- def attributes(self):
555
+ def attributes(self) -> dict:
556
556
  return dict(last_result = self.vehicle.climater_action_status)
557
557
 
558
558
 
pycupra/firebase.py CHANGED
@@ -6,6 +6,8 @@ import string
6
6
  import secrets
7
7
 
8
8
  from .firebase_messaging import FcmPushClient, FcmRegisterConfig
9
+ from typing import Any
10
+
9
11
 
10
12
  from .const import (
11
13
  FCM_PROJECT_ID,
@@ -19,14 +21,15 @@ class Firebase():
19
21
  def __init__(self):
20
22
  self._pushClient = None
21
23
 
22
- async def firebaseStart(self, onNotificationFunc, firebaseCredentialsFileName, brand='cupra'):
24
+ async def firebaseStart(self, onNotificationFunc, firebaseCredentialsFileName: str, brand='cupra') -> bool:
23
25
  """ Starts the firebase cloud messaging receiver """
24
26
  try:
25
27
  loop = asyncio.get_running_loop()
26
28
  credentials = await loop.run_in_executor(None, readFCMCredsFile, firebaseCredentialsFileName)
27
29
  #credentials = readFCMCredsFile(firebaseCredentialsFileName)
28
- if credentials == {}:
29
- credentials =''
30
+
31
+ #if credentials == {}:
32
+ # credentials =None
30
33
 
31
34
  fcm_project_id=FCM_PROJECT_ID
32
35
  fcm_app_id=FCM_APP_ID[brand]
@@ -46,7 +49,7 @@ class Firebase():
46
49
  _LOGGER.error(f'Error in firebaseStart. Error: {e}')
47
50
  return False
48
51
 
49
- async def firebaseStop(self):
52
+ async def firebaseStop(self) -> bool:
50
53
  """ Stops the firebase cloud messaging receiver """
51
54
  try:
52
55
  await self._pushClient.stop()
@@ -57,7 +60,7 @@ class Firebase():
57
60
  _LOGGER.error(f'Error in firebaseStop. Error: {e}')
58
61
  return False
59
62
 
60
- def readFCMCredsFile(credsFile):
63
+ def readFCMCredsFile(credsFile) -> dict[str, Any]:
61
64
  """ Reads the firebase cloud messaging credentials from file"""
62
65
  try:
63
66
  if os.path.isfile(credsFile):
@@ -71,9 +74,9 @@ def readFCMCredsFile(credsFile):
71
74
  return {}
72
75
  except Exception as e:
73
76
  _LOGGER.warning(f'readFCMCredsFile() not successful. Error: {e}')
74
- return ''
77
+ return {}
75
78
 
76
- def writeFCMCredsFile(creds, firebaseCredentialsFileName):
79
+ def writeFCMCredsFile(creds, firebaseCredentialsFileName) -> None:
77
80
  """ Saves the firebase cloud messaging credentials to a file for future use """
78
81
  try:
79
82
  with open(firebaseCredentialsFileName, "w") as f:
@@ -82,7 +85,7 @@ def writeFCMCredsFile(creds, firebaseCredentialsFileName):
82
85
  except Exception as e:
83
86
  _LOGGER.warning(f'writeFCMCredsFile() not successful. Error: {e}')
84
87
 
85
- async def onFCMCredentialsUpdated(creds, firebaseCredentialsFileName):
88
+ async def onFCMCredentialsUpdated(creds: dict[str, Any], firebaseCredentialsFileName: str) -> None:
86
89
  """ Is called from firebase-messaging package """
87
90
  loop = asyncio.get_running_loop()
88
91
  await loop.run_in_executor(None, writeFCMCredsFile, creds, firebaseCredentialsFileName)