britkat1980 / giv_tcp

TCP connection (from inverter) and MQTT implementation
73 stars 34 forks source link

Exception converting date string to float for Charge Time Remaining #73

Closed Geheee closed 1 year ago

Geheee commented 1 year ago

Since the last few days, possibly introduced in v2.2, I have several log errors such as the following:

Exception raised when updating state of sensor.givtcp_fa**_charge_time_remaining, topic: 'GivEnergy/FA/Power/Power/Charge_Time_Remaining' with payload: b'2023-07-03T16:00:34.684064+01:00' Exception raised when updating state of sensor.givtcp_fa**_charge_time_remaining, topic: 'GivEnergy/FA/Power/Power/Charge_Time_Remaining' with payload: b'2023-07-03T16:00:46.896739+01:00' Exception raised when updating state of sensor.givtcp_fa**_charge_time_remaining, topic: 'GivEnergy/FA/Power/Power/Charge_Time_Remaining' with payload: b'2023-07-03T16:00:59.291146+01:00' Exception raised when updating state of sensor.givtcp_fa_charge_time_remaining, topic: 'GivEnergy/FA/status' with payload: b'online' Exception raised when updating state of sensor.givtcp_fa_charge_time_remaining, topic: 'GivEnergy/FA/Power/Power/Charge_Time_Remaining' with payload: b'2023-07-03T16:01:13.661348+01:00' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 583, in state numerical_value = float(value) # type:ignore[arg-type] ^^^^^^^^^^^^ ValueError: could not convert string to float: '2023-07-02T19:06:48.170542+01:00'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 270, in process_write_state_requests entity.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 585, in state raise ValueError( ValueError: Sensor sensor.givtcp_fa****_charge_time_remaining 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-07-02T19:06:48.170542+01:00' (<class 'str'>)

Looks like its unable to cast the datetime string to a float as expected...

Geheee commented 1 year ago

This looks resolved in 2.2.3 - thank you :)