[BUG] Error after upgrading to Home Assistant 2023.5.0
Closed this issue ยท 20 comments
Before you post a new issue - you must first check the following (and check the boxes with an "X" below)
- 1.) Can you login using the smartphone app We Connect (not We Connect ID or We Connect GO) and interact with your car?
- 2.) Please make sure that you can login into https://vwid.vwgroup.io/ and make sure that any "Terms and Conditions" are all checked
- 3.) I do not have MFA enabled.
Environment
- Volkswagencarnet release with the issue:
- Last working homeassistant-volkswagencarnet release (if known):
- Home Assistant Core release with the issue:
- Operating environment (Home Assistant OS/Supervised/Container/Core/venv):
- Car model and year:
- Country where the car was bought:
- Valid We Connect subscription:
- Have you verified that the We Connect service works via VWยดs portal?:
Describe the bug
After the latest Home Assistant upgrade (2023.5.0), the "datetime" values are no longer shown.
Steps to Reproduce
Expected behavior
Screenshots
Traceback/Error logs
2023-05-04 08:18:48.562 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 579, in state
numerical_value = int(value)
ValueError: invalid literal for int() with base 10: '2023-05-03 16:25:33'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 204, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 349, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 146, in async_update_listeners
update_callback()
File "/config/custom_components/volkswagencarnet/__init__.py", line 344, in async_write_ha_state
or str(self.state or STATE_UNKNOWN) != str(prev.state)
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 583, in state
raise ValueError(
ValueError: Sensor sensor.vw_touran_parking_time has device class None, state class None unit and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: 2023-05-03 16:25:33 (<class 'str'>)
Debug information - all JSON responses from logfile
Additional context
There are many complaints on HA Git about similar issue:
- home-assistant/core#92523
- home-assistant/core#92483
- home-assistant/core#92479
- home-assistant/core#92322
- home-assistant/core#92496
Let's see what HA Devs will say about it.
I'm also seeing issues after upgrading to 2023.5.0. Sensors like sensor.{car_id}_battery_level
are no longer updated. Only when restarting HA (or reloading the integration) the sensor state is updated.
I've submitted the fix: #475
If you don't want to wait for the merge just edit the sensor.py file inside the integration folder (/config/custom_components/volkswagencarnet/sensor.py).
Change this code:
@property
def _attr_native_unit_of_measurement(self):
"""Return the unit of measurement."""
return self.instrument.unit
To this code:
@property
def _attr_native_unit_of_measurement(self):
"""Return the unit of measurement."""
if self.instrument.unit:
return self.instrument.unit
Thank you stickpin! all good with your fix.
only sensor.vw_charger_max_ampere [unavail] to go since 2023.5.0. update
Thanks
Thanks for the quick fix. I do have one more sensor which is still not working besided the max_ampere sensor:
sensor.volkswagen_charging_time_left
Sorry, I don't have E-VW, so I cannot debug it properly on my end. :(
If I can help you debugging, please let me know.
Same here. Sensors not updating without reloading integration. Only battery level is working. So I have maximum range with 0% battery sometimes. :) Remote climatisation works but switch won't stay toggled and therefore unable to turn climatisation off again.
Also missing sensor charging time left. Using latest version.
I'm also having the same issues even after patching to version v4.4.60
Here is a stack trace of the error that causes the Charging Time Left sensor to not be displayed correctly:
Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:583
Integration: Sensor (documentation, issues)
First occurred: 07:40:15 (4 occurrences)
Last logged: 11:19:24
Error adding entities for domain sensor with platform volkswagencarnet
Error while setting up volkswagencarnet platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 579, in state
numerical_value = int(value)
ValueError: invalid literal for int() with base 10: '10:30'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 846, in add_to_platform_finish
self.async_write_ha_state()
File "/config/custom_components/volkswagencarnet/__init__.py", line 346, in async_write_ha_state
super().async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 583, in state
raise ValueError(
ValueError: Sensor sensor.e_up_charging_time_left has device class None, state class None unit h and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: 10:30 (<class 'str'>)
well, as far as I can see, there are two approaches to solving this:
- To update the HA plugging to exclude those two sensors inside the _attr_native_unit_of_measurement function. Which I guess gonna be a bit ugly.
- To update the Python library to pass empty units for not int sensors. This approach may break some other integrations except HA: https://github.com/robinostlund/volkswagencarnet/blob/master/volkswagencarnet/vw_dashboard.py
@robinostlund what is your opinion?
@stickpin i suggest to update the vw_dashboad.py in volkswagencarnet as that is only used for the home assistant integration ๐ , thanks for helping out, i don't have a car with weconnect anymore so i appreciate all the help i can get ๐
@robinostlund thanks! :)
I've pushed the fix: robinostlund/volkswagencarnet#202
@stickpin lovely, i will release a new version of the library, can you do a PR to this repo and update the version in this file once it is released? :)
https://github.com/robinostlund/homeassistant-volkswagencarnet/blob/master/requirements.txt
@robinostlund sure, will do. :)
@robinostlund PR created: #477
:)
All working fine again after latest update. Thanks!
Thank you so much stickpin and team. Legends.
Thank you very much!!