robinostlund / homeassistant-volkswagencarnet

Volkswagen Carnet Component for home assistant
GNU General Public License v3.0
340 stars 63 forks source link

[BUG] Can only set up one car out of two #614

Closed stigvi closed 6 months ago

stigvi commented 7 months ago

Before you post a new issue - you must first check the following (and check the boxes with an "X" below)

Environment

Describe the bug

It seems that the integration can retrieve data for only one car. After restarting HA, sometimes e-Golf is OK , but all data for GTE is missing. And somtimes the other way, Passat GTE is OK, but e-Golf data is missing.

Steps to Reproduce

Expected behavior

Screenshots

Traceback/Error logs

2024-05-02 08:03:27.825 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up volkswagencarnet platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/volkswagencarnet/sensor.py", line 31, in async_setup_entry
    data = hass.data[DOMAIN][entry.entry_id][DATA]
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'c8a6b6ad8exxxxxxxxxxxx749c666764c'
2024-05-02 08:03:27.827 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up volkswagencarnet platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/volkswagencarnet/binary_sensor.py", line 29, in async_setup_entry
    data = hass.data[DOMAIN][entry.entry_id][DATA]
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'c8a6b6ad8exxxxxxxxxxxxxxx749c666764c'
2024-05-02 08:03:27.829 ERROR (MainThread) [homeassistant.components.number] Error while setting up volkswagencarnet platform for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/volkswagencarnet/number.py", line 27, in async_setup_entry
    data = hass.data[DOMAIN][entry.entry_id][DATA]
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'c8a6b6ad8exxxxxxxxxxxxxxx749c666764c'
2024-05-02 08:03:27.830 ERROR (MainThread) [homeassistant.components.device_tracker] Error while setting up volkswagencarnet platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/volkswagencarnet/device_tracker.py", line 20, in async_setup_entry
    data = hass.data[DOMAIN][entry.entry_id][DATA]
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'c8a6b6ad8exxxxxxxxxxxxxxx749c666764c'
2024-05-02 08:03:27.831 ERROR (MainThread) [homeassistant.components.switch] Error while setting up volkswagencarnet platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/volkswagencarnet/switch.py", line 23, in async_setup_entry
    data = hass.data[DOMAIN][entry.entry_id][DATA]
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'c8a6b6ad8exxxxxxxxxxxx749c666764c'

Debug information - all JSON responses from logfile

Additional context

Note

Issues lacking sufficient details or context may be subject to closure without prior notice. Detailed bug reports are essential for effective issue resolution. Thank you for your cooperation.

gmp91 commented 7 months ago

Same here, since this morning. (as far as I can tell) At first both cars were missing all data, but after a restart one car has data, the other one not

kl1127 commented 7 months ago

Same here

stickpin commented 7 months ago

Hi All,

Yes, there is a known issue with the multiple vehicles under one account. I am aware of it, I just need to find some time to debug it.

stickpin commented 7 months ago

Fixed with v4.6.2

kl1127 commented 7 months ago

Just updated to 4.6.2 along with an update of core to 2024.5.1 and did a restart.

Same issue still applies, though it is now the car that did not work before that works and the one that worked that does not, like in the bug description, I imagine.

stickpin commented 7 months ago

@kl1127 with all the different combinations of the accounts that I can think of, I was not able to reproduce it anymore. Please enable and share the debug logging following this guidance: https://github.com/robinostlund/homeassistant-volkswagencarnet/wiki/Enabling-Debug-Logging-in-Home-Assistant

stickpin commented 6 months ago

I've managed to reproduce this issue and this is a new one. I've fixed another issue with multiple vehicles, not this one. Something has been changed in HA 2024.5.x that I am not aware of... Not sure how to fix it yet.

stickpin commented 6 months ago

It seems to be related to this change: https://developers.home-assistant.io/blog/2024/04/30/store-runtime-data-inside-config-entry

virtualdj commented 6 months ago

It seems to be related to this change: https://developers.home-assistant.io/blog/2024/04/30/store-runtime-data-inside-config-entry

@stickpin But this is a new feature as far as I understand, so it should not break the existing use of the ConfigEntry to store the data. Documentation is still poor, unfortunately.

stickpin commented 6 months ago

@virtualdj yes.. have no clue yet what is breaking it.

stickpin commented 6 months ago

Found the issue. :) I have to run now... Spend too much time on something that stupid. :) I will release the fix tonight or tomorrow morning. :)

stickpin commented 6 months ago

Please try v4.6.3. The bug should be fixed now.

P356c commented 6 months ago

Thanks @stickpin works like a charm again!

stickpin commented 6 months ago

@P356c thanks for the confirmation! :)