If you paste the following in the template tool, does it give an output?
{{ states.sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1.state | float }}
If you paste the following in the template tool, does it give an output?
{{ states.sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1.state | float }}
@123
i copy and paste your code and got the following error in the logs:
Value cannot be processed as a number: <state sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1=43,0; level_0=JVACASPERS, level_1=Intel Core 2 Quad Q9650, level_2=Temperatures, name=CPU Core #1, minimal_value=42,0, maximum_value=54,0, unit_of_measurement=°C, friendly_name=JVACASPERS Intel Core 2 Quad Q9650 Temperatures CPU Core #1 @ 2019-03-31T23:22:52.031088+02:00> (Offending entity: 43,0)
i tried to copy and paste your example and the output was : 0.0
the correct value i got from:
{{ states.sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1.state}}
but my example wont work with it
I assume by code you mean the second example using platform: numeric_state
? That means the sensor’s value is not understood to be a string and not a numeric value.
Or do you mean the code in the first example using platform: template
?
your second example.
Trigger is numeric state.
But it seems, that the output of the
sensor.jvacaspers…core_1
is a string.
so im now trying the following code:
` trigger:
That’s what the filter conversion is for. If you try int instead of float does it change anything?
Please format the code for presentation on this forum.
I suggested you add | float
to the end of the value_template
's contents:
value_template: "{{ (states.sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1.state|float)}}"
@walrus_parka
Nope. Tried a lot of different combinations.
int,number,float
@123
That was my first try yesterday.
Something is wrong here. If the temperature value is a numeric string, either float
or int
will convert it to a numeric value. If they are failing to do that then the temperature value is a non-numeric string.
I noticed this: (Offending entity: 43,0)
The comma decimal separator must be due to localization (i.e. that’s the way it’s done in your country). However, is this making Home Assistant treat it as a non-numeric string?!?
@123
i added your " | float" to my value template.
Now Im getting the same error
Value cannot be processed as a number
German here. Decimals are wrote with a commata here.
Is that the problem?
Can you post a screenshot of the entity from the states page?
THANKS A LOT!
The comma as decimal seperator was the problem.
The following template is working:
value_template: "{{ states.sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1.state |replace(',0', '')| float }}"
The template editor gaves me the correct output as a float:
43.0
and NOT: 43,0
You’re welcome but, to be honest, I don’t understand why Home Assistant fails to understand the localization (i.e. German use of comma as decimal separator).
Nevertheless it is failing to consider localization and is treating 46,0
like a non-numeric string (as non-numeric as 46;0
would be). Strange.
Something needs to be fixed somewhere because I can’t imagine having to use Home Assistant in this manner. For every temperature sensor you’ll need to parse out the comma? That’s ugly!
Yes but that is okay.
Does ha stops the automation after the first trigger?
Temp goes up -> lamp off
I manually turn on the lamp
…
the lamp stays on. Automation is running
The automation ends after completing the action
section.
The interesting thing I discovered, while testing with the Template Editor, is that if I try to convert “46,0” with float
it doesn’t fail but simply converts it to zero. My localization uses period as the decimal separator. Try this on your system and see if report zero or produces an error.
How are you getting
sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1
?
I’ve never had any issues with commas in my temp sensors
This is a failure:
Value cannot be processed as a number: <state sensor.jvacaspers_intel_core_2_quad_q9650_temperatures_cpu_core_1=43,0; level_0=JVACASPERS, level_1=Intel Core 2 Quad Q9650, level_2=Temperatures, name=CPU Core #1, minimal_value=42,0, maximum_value=54,0, unit_of_measurement=°C, friendly_name=JVACASPERS Intel Core 2 Quad Q9650 Temperatures CPU Core #1 @ 2019-03-31T23:22:52.031088+02:00> (Offending entity: 43,0)
Whereas returning a 0
is just the float
filter’s way of handling non-convertible strings.
You’ve mistakenly directed your question to me. I’m not the individual experiencing the problem, it’s @curryhoden.
That’s what I’d expect if the system is running properly.
If you can, at the Linux system prompt, type locale
and confirm it is set correctly (de_DE.UTF-8
).
Sorry Im back. It was night in germany.
@123 was right. In germany we use a comma as decimal seperator .
The output of locale is:
LANG=de_DE.UTF-8
I think the problem is the openhardwaremonitor tool running on my windows computer.
The openhardware component (running on my ha) is getting its information from the openhardwaremonitor-webserver (built-in) at my windows pc.
The ha component is reading a json file, which includes the temperature as
“43,0” -> comma as seperator.
The ha object/entity represents the json attribute, so the problem is NOT at home assistant.
BTW: i downloaded the newest version of openhardwaremonitor.
Windows 10 locale is germany
openhardwaremonitor is running in english (no language settings found)
Did you get “real” float values (43.0) in another countries?
Later i can try to set windows locale to united states.
Maybe there is the mistake.
@Codec303
I am running the openhardwaremonitor tool on my personal computer.
The tool has a built in webserver.
In ha, you can add the openhardwaremonitor component and reading the values of your personal computer at its webserver.
You will get states for each value in openhardwaremonitor