-
-
Notifications
You must be signed in to change notification settings - Fork 28.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception since 2023.5.0: state class None: numeric value, however, it has the non-numeric value. #92483
Comments
Same problem here, this code in longer works (sensor shows as unavailable in lovelace):
But, it does work if the code is changed to this (note three lines changed):
But, even with the change above (three places with %) to make the sensor work, this error is still in the syslog: May 5 08:01:26 kruse-pi homeassistant[599]: ValueError: Sensor sensor.battery_status_kruse_cell 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: Charging: 100 (<class 'str'>)#33[0m |
I am also seeing this with the GivTCP addon, as below:
|
I also started getting a similar error after the latest update.. related to modbus sensor.
|
I am getting this with a template
Error is |
@hitnrun30 remove: |
A user reported this exception for my HomeAssistant add-on (neilenns/ambientweather2mqtt#99). It's a timestamp sensor and worked fine prior to this update. Looks like it might be related to this pull request: https://github.com/home-assistant/core/pull/85605/files |
I have a solution that could work for some. |
Thank you that did it. |
there seems to have been a breaking change, so that entites with unit_of_measurement: '' cause now an exception when assuming it is a numeric value. Was this breaking change documented somewhere or is some fallback planned? However, I could change all unit_of_measurement:'' to unit_of_measurement:'something' - but a usefull fallback seems reasonable |
This is getting really annoying. I am having tens of thousands of these messages in the log and the log is cluttered with these messages, adding tens of megabytes per day... |
Is there any workaround I can use in my case? |
I'm having the same problem: ``Logger: homeassistant.components.mqtt.models Exception raised when updating state of sensor.rain_barrel_ds18b20_id, topic: 'tele/RainBarrel/SENSOR' with payload: b'{"Time":"2023-05-16T12:46:57","Switch1":"ON","Switch2":"ON","Switch3":"ON","Switch4":"ON","Switch5":"ON","DS18B20":{"Id":"00000983A15A","Temperature":55.2},"TempUnit":"F"}' The above exception was the direct cause of the following exception: Traceback (most recent call last): My mqtt yaml:
My mqtt payload:
|
@epenet ist this a new problem or only a new message? |
If it has a unit of measurement => the value MUST be a number or So there are two ways to fix:
For example:
|
Where is this documented? If the unit of measurement is |
Also in my case the sensors are not manually defined, they are automatically added by MQTT integration, I can't change anything for those sensors... |
But this is not what the message says. It says: |
"has device class None, state class None unit and suggested precision None thus indicating it has a numeric value"
Each scenario here is different... and it should be resolved differently in each case. |
I suppose this is down to MQTT integration then, because the very same sensors loaded through different integration (Tasmota) show up OK without errors. |
Another issue that I see above from @KruseLuds: |
Yes, there are some sensors that are incorrectly sending strings for numeric data. But others are doing it correctly (e.g. for timestamp values), and HomeAssistant is incorrectly reporting those as invalid. The change introduced for 2023.5.0 to enforce the numeric value appears to have forgotten to handle the case where the sensor value is supposed to be a string. Edit: Here's one issue logged specifically for timestamp values. |
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) mobile_app documentation |
I suppose you wanted to add mqtt integration label, not mobile_app? |
I have the same issue with modus sensors... no change on my end for years. |
No. I tagged as That one is (or was) a bug in |
You should open a separate issue for
|
similar issue here |
I don't know why suddenly home assistant is now strictly enforcing typing of states. States in the past were always strings unless explicitly used in a manner that forces their conversion, ie. Everyone who writes uses a template sensor, MQTT sensor must write in their own data sanitization to keep home assistant from throwing ugly exceptions. I thought the goal of this project was to make things more user friendly over time, but this move is completely backwards when we have to make the states compatible with raw python string to numeric conversion at all times. Worse yet this isn't even compatible with how home assistant normally handles the state of sensors. If a sensor is malfunctioning or hasn't been completely initialized yet it is supposed to report |
And it seems to be not working as designed. Even a trigger template and check against a number and only take this then and otherwise the old value, which should be a number because of this rule is not working either. Where it should restore state on startup. But gives the same error. |
Well said, I can't think of what was the point of this change. |
A quote from a great man, as noted on wikipedia…
In computing <https://en.m.wikipedia.org/wiki/Computing>, the *robustness
principle* is a design guideline for software that states: "be conservative
in what you do, be liberal in what you accept from others". It is often
reworded as: "be conservative in what you send, be liberal in what you
accept". The principle is also known as *Postel's law*, after Jon Postel
<https://en.m.wikipedia.org/wiki/Jon_Postel>, who used the wording in an
early specification of TCP
<https://en.m.wikipedia.org/wiki/Transmission_Control_Protocol>.[1]
<https://en.m.wikipedia.org/wiki/Robustness_principle#cite_note-1>
On Sat, May 20, 2023 at 07:37 JoHnY ***@***.***> wrote:
Well said, I can't think of what was the point of this change.
—
Reply to this email directly, view it on GitHub
<#92483 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN5FLPAVLOPD4UJKA7O4H33XHDJJHANCNFSM6AAAAAAXVSQEYU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Glen Larwill
…-- opinions expressed are my own - no connection to my employer --
|
I've been experimenting to see if I can even create a template sensor that can return a 'None' to satisfy the string to numeric conversion. Is this even possible? The string 'None' won't work. Hard coding a 'None' in yaml as 'null' throws an error because a none type is invalid according to the yaml parser. An empty string is still a string. If I can only represent the state as a string in a template or mqtt sensor, but a python None can't be represented as a string, then now we got an unresolvable problem. |
That is the result of my tests as well. Secondly a trigger template should restore it's state at startup. And then I tried to set a change trigger on the source, which is perhaps not available on startup of the template and a trigger on ha-start and a if with is_number, so that the template should either take his old (or restored value) number value or the/a new number value from source. But it returns the same error on startup for whatever reasons because it should work, at least think so. Can anyone or the one who implemented this error message (was it you @epenet in #85605?) please give one single example how to define now a template sensor with a number state class or a uom and which is working without error at system start? |
For templates the solution seems to be For your trigger templates, I think I have an idea of what could be wrong as I encountered this issue. If a trigger based template throws the exception due to a failed string to numeric conversion the trigger gets disabled until hass is rebooted. You can have a whole block of template sensors under one trigger and if any one of those throws the exception the whole block no longer triggers. Later in the week I'll see if I can come up with a reproducer configuration and open an issue for that. |
So this went away for me when I deleted my iPhone from the mobile integration and then let it get re-added when I ran the iOS companion app. |
Thanks for confirming. |
This fixed it for me, too. |
I updated my Home Assistant and now I get from some of devices: ValueError: Sensor sensor.airthings_wave_006661_radon_1_day_level has device class None, state class measurement unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: low (<class 'str'>) ValueError: Sensor sensor.fr_re22210040331_radon_uptime_string has device class None, state class measurement unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: 3d 11:27:36 (<class 'str'>) So this means those are not shown on HA anymore. How to fix this? They was working before update just fine. |
The issue here is closed. Please open a new issue describing precisely which integration the sensors belong to. |
The problem
The issue is introduced in 2023.5, without any config changes from my site related to my iPhone
Exception is visible both with charging and not-charging. (makes sense off course)
What version of Home Assistant Core has the issue?
2023.5.0
What was the last working version of Home Assistant Core?
2023.4.6
What type of installation are you running?
Home Assistant OS
Integration causing the issue
NA
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?
Additional information
No response
The text was updated successfully, but these errors were encountered: