home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

Volvo On Call sensor last_trip has device class None #91113

Closed swa72 closed 1 year ago

swa72 commented 1 year ago

The problem

Warning in Logs (only sensor that gets warning

Sensor sensor.su_XXXX_last_trip has device class None, state class None and unit thus indicating it has a numeric value; however, it has the non-numeric value: 2023-04-08 15:53:36+02:00 (<class 'datetime.datetime'>); Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?

What version of Home Assistant Core has the issue?

core-2023.4.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Patrick-UK commented 1 year ago

I can confirm seeing this also since update this morning.

home-assistant[bot] commented 1 year ago

Hey there @molobrakos, mind taking a look at this issue as it has been labeled with an integration (volvooncall) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `volvooncall` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign volvooncall` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


volvooncall documentation volvooncall source (message by IssueLinks)

uspino2 commented 1 year ago

Same issue here.

dvhub commented 1 year ago

Same problem for me.

koying commented 1 year ago

Updated to 2023.5 and get the following exception. I actually think it was working on 2023.4

2023-05-06 10:29:07.403 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 581, in state
    numerical_value = float(value)  # type:ignore[arg-type]
TypeError: float() argument must be a string or a real number, not 'datetime.datetime'

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 "/usr/src/homeassistant/homeassistant/components/volvooncall/sensor.py", line 74, in _handle_coordinator_update
    self.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.<plate>_last_trip 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-01 20:03:44+02:00 (<class 'datetime.datetime'>)
robingemmill commented 1 year ago

Same problem for me. HA 2023.5.2. Seems to fix itself for a while after reloading the integration, but then fails again

bakerkj commented 1 year ago

I am seeing the same problem with 2023.5.2.

robingemmill commented 1 year ago

Seems that the problem with "sensor.[plate]_last_trip" is preventing the integration from running properly once loaded. So I disabled that sensor in the VOC integration and so far the integration has stayed up. I know it's only a work-around, but I don't need to see last_trip.

stefanodesjo commented 1 year ago

I've created this PR, that probably will handle this.

decompil3d commented 1 year ago

Also being discussed in #92746. I've merged your PR into my own that does a more holistic fix. Just waiting for GitHub Actions to stop being broken (it's broadly down right now apparently) and then I can publish and bring the fix into HA core.