pycupra 0.0.3__tar.gz → 0.0.4__tar.gz

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.
@@ -5,4 +5,5 @@ build/
5
5
  dist/
6
6
  __pycache__/
7
7
  *.json
8
+ *.txt
8
9
  www/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: A library to read and send vehicle data via Cupra/Seat portal using the same API calls as the MyCupra/MySeat mobile app.
5
5
  Home-page: https://github.com/WulfgarW/pycupra
6
6
  Author: WulfgarW
@@ -28,6 +28,7 @@ PRINTRESPONSE = True
28
28
  INTERVAL = 5
29
29
  TOKEN_FILE_NAME_AND_PATH='./cupra_token.json'
30
30
  CREDENTIALS_FILE_NAME_AND_PATH='./cupra_credentials.json'
31
+ ALL_ATTRIBUTES_FILE_NAME_AND_PATH='./cupra_all_attributes.txt'
31
32
 
32
33
 
33
34
  COMPONENTS = {
@@ -142,6 +143,16 @@ def exportToCSV(vehicle, csvFileName, dataType='short'):
142
143
  df.to_csv(csvFileName)
143
144
  return True
144
145
 
146
+ def exportAllAttributes(vehicle, exportFileName):
147
+ try:
148
+ with open(exportFileName, "w") as f:
149
+ print(vehicle.attrs, file=f)
150
+ f.close()
151
+ return True
152
+ except Exception as e:
153
+ _LOGGER.warning(f'exportAllAttributes() not successful. Error: {e}')
154
+ return False
155
+
145
156
  async def demo_set_charger(vehicle, action="start"):
146
157
  print('########################################')
147
158
  print('# Start/Stop charging #')
@@ -461,8 +472,11 @@ async def main():
461
472
  print(txt.center(40, '#'))
462
473
  await vehicle.get_trip_statistic()
463
474
  print('')
464
- print('Updates complete')"""
475
+ print('Updates complete')
465
476
 
477
+ print(f"Sleeping for {INTERVAL} seconds")
478
+ await asyncio.sleep(INTERVAL)"""
479
+
466
480
  print('########################################')
467
481
  print('# Export driving data to csv #')
468
482
  print(txt.center(40, '#'))
@@ -470,9 +484,6 @@ async def main():
470
484
  print('')
471
485
  print('Export of driving data to csv complete')
472
486
 
473
- print(f"Sleeping for {INTERVAL} seconds")
474
- await asyncio.sleep(INTERVAL)
475
-
476
487
  # Examples for using set functions:
477
488
 
478
489
  #await demo_set_charger(vehicle, action = "start") # action = "start" or "stop"
@@ -502,8 +513,18 @@ async def main():
502
513
 
503
514
  #await demo_send_destination(vehicle) # arguments can be found in the demo function
504
515
 
505
- print(f"Sleeping for {5*INTERVAL} seconds")
506
- await asyncio.sleep(5*INTERVAL)
516
+ print('########################################')
517
+ print('# Export all attributes to file #')
518
+ print(txt.center(40, '#'))
519
+ rc= exportAllAttributes(vehicle, ALL_ATTRIBUTES_FILE_NAME_AND_PATH)
520
+ print('')
521
+ if rc:
522
+ print('Export of all attributes successfully completed')
523
+ else:
524
+ print('Export of all attributes failed')
525
+
526
+ print(f"Sleeping for {INTERVAL} seconds")
527
+ await asyncio.sleep(INTERVAL)
507
528
 
508
529
  exit
509
530
 
@@ -3,4 +3,4 @@ pycupra - A Python 3 library for interacting with the My Cupra/My Seat portal.
3
3
 
4
4
  For more details and documentation, visit the github page at https://github.com/WulfgarW/pycupra
5
5
  """
6
- __version__ = "0.0.3"
6
+ __version__ = "0.0.4"
@@ -153,6 +153,7 @@ class Connection:
153
153
  if os.path.isfile(self._tokenFile):
154
154
  with open(self._tokenFile, "r") as f:
155
155
  tokenString=f.read()
156
+ f.close()
156
157
  tokens=json.loads(tokenString)
157
158
  self._session_tokens[brand]=tokens
158
159
  self._user_id=tokens['user_id']
@@ -171,6 +172,7 @@ class Connection:
171
172
  try:
172
173
  with open(self._tokenFile, "w") as f:
173
174
  f.write(json.dumps(self._session_tokens[brand]))
175
+ f.close()
174
176
  return True
175
177
  except Exception as e:
176
178
  _LOGGER.warning(f'writeTokenFile() not successful. Error: {e}')
@@ -193,6 +195,7 @@ class Connection:
193
195
  with open(f'./www/image_{imageName}.png', "wb") as f:
194
196
  f.write(imageData)
195
197
  imageDict[imageName]=f'/local/image_{imageName}.png'
198
+ f.close()
196
199
  return True
197
200
  except:
198
201
  _LOGGER.warning('writeImageFile() not successful. Ignoring this problem.')
@@ -711,8 +711,8 @@ class DepartureTimer1(Switch):
711
711
 
712
712
  @property
713
713
  def state(self):
714
- status = self.vehicle.departure1.get("timerProgrammedStatus", "")
715
- if status == "programmed":
714
+ status = self.vehicle.departure1.get("enabled", "")
715
+ if status:
716
716
  return True
717
717
  else:
718
718
  return False
@@ -743,8 +743,8 @@ class DepartureTimer2(Switch):
743
743
 
744
744
  @property
745
745
  def state(self):
746
- status = self.vehicle.departure2.get("timerProgrammedStatus", "")
747
- if status == "programmed":
746
+ status = self.vehicle.departure2.get("enabled", "")
747
+ if status:
748
748
  return True
749
749
  else:
750
750
  return False
@@ -774,8 +774,8 @@ class DepartureTimer3(Switch):
774
774
 
775
775
  @property
776
776
  def state(self):
777
- status = self.vehicle.departure3.get("timerProgrammedStatus", "")
778
- if status == "programmed":
777
+ status = self.vehicle.departure3.get("enabled", "")
778
+ if status:
779
779
  return True
780
780
  else:
781
781
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: A library to read and send vehicle data via Cupra/Seat portal using the same API calls as the MyCupra/MySeat mobile app.
5
5
  Home-page: https://github.com/WulfgarW/pycupra
6
6
  Author: WulfgarW
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes