When posting code, it needs to formatted correctly so others can help you. Look at the blue portion at the top of the page. Paste your code, highlight, then press the button.
The templating tool is a good resource to test whether or not a template provides a good output.
If it doesnât work, and youâre sure the sensor is working properly, look at Home Assistantâs States page and confirm the automation is enabled (on).
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?
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?!?
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
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!
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.