You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading Home Assistant to 2023.5 I now get a ValueError: could not convert string to float: 'No Departures'
Complete output from log is below:
Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:583
Integration: Sensor (documentation, issues)
First occurred: 18:55:38 (2 occurrences)
Last logged: 18:55:38
Error adding entities for domain sensor with platform realtime_trains_api
Error while setting up realtime_trains_api platform for sensor
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]
ValueError: could not convert string to float: 'No Departures'
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 "/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.next_train_from_ips_to_lst has device class None, state class None unit min and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: No Departures (<class 'str'>)
The text was updated successfully, but these errors were encountered:
I replaced the following code in sensor.py at lines 203 and 204:
if nextDepartureEstimatedTs is None:
self._state = "No Departures"
with
if nextDepartureEstimatedTs is None:
self._state = "0"
and I no longer get the error. There is probably a more elegant way of doing this, but the integration now runs without errors. However instead of showing "No departures" it now looks like this.
After upgrading Home Assistant to 2023.5 I now get a
ValueError: could not convert string to float: 'No Departures'
Complete output from log is below:
The text was updated successfully, but these errors were encountered: