skodaconnect / homeassistant-myskoda

Homeassistant integration for MySkoda.
96 stars 15 forks source link

Error after installation #84

Closed johnvanderster closed 1 month ago

johnvanderster commented 1 month ago

Describe the bug After installation, restart, add integration and login this error: Field "charger_lock_state" of type Optional[ChargerLockedState] in AirConditioning has invalid value 'INVALID'

**Is this working in MySkoda app?*** NA I think. App working.

Latest working release Fresh install 1.45

Debug logs Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.myskoda.coordinator Bron: helpers/update_coordinator.py:354 integratie: MySkoda (documentatie, problemen) Eerst voorgekomen: 18:44:45 (21 gebeurtenissen) Laatst gelogd: 19:09:30

Unexpected error fetching myskoda data Traceback (most recent call last): File "", line 62, in mashumaro_from_json File "/usr/local/lib/python3.12/enum.py", line 757, in call return cls.new(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 1171, in new raise ve_exc ValueError: 'INVALID' is not a valid ChargerLockedState

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/myskoda/coordinator.py", line 82, in _async_update_data vehicle = await self.myskoda.get_vehicle(self.vin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/myskoda/myskoda.py", line 239, in get_vehicle vehicle.air_conditioning = await self.get_air_conditioning(vin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/myskoda/myskoda.py", line 197, in get_air_conditioning return await self.rest_api.get_air_conditioning(vin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 68, in get_air_conditioning return await self._make_get_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 42, in _make_get_request data = deserialize(response_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 64, in mashumaro_from_json mashumaro.exceptions.InvalidFieldValue: Field "charger_lock_state" of type Optional[ChargerLockedState] in AirConditioning has invalid value 'INVALID'

Installation:

Additional context

WebSpider commented 1 month ago

Thanks for this report. What car is connected to your account?

johnvanderster commented 1 month ago

Ah, sorry. A 2024 PHEV Skoda Kodiaq II

dvx76 commented 1 month ago

@WebSpider what should we map this to? We can add INVALID to the enum, but what should the behavior be on the sensor (ChargerLocked)? Unknown or unavailable?

WebSpider commented 1 month ago

I guess that depends on what the value maps to in reality. @johnvanderster can your car lock the charge cable?

johnvanderster commented 1 month ago

Yes, car can lock the charge cable (default = locks)

WebSpider commented 1 month ago

I think i encountered this state in real life: my charge cable was locked in the car, and the car could not unlock it.

I think the best translation here is 'Unknown'

dvx76 commented 1 month ago

Ok so for the ChargerLockedState I think we just use the actual value, since it's HA-agnostic. So just ChargerLockedState.INVALID.

Then in the ChargerLocked entity ... based on your description above we could use it to have a is_jammed property return True (see https://developers.home-assistant.io/docs/core/entity/lock), or if we want to mark the entity as temporarily unavailable, I'm not sure what the 'correct' way to do it is? Just have a available property return False if ChargerLockedState.INVALID?

WebSpider commented 1 month ago

I like the is_jammed 😆

dvx76 commented 1 month ago

As per this comment from Prior99 returning None would have HA show the sensor as Unavailable, so that's also an option.