core icon indicating copy to clipboard operation
core copied to clipboard

ValueError: could not convert string to float: 'None' -Google Assistant

Open Anto79-ops opened this issue 3 years ago • 3 comments

The problem

Hi

recently, this message has been flooding my logs, several times an hour

I use Nabu Casa to manage my entities to Google Assistant.

Sounds like one of my temperature sensors is none, and it doesn't like it. Maybe it does not handle none properly?

Logger: homeassistant
Source: components/google_assistant/trait.py:848
First occurred: 9:26:38 PM (3 occurrences)
Last logged: 9:32:52 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 75, in async_entity_state_listener
    entity_data = entity.query_serialize()
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 663, in query_serialize
    deep_update(attrs, trt.query_attributes())
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 848, in query_attributes
    temp = round(temp_util.convert(float(current_temp), unit, TEMP_CELSIUS), 1)
ValueError: could not convert string to float: 'None'

What version of Home Assistant Core has the issue?

Home Assistant 2022.9.5 (and earlier)

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Google Assistant

Link to integration documentation on our website

https://www.home-assistant.io/integrations/google_assistant/

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

Anto79-ops avatar Sep 20 '22 03:09 Anto79-ops

Hey there @home-assistant/cloud, mind taking a look at this issue as it has been labeled with an integration (google_assistant) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Looks like an integration is pushing the wrong info to the state machine. What integration provides this?

balloob avatar Sep 20 '22 21:09 balloob

@balloob and @emontnemery thanks, put the logs on debug, it could be an Mqtt integration for a windchill sensor

new_state=<state sensor.windchill_2=None

below. If you can confirm, I can let the developer know.

2022-09-21 09:23:48.983 INFO (MainThread) [homeassistant.components.mqtt.mixins] Ignoring unchanged update for: sensor.windchill_2
2022-09-21 09:23:48.987 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.windchill_2, old_state=<state sensor.windchill_2=unavailable; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=windchill @ 2022-09-20T15:50:22.811041-06:00>, new_state=<state sensor.windchill_2=None; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=windchill @ 2022-09-21T09:23:48.987651-06:00>>
2022-09-21 09:23:48.991 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 75, in async_entity_state_listener
    entity_data = entity.query_serialize()
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 663, in query_serialize
    deep_update(attrs, trt.query_attributes())
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 848, in query_attributes
    temp = round(temp_util.convert(float(current_temp), unit, TEMP_CELSIUS), 1)
ValueError: could not convert string to float: 'None'

Anto79-ops avatar Sep 21 '22 21:09 Anto79-ops

Thanks for looping me in, @Anto79-ops – I think it's safe to assume this value is coming from ecowitt2mqtt.

As we've previously discussed, wind chill is only defined in situations when both (a) the temperature is at or below 50°F and (b) the wind speed is above 3mph. When these conditions are not met, the wind chill value is undefined (which is why ecowitt2mqtt uses None in that case).

@balloob FYI, when ^^^ occurs, we mark the entity in MQTT Discovery as unavailable:

CleanShot 2022-09-21 at 15 45 22

CleanShot 2022-09-21 at 15 50 17

I wouldn't expect an unavailable entity to be pushed to Google (and throw this error); am I wrong there?

bachya avatar Sep 21 '22 21:09 bachya

the problem here is that the state is set to None and not unavailable or unknown. None is not a valid value.

balloob avatar Sep 22 '22 00:09 balloob

I didn't realize that we had to explicitly pass unavailable or unknown – I thought translation occurred somewhere internally. Nevertheless, good to know. @Anto79-ops, this will require an update to ecowitt2mqtt. I'm going to close this issue and create one over there. Thanks!

bachya avatar Sep 22 '22 01:09 bachya

Thanks all. You all make troubleshooting so enjoyable!

Anto79-ops avatar Sep 22 '22 01:09 Anto79-ops