carconnectivity-connector-skoda 0.1a12__py3-none-any.whl → 0.1a13__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.

Potentially problematic release.


This version of carconnectivity-connector-skoda might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: carconnectivity-connector-skoda
3
- Version: 0.1a12
3
+ Version: 0.1a13
4
4
  Summary: CarConnectivity connector for Skoda services
5
5
  Author: Till Steinbach
6
6
  License: MIT License
@@ -1,9 +1,9 @@
1
1
  carconnectivity_connectors/skoda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- carconnectivity_connectors/skoda/_version.py,sha256=LTN3-qFTXgVe28NShsxv8_1dTwqTjAScN3YtCyuR-V0,409
2
+ carconnectivity_connectors/skoda/_version.py,sha256=87o_kQQRIfRYZbD8Vrp3tNP9bKGf1QZJgBdyeWeQUXI,409
3
3
  carconnectivity_connectors/skoda/capability.py,sha256=JlNEaisVYF8qWv0wNDHTaas36uIpTIQ3NVR69wesiYQ,4513
4
4
  carconnectivity_connectors/skoda/charging.py,sha256=oDHxZxrfTMvtYCJxmGfKFeWVMH4ceQ5HTKRAspnsunU,3312
5
- carconnectivity_connectors/skoda/connector.py,sha256=QpuJ4_ZrWrrFTQPjq18UPovmUAHlylIU7_ZD3lSiuwo,62260
6
- carconnectivity_connectors/skoda/mqtt_client.py,sha256=jLduFpG-hI_XQ7LG3mbV9c2hCs3HY7JBrZmbBfm8LYk,31595
5
+ carconnectivity_connectors/skoda/connector.py,sha256=q2tnF8Q99vJUBSSqW8YngdpYvWW5tD69bVoMgQMNyz8,66387
6
+ carconnectivity_connectors/skoda/mqtt_client.py,sha256=oFyuMWchYSdu_St4VzcGsCUzsgUzYdA2_gmzbilgqL8,32105
7
7
  carconnectivity_connectors/skoda/vehicle.py,sha256=H3GRDNimMghFwFi--y9BsgoSK3pMibNf_l6SsDN6gvQ,2759
8
8
  carconnectivity_connectors/skoda/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  carconnectivity_connectors/skoda/auth/auth_util.py,sha256=dGLUbUre0HBsTg_Ii5vW34f8DLrCykYJYCyzEvUBBEE,4434
@@ -12,8 +12,8 @@ carconnectivity_connectors/skoda/auth/openid_session.py,sha256=LusWi2FZZIL3buodG
12
12
  carconnectivity_connectors/skoda/auth/session_manager.py,sha256=Uf1vujuDBYUCAXhYToOsZkgbTtfmY3Qe0ICTfwomBpI,2899
13
13
  carconnectivity_connectors/skoda/auth/skoda_web_session.py,sha256=cjzMkzx473Sh-4RgZAQULeRRcxB1MboddldCVM_y5LE,10640
14
14
  carconnectivity_connectors/skoda/auth/helpers/blacklist_retry.py,sha256=f3wsiY5bpHDBxp7Va1Mv9nKJ4u3qnCHZZmDu78_AhMk,1251
15
- carconnectivity_connector_skoda-0.1a12.dist-info/LICENSE,sha256=PIwI1alwDyOfvEQHdGCm2u9uf_mGE8030xZDfun0xTo,1071
16
- carconnectivity_connector_skoda-0.1a12.dist-info/METADATA,sha256=Wl0v7LUcmBOA7g5X-u_QjGxU9Lr8Odi87iG2lDkkrL8,5327
17
- carconnectivity_connector_skoda-0.1a12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
- carconnectivity_connector_skoda-0.1a12.dist-info/top_level.txt,sha256=KqA8GviZsDH4PtmnwSQsz0HB_w-TWkeEHLIRNo5dTaI,27
19
- carconnectivity_connector_skoda-0.1a12.dist-info/RECORD,,
15
+ carconnectivity_connector_skoda-0.1a13.dist-info/LICENSE,sha256=PIwI1alwDyOfvEQHdGCm2u9uf_mGE8030xZDfun0xTo,1071
16
+ carconnectivity_connector_skoda-0.1a13.dist-info/METADATA,sha256=Q4WodCT8EOJN6H_iS6-b0t2Jl6csXoOUnyF8dyZ15as,5327
17
+ carconnectivity_connector_skoda-0.1a13.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
+ carconnectivity_connector_skoda-0.1a13.dist-info/top_level.txt,sha256=KqA8GviZsDH4PtmnwSQsz0HB_w-TWkeEHLIRNo5dTaI,27
19
+ carconnectivity_connector_skoda-0.1a13.dist-info/RECORD,,
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1a12'
15
+ __version__ = version = '0.1a13'
16
16
  __version_tuple__ = version_tuple = (0, 1)
@@ -15,14 +15,15 @@ from carconnectivity.errors import AuthenticationError, TooManyRequestsError, Re
15
15
  TemporaryAuthenticationError, ConfigurationError
16
16
  from carconnectivity.util import robust_time_parse, log_extra_keys, config_remove_credentials
17
17
  from carconnectivity.units import Length, Speed, Power, Temperature
18
- from carconnectivity.doors import Doors
19
- from carconnectivity.windows import Windows
20
- from carconnectivity.lights import Lights
18
+ # from carconnectivity.doors import Doors
19
+ # from carconnectivity.windows import Windows
20
+ # from carconnectivity.lights import Lights
21
21
  from carconnectivity.drive import GenericDrive, ElectricDrive, CombustionDrive
22
22
  from carconnectivity.attributes import BooleanAttribute, DurationAttribute
23
23
  from carconnectivity.charging import Charging
24
24
  from carconnectivity.position import Position
25
25
  from carconnectivity.climatization import Climatization
26
+ from carconnectivity.charging_connector import ChargingConnector
26
27
 
27
28
  from carconnectivity_connectors.base.connector import BaseConnector
28
29
  from carconnectivity_connectors.skoda.auth.session_manager import SessionManager, SessionUser, Service
@@ -128,6 +129,8 @@ class Connector(BaseConnector):
128
129
  if not isinstance(session, MySkodaSession):
129
130
  raise AuthenticationError('Could not create session')
130
131
  self.session: MySkodaSession = session
132
+ self.session.retries = 3
133
+ self.session.timeout = 180
131
134
  self.session.refresh()
132
135
 
133
136
  self._elapsed: List[timedelta] = []
@@ -302,7 +305,6 @@ class Connector(BaseConnector):
302
305
  for vin in set(garage.list_vehicle_vins()):
303
306
  vehicle_to_update: Optional[GenericVehicle] = garage.get_vehicle(vin)
304
307
  if vehicle_to_update is not None and isinstance(vehicle_to_update, SkodaVehicle) and vehicle_to_update.is_managed_by_connector(self):
305
- #vehicle_to_update = self.fetch_vehicle_status_second_api(vehicle_to_update)
306
308
  vehicle_to_update = self.fetch_driving_range(vehicle_to_update)
307
309
  if vehicle_to_update.capabilities is not None and vehicle_to_update.capabilities.enabled:
308
310
  if vehicle_to_update.capabilities.has_capability('PARKING_POSITION'):
@@ -526,8 +528,42 @@ class Connector(BaseConnector):
526
528
  log_extra_keys(LOG_API, 'targetTemperature', data['outsideTemperature'], {'carCapturedTimestamp', 'temperatureUnit', 'temperatureValue'})
527
529
  else:
528
530
  vehicle.outside_temperature._set_value(value=None, measured=None, unit=Temperature.UNKNOWN) # pylint: disable=protected-access
531
+ if isinstance(vehicle, SkodaElectricVehicle):
532
+ if 'chargerConnectionState' in data and data['chargerConnectionState'] is not None \
533
+ and vehicle.charging is not None and vehicle.charging.connector is not None:
534
+ if data['chargerConnectionState'] in [item.name for item in ChargingConnector.ChargingConnectorConnectionState]:
535
+ charging_connector_state: ChargingConnector.ChargingConnectorConnectionState = \
536
+ ChargingConnector.ChargingConnectorConnectionState[data['chargerConnectionState']]
537
+ # pylint: disable-next=protected-access
538
+ vehicle.charging.connector.connection_state._set_value(value=charging_connector_state, measured=captured_at)
539
+ else:
540
+ LOG_API.info('Unkown connector state %s not in %s', data['chargerConnectionState'],
541
+ str(ChargingConnector.ChargingConnectorConnectionState))
542
+ # pylint: disable-next=protected-access
543
+ vehicle.charging.connector.connection_state._set_value(value=SkodaCharging.SkodaChargingState.UNKNOWN, measured=captured_at)
544
+ else:
545
+ # pylint: disable-next=protected-access
546
+ vehicle.charging.connector.connection_state._set_value(value=None, measured=captured_at)
547
+ if 'chargerLockState' in data and data['chargerLockState'] is not None \
548
+ and vehicle.charging is not None and vehicle.charging.connector is not None:
549
+ if data['chargerLockState'] in [item.name for item in ChargingConnector.ChargingConnectorLockState]:
550
+ charging_connector_lockstate: ChargingConnector.ChargingConnectorLockState = \
551
+ ChargingConnector.ChargingConnectorLockState[data['chargerLockState']]
552
+ # pylint: disable-next=protected-access
553
+ vehicle.charging.connector.lock_state._set_value(value=charging_connector_lockstate, measured=captured_at)
554
+ else:
555
+ LOG_API.info('Unkown connector lock state %s not in %s', data['chargerLockState'],
556
+ str(ChargingConnector.ChargingConnectorLockState))
557
+ # pylint: disable-next=protected-access
558
+ vehicle.charging.connector.lock_state._set_value(value=SkodaCharging.SkodaChargingState.UNKNOWN, measured=captured_at)
559
+ else:
560
+ # pylint: disable-next=protected-access
561
+ vehicle.charging.connector.lock_state._set_value(value=None, measured=captured_at)
562
+ if 'windowHeatingState' in data and data['windowHeatingState'] is not None:
563
+ pass
529
564
  log_extra_keys(LOG_API, 'air-condition', data, {'carCapturedTimestamp', 'state', 'estimatedDateTimeToReachTargetTemperature'
530
- 'targetTemperature', 'outsideTemperature'})
565
+ 'targetTemperature', 'outsideTemperature', 'chargerConnectionState',
566
+ 'chargerLockState'})
531
567
  return vehicle
532
568
 
533
569
  def fetch_vehicle_details(self, vehicle: SkodaVehicle, no_cache: bool = False) -> SkodaVehicle:
@@ -693,185 +729,186 @@ class Connector(BaseConnector):
693
729
  'secondaryEngineRange'})
694
730
  return vehicle
695
731
 
696
- def fetch_vehicle_status_second_api(self, vehicle: SkodaVehicle, no_cache: bool = False) -> SkodaVehicle:
697
- """
698
- Fetches the status of a vehicle from other Skoda API.
699
-
700
- Args:
701
- vehicle (GenericVehicle): The vehicle object containing the VIN.
702
-
703
- Returns:
704
- None
705
- """
706
- vin = vehicle.vin.value
707
- if vin is None:
708
- raise APIError('VIN is missing')
709
- url = f'https://api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}'
710
- vehicle_status_data: Dict[str, Any] | None = self._fetch_data(url=url, session=self.session, no_cache=no_cache)
711
- if vehicle_status_data:
712
- if 'remote' in vehicle_status_data and vehicle_status_data['remote'] is not None:
713
- vehicle_status_data = vehicle_status_data['remote']
714
- if vehicle_status_data:
715
- if 'capturedAt' in vehicle_status_data and vehicle_status_data['capturedAt'] is not None:
716
- captured_at: datetime = robust_time_parse(vehicle_status_data['capturedAt'])
717
- else:
718
- raise APIError('Could not fetch vehicle status, capturedAt missing')
719
- if 'mileageInKm' in vehicle_status_data and vehicle_status_data['mileageInKm'] is not None:
720
- vehicle.odometer._set_value(value=vehicle_status_data['mileageInKm'], measured=captured_at, unit=Length.KM) # pylint: disable=protected-access
721
- else:
722
- vehicle.odometer._set_value(value=None, measured=captured_at, unit=Length.KM) # pylint: disable=protected-access
723
- if 'status' in vehicle_status_data and vehicle_status_data['status'] is not None:
724
- if 'open' in vehicle_status_data['status'] and vehicle_status_data['status']['open'] is not None:
725
- if vehicle_status_data['status']['open'] == 'YES':
726
- vehicle.doors.open_state._set_value(Doors.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
727
- elif vehicle_status_data['status']['open'] == 'NO':
728
- vehicle.doors.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
729
- else:
730
- vehicle.doors.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
731
- LOG_API.info('Unknown door open state: %s', vehicle_status_data['status']['open'])
732
- else:
733
- vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
734
- if 'locked' in vehicle_status_data['status'] and vehicle_status_data['status']['locked'] is not None:
735
- if vehicle_status_data['status']['locked'] == 'YES':
736
- vehicle.doors.lock_state._set_value(Doors.LockState.LOCKED, measured=captured_at) # pylint: disable=protected-access
737
- elif vehicle_status_data['status']['locked'] == 'NO':
738
- vehicle.doors.lock_state._set_value(Doors.LockState.UNLOCKED, measured=captured_at) # pylint: disable=protected-access
739
- else:
740
- vehicle.doors.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
741
- LOG_API.info('Unknown door lock state: %s', vehicle_status_data['status']['locked'])
742
- else:
743
- vehicle.doors.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
744
- else:
745
- vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
746
- vehicle.doors.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
747
- if 'doors' in vehicle_status_data and vehicle_status_data['doors'] is not None:
748
- seen_door_ids: set[str] = set()
749
- for door_status in vehicle_status_data['doors']:
750
- if 'name' in door_status and door_status['name'] is not None:
751
- door_id = door_status['name']
752
- seen_door_ids.add(door_id)
753
- if door_id in vehicle.doors.doors:
754
- door: Doors.Door = vehicle.doors.doors[door_id]
755
- else:
756
- door = Doors.Door(door_id=door_id, doors=vehicle.doors)
757
- vehicle.doors.doors[door_id] = door
758
- if 'status' in door_status and door_status['status'] is not None:
759
- if door_status['status'] == 'OPEN':
760
- door.lock_state._set_value(Doors.LockState.UNLOCKED, measured=captured_at) # pylint: disable=protected-access
761
- door.open_state._set_value(Doors.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
762
- elif door_status['status'] == 'CLOSED':
763
- door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
764
- door.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
765
- elif door_status['status'] == 'LOCKED':
766
- door.lock_state._set_value(Doors.LockState.LOCKED, measured=captured_at) # pylint: disable=protected-access
767
- door.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
768
- elif door_status['status'] == 'UNSUPPORTED':
769
- door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
770
- door.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
771
- else:
772
- LOG_API.info('Unknown door status %s', door_status['status'])
773
- door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
774
- door.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
775
- else:
776
- door.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
777
- door.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
778
- else:
779
- raise APIError('Could not parse door, name missing')
780
- log_extra_keys(LOG_API, 'doors', door_status, {'name', 'status'})
781
- for door_to_remove in set(vehicle.doors.doors) - seen_door_ids:
782
- vehicle.doors.doors[door_to_remove].enabled = False
783
- vehicle.doors.doors.pop(door_to_remove)
784
- log_extra_keys(LOG_API, 'status', vehicle_status_data['status'], {'open', 'locked'})
785
- else:
786
- vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
787
- vehicle.doors.doors = {}
788
- if 'windows' in vehicle_status_data and vehicle_status_data['windows'] is not None:
789
- seen_window_ids: set[str] = set()
790
- all_windows_closed: bool = True
791
- for window_status in vehicle_status_data['windows']:
792
- if 'name' in window_status and window_status['name'] is not None:
793
- window_id = window_status['name']
794
- seen_window_ids.add(window_id)
795
- if window_id in vehicle.windows.windows:
796
- window: Windows.Window = vehicle.windows.windows[window_id]
797
- else:
798
- window = Windows.Window(window_id=window_id, windows=vehicle.windows)
799
- vehicle.windows.windows[window_id] = window
800
- if 'status' in window_status and window_status['status'] is not None:
801
- if window_status['status'] == 'OPEN':
802
- all_windows_closed = False
803
- window.open_state._set_value(Windows.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
804
- elif window_status['status'] == 'CLOSED':
805
- window.open_state._set_value(Windows.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
806
- elif window_status['status'] == 'UNSUPPORTED':
807
- window.open_state._set_value(Windows.OpenState.UNSUPPORTED, measured=captured_at) # pylint: disable=protected-access
808
- elif window_status['status'] == 'INVALID':
809
- window.open_state._set_value(Windows.OpenState.INVALID, measured=captured_at) # pylint: disable=protected-access
810
- else:
811
- LOG_API.info('Unknown window status %s', window_status['status'])
812
- window.open_state._set_value(Windows.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
813
- else:
814
- window.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
815
- else:
816
- raise APIError('Could not parse window, name missing')
817
- log_extra_keys(LOG_API, 'doors', window_status, {'name', 'status'})
818
- for window_to_remove in set(vehicle.windows.windows) - seen_window_ids:
819
- vehicle.windows.windows[window_to_remove].enabled = False
820
- vehicle.windows.windows.pop(window_to_remove)
821
- if all_windows_closed:
822
- vehicle.windows.open_state._set_value(Windows.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
823
- else:
824
- vehicle.windows.open_state._set_value(Windows.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
825
- else:
826
- vehicle.windows.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
827
- vehicle.windows.windows = {}
828
- if 'lights' in vehicle_status_data and vehicle_status_data['lights'] is not None:
829
- seen_light_ids: set[str] = set()
830
- if 'overallStatus' in vehicle_status_data['lights'] and vehicle_status_data['lights']['overallStatus'] is not None:
831
- if vehicle_status_data['lights']['overallStatus'] == 'ON':
832
- vehicle.lights.light_state._set_value(Lights.LightState.ON, measured=captured_at) # pylint: disable=protected-access
833
- elif vehicle_status_data['lights']['overallStatus'] == 'OFF':
834
- vehicle.lights.light_state._set_value(Lights.LightState.OFF, measured=captured_at) # pylint: disable=protected-access
835
- elif vehicle_status_data['lights']['overallStatus'] == 'INVALID':
836
- vehicle.lights.light_state._set_value(Lights.LightState.INVALID, measured=captured_at) # pylint: disable=protected-access
837
- else:
838
- LOG_API.info('Unknown light status %s', vehicle_status_data['lights']['overallStatus'])
839
- vehicle.lights.light_state._set_value(Lights.LightState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
840
- else:
841
- vehicle.lights.light_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
842
- if 'lightsStatus' in vehicle_status_data['lights'] and vehicle_status_data['lights']['lightsStatus'] is not None:
843
- for light_status in vehicle_status_data['lights']['lightsStatus']:
844
- if 'name' in light_status and light_status['name'] is not None:
845
- light_id: str = light_status['name']
846
- seen_light_ids.add(light_id)
847
- if light_id in vehicle.lights.lights:
848
- light: Lights.Light = vehicle.lights.lights[light_id]
849
- else:
850
- light = Lights.Light(light_id=light_id, lights=vehicle.lights)
851
- vehicle.lights.lights[light_id] = light
852
- if 'status' in light_status and light_status['status'] is not None:
853
- if light_status['status'] == 'ON':
854
- light.light_state._set_value(Lights.LightState.ON, measured=captured_at) # pylint: disable=protected-access
855
- elif light_status['status'] == 'OFF':
856
- light.light_state._set_value(Lights.LightState.OFF, measured=captured_at) # pylint: disable=protected-access
857
- elif light_status['status'] == 'INVALID':
858
- light.light_state._set_value(Lights.LightState.INVALID, measured=captured_at) # pylint: disable=protected-access
859
- else:
860
- LOG_API.info('Unknown light status %s', light_status['status'])
861
- light.light_state._set_value(Lights.LightState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
862
- else:
863
- light.light_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
864
- else:
865
- raise APIError('Could not parse light, name missing')
866
- log_extra_keys(LOG_API, 'lights', light_status, {'name', 'status'})
867
- for light_to_remove in set(vehicle.lights.lights) - seen_light_ids:
868
- vehicle.lights.lights[light_to_remove].enabled = False
869
- vehicle.lights.lights.pop(light_to_remove)
870
- else:
871
- vehicle.lights.lights = {}
872
- log_extra_keys(LOG_API, 'lights', vehicle_status_data['lights'], {'overallStatus', 'lightsStatus'})
873
- log_extra_keys(LOG_API, 'vehicles', vehicle_status_data, {'capturedAt', 'mileageInKm', 'status', 'doors', 'windows', 'lights'})
874
- return vehicle
732
+ # def fetch_vehicle_status_second_api(self, vehicle: SkodaVehicle, no_cache: bool = False) -> SkodaVehicle:
733
+ # """
734
+ # Fetches the status of a vehicle from other Skoda API.
735
+ #
736
+ # Args:
737
+ # vehicle (GenericVehicle): The vehicle object containing the VIN.
738
+ #
739
+ # Returns:
740
+ # None
741
+ # """
742
+ # vin = vehicle.vin.value
743
+ # if vin is None:
744
+ # raise APIError('VIN is missing')
745
+ # url = f'https://api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}'
746
+ # vehicle_status_data: Dict[str, Any] | None = self._fetch_data(url=url, session=self.session, no_cache=no_cache)
747
+ # if vehicle_status_data:
748
+ # if 'remote' in vehicle_status_data and vehicle_status_data['remote'] is not None:
749
+ # vehicle_status_data = vehicle_status_data['remote']
750
+ # if vehicle_status_data:
751
+ # if 'capturedAt' in vehicle_status_data and vehicle_status_data['capturedAt'] is not None:
752
+ # captured_at: datetime = robust_time_parse(vehicle_status_data['capturedAt'])
753
+ # else:
754
+ # raise APIError('Could not fetch vehicle status, capturedAt missing')
755
+ # if 'mileageInKm' in vehicle_status_data and vehicle_status_data['mileageInKm'] is not None:
756
+ # # pylint: disable-next=protected-access
757
+ # vehicle.odometer._set_value(value=vehicle_status_data['mileageInKm'], measured=captured_at, unit=Length.KM)
758
+ # else:
759
+ # vehicle.odometer._set_value(value=None, measured=captured_at, unit=Length.KM) # pylint: disable=protected-access
760
+ # if 'status' in vehicle_status_data and vehicle_status_data['status'] is not None:
761
+ # if 'open' in vehicle_status_data['status'] and vehicle_status_data['status']['open'] is not None:
762
+ # if vehicle_status_data['status']['open'] == 'YES':
763
+ # vehicle.doors.open_state._set_value(Doors.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
764
+ # elif vehicle_status_data['status']['open'] == 'NO':
765
+ # vehicle.doors.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
766
+ # else:
767
+ # vehicle.doors.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
768
+ # LOG_API.info('Unknown door open state: %s', vehicle_status_data['status']['open'])
769
+ # else:
770
+ # vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
771
+ # if 'locked' in vehicle_status_data['status'] and vehicle_status_data['status']['locked'] is not None:
772
+ # if vehicle_status_data['status']['locked'] == 'YES':
773
+ # vehicle.doors.lock_state._set_value(Doors.LockState.LOCKED, measured=captured_at) # pylint: disable=protected-access
774
+ # elif vehicle_status_data['status']['locked'] == 'NO':
775
+ # vehicle.doors.lock_state._set_value(Doors.LockState.UNLOCKED, measured=captured_at) # pylint: disable=protected-access
776
+ # else:
777
+ # vehicle.doors.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
778
+ # LOG_API.info('Unknown door lock state: %s', vehicle_status_data['status']['locked'])
779
+ # else:
780
+ # vehicle.doors.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
781
+ # else:
782
+ # vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
783
+ # vehicle.doors.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
784
+ # if 'doors' in vehicle_status_data and vehicle_status_data['doors'] is not None:
785
+ # seen_door_ids: set[str] = set()
786
+ # for door_status in vehicle_status_data['doors']:
787
+ # if 'name' in door_status and door_status['name'] is not None:
788
+ # door_id = door_status['name']
789
+ # seen_door_ids.add(door_id)
790
+ # if door_id in vehicle.doors.doors:
791
+ # door: Doors.Door = vehicle.doors.doors[door_id]
792
+ # else:
793
+ # door = Doors.Door(door_id=door_id, doors=vehicle.doors)
794
+ # vehicle.doors.doors[door_id] = door
795
+ # if 'status' in door_status and door_status['status'] is not None:
796
+ # if door_status['status'] == 'OPEN':
797
+ # door.lock_state._set_value(Doors.LockState.UNLOCKED, measured=captured_at) # pylint: disable=protected-access
798
+ # door.open_state._set_value(Doors.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
799
+ # elif door_status['status'] == 'CLOSED':
800
+ # door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
801
+ # door.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
802
+ # elif door_status['status'] == 'LOCKED':
803
+ # door.lock_state._set_value(Doors.LockState.LOCKED, measured=captured_at) # pylint: disable=protected-access
804
+ # door.open_state._set_value(Doors.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
805
+ # elif door_status['status'] == 'UNSUPPORTED':
806
+ # door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
807
+ # door.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
808
+ # else:
809
+ # LOG_API.info('Unknown door status %s', door_status['status'])
810
+ # door.lock_state._set_value(Doors.LockState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
811
+ # door.open_state._set_value(Doors.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
812
+ # else:
813
+ # door.lock_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
814
+ # door.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
815
+ # else:
816
+ # raise APIError('Could not parse door, name missing')
817
+ # log_extra_keys(LOG_API, 'doors', door_status, {'name', 'status'})
818
+ # for door_to_remove in set(vehicle.doors.doors) - seen_door_ids:
819
+ # vehicle.doors.doors[door_to_remove].enabled = False
820
+ # vehicle.doors.doors.pop(door_to_remove)
821
+ # log_extra_keys(LOG_API, 'status', vehicle_status_data['status'], {'open', 'locked'})
822
+ # else:
823
+ # vehicle.doors.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
824
+ # vehicle.doors.doors = {}
825
+ # if 'windows' in vehicle_status_data and vehicle_status_data['windows'] is not None:
826
+ # seen_window_ids: set[str] = set()
827
+ # all_windows_closed: bool = True
828
+ # for window_status in vehicle_status_data['windows']:
829
+ # if 'name' in window_status and window_status['name'] is not None:
830
+ # window_id = window_status['name']
831
+ # seen_window_ids.add(window_id)
832
+ # if window_id in vehicle.windows.windows:
833
+ # window: Windows.Window = vehicle.windows.windows[window_id]
834
+ # else:
835
+ # window = Windows.Window(window_id=window_id, windows=vehicle.windows)
836
+ # vehicle.windows.windows[window_id] = window
837
+ # if 'status' in window_status and window_status['status'] is not None:
838
+ # if window_status['status'] == 'OPEN':
839
+ # all_windows_closed = False
840
+ # window.open_state._set_value(Windows.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
841
+ # elif window_status['status'] == 'CLOSED':
842
+ # window.open_state._set_value(Windows.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
843
+ # elif window_status['status'] == 'UNSUPPORTED':
844
+ # window.open_state._set_value(Windows.OpenState.UNSUPPORTED, measured=captured_at) # pylint: disable=protected-access
845
+ # elif window_status['status'] == 'INVALID':
846
+ # window.open_state._set_value(Windows.OpenState.INVALID, measured=captured_at) # pylint: disable=protected-access
847
+ # else:
848
+ # LOG_API.info('Unknown window status %s', window_status['status'])
849
+ # window.open_state._set_value(Windows.OpenState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
850
+ # else:
851
+ # window.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
852
+ # else:
853
+ # raise APIError('Could not parse window, name missing')
854
+ # log_extra_keys(LOG_API, 'doors', window_status, {'name', 'status'})
855
+ # for window_to_remove in set(vehicle.windows.windows) - seen_window_ids:
856
+ # vehicle.windows.windows[window_to_remove].enabled = False
857
+ # vehicle.windows.windows.pop(window_to_remove)
858
+ # if all_windows_closed:
859
+ # vehicle.windows.open_state._set_value(Windows.OpenState.CLOSED, measured=captured_at) # pylint: disable=protected-access
860
+ # else:
861
+ # vehicle.windows.open_state._set_value(Windows.OpenState.OPEN, measured=captured_at) # pylint: disable=protected-access
862
+ # else:
863
+ # vehicle.windows.open_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
864
+ # vehicle.windows.windows = {}
865
+ # if 'lights' in vehicle_status_data and vehicle_status_data['lights'] is not None:
866
+ # seen_light_ids: set[str] = set()
867
+ # if 'overallStatus' in vehicle_status_data['lights'] and vehicle_status_data['lights']['overallStatus'] is not None:
868
+ # if vehicle_status_data['lights']['overallStatus'] == 'ON':
869
+ # vehicle.lights.light_state._set_value(Lights.LightState.ON, measured=captured_at) # pylint: disable=protected-access
870
+ # elif vehicle_status_data['lights']['overallStatus'] == 'OFF':
871
+ # vehicle.lights.light_state._set_value(Lights.LightState.OFF, measured=captured_at) # pylint: disable=protected-access
872
+ # elif vehicle_status_data['lights']['overallStatus'] == 'INVALID':
873
+ # vehicle.lights.light_state._set_value(Lights.LightState.INVALID, measured=captured_at) # pylint: disable=protected-access
874
+ # else:
875
+ # LOG_API.info('Unknown light status %s', vehicle_status_data['lights']['overallStatus'])
876
+ # vehicle.lights.light_state._set_value(Lights.LightState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
877
+ # else:
878
+ # vehicle.lights.light_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
879
+ # if 'lightsStatus' in vehicle_status_data['lights'] and vehicle_status_data['lights']['lightsStatus'] is not None:
880
+ # for light_status in vehicle_status_data['lights']['lightsStatus']:
881
+ # if 'name' in light_status and light_status['name'] is not None:
882
+ # light_id: str = light_status['name']
883
+ # seen_light_ids.add(light_id)
884
+ # if light_id in vehicle.lights.lights:
885
+ # light: Lights.Light = vehicle.lights.lights[light_id]
886
+ # else:
887
+ # light = Lights.Light(light_id=light_id, lights=vehicle.lights)
888
+ # vehicle.lights.lights[light_id] = light
889
+ # if 'status' in light_status and light_status['status'] is not None:
890
+ # if light_status['status'] == 'ON':
891
+ # light.light_state._set_value(Lights.LightState.ON, measured=captured_at) # pylint: disable=protected-access
892
+ # elif light_status['status'] == 'OFF':
893
+ # light.light_state._set_value(Lights.LightState.OFF, measured=captured_at) # pylint: disable=protected-access
894
+ # elif light_status['status'] == 'INVALID':
895
+ # light.light_state._set_value(Lights.LightState.INVALID, measured=captured_at) # pylint: disable=protected-access
896
+ # else:
897
+ # LOG_API.info('Unknown light status %s', light_status['status'])
898
+ # light.light_state._set_value(Lights.LightState.UNKNOWN, measured=captured_at) # pylint: disable=protected-access
899
+ # else:
900
+ # light.light_state._set_value(None, measured=captured_at) # pylint: disable=protected-access
901
+ # else:
902
+ # raise APIError('Could not parse light, name missing')
903
+ # log_extra_keys(LOG_API, 'lights', light_status, {'name', 'status'})
904
+ # for light_to_remove in set(vehicle.lights.lights) - seen_light_ids:
905
+ # vehicle.lights.lights[light_to_remove].enabled = False
906
+ # vehicle.lights.lights.pop(light_to_remove)
907
+ # else:
908
+ # vehicle.lights.lights = {}
909
+ # log_extra_keys(LOG_API, 'lights', vehicle_status_data['lights'], {'overallStatus', 'lightsStatus'})
910
+ # log_extra_keys(LOG_API, 'vehicles', vehicle_status_data, {'capturedAt', 'mileageInKm', 'status', 'doors', 'windows', 'lights'})
911
+ # return vehicle
875
912
 
876
913
  def _record_elapsed(self, elapsed: timedelta) -> None:
877
914
  """
@@ -20,6 +20,7 @@ from carconnectivity.vehicle import GenericVehicle
20
20
  from carconnectivity.drive import ElectricDrive
21
21
  from carconnectivity.util import robust_time_parse, log_extra_keys
22
22
  from carconnectivity.charging import Charging
23
+ from carconnectivity.climatization import Climatization
23
24
 
24
25
  from carconnectivity_connectors.skoda.vehicle import SkodaVehicle, SkodaElectricVehicle
25
26
  from carconnectivity_connectors.skoda.charging import SkodaCharging, mapping_skoda_charging_state
@@ -514,6 +515,14 @@ class SkodaMQTTClient(Client): # pylint: disable=too-many-instance-attributes
514
515
  self._skoda_connector.fetch_air_conditioning(vehicle, no_cache=True)
515
516
  except CarConnectivityError as e:
516
517
  LOG.error('Error while fetching charging: %s', e)
518
+ elif 'name' in data and data['name'] == 'climatisation-completed':
519
+ if 'data' in data and data['data'] is not None:
520
+ vehicle: Optional[GenericVehicle] = self._skoda_connector.car_connectivity.garage.get_vehicle(vin)
521
+ if vehicle is not None and vehicle.climatization is not None:
522
+ # pylint: disable-next=protected-access
523
+ vehicle.climatization.state._set_value(value=Climatization.ClimatizationState.OFF, measured=measured_at)
524
+ # pylint: disable-next=protected-access
525
+ vehicle.climatization.estimated_date_reached._set_value(value=measured_at, measured=measured_at)
517
526
  LOG_API.info('Received event name %s service event %s for vehicle %s from user %s: %s', data['name'],
518
527
  service_event, vin, user_id, msg.payload)
519
528
  return
@@ -546,10 +555,6 @@ class SkodaMQTTClient(Client): # pylint: disable=too-many-instance-attributes
546
555
  self._skoda_connector.fetch_air_conditioning(vehicle, no_cache=True)
547
556
  except CarConnectivityError as e:
548
557
  LOG.error('Error while fetching air conditioning: %s', e)
549
- #try:
550
- # self._skoda_connector.fetch_vehicle_status_second_api(vehicle, no_cache=True)
551
- #except CarConnectivityError as e:
552
- # LOG.error('Error while fetching status second API: %s', e)
553
558
 
554
559
  if vin in self.delayed_access_function_timers:
555
560
  self.delayed_access_function_timers[vin].cancel()