I’m trying to calibrate my temperature sensors by adjusting the temperature to match a master sensor. I have read this is done by using a template (https://home-assistant.io/docs/configuration/templating/). I can’t understand how this is done.
Could someone please give my an example for a template that adjust a temperature sensor with entity name “sensor.temperature_158d0001b7b128” say +1 degree celcius?
ah yes, that looks like the exact example i found haha.
alas, I’m not 100% sure where to plop that. i tried doing it in the ‘customize.yaml’ but with no luck (yet!).
And every thread about this i find on the forum seems to be pointing people to very broad “how-to” pages (that i’ve read!) that assume some prior knowledge, without actually giving the answer haha. ahhhh well
I’ll come back to this conundrum one day when things make a bit more sense perhaps, I’m still early in my hassio set up
Where do you put “{{ states.sensor.temperature_158d0001b7b128.state | float + 1 }}” do you simply go to <> in the menu on the left at the bottom and then enter it in the JSON field ?
It’s a bit blind leading the blind here but I think you should add the template under sensor: in configuration.yaml. I added this to my configuration.yaml:
After a restart of Hass.io I got a new virtual device that showed the original sensors value plus 50. The sensor is NOT however a temperature sensor, it’s showing under states as “sensor.sun_state” (?!) and only show time active when clicked on in the GUI, not a graph with values over time as the other temperature sensors.
It’s sensor.sun_state because you named it that way. If you want to change it you just have to replace the 4th line of your example with the name you want it to have.
To see it as a graph in the pop up you have add to add the attribute unit_of_measurement with either °C or °F as value.
How can I change the value to let’s say 70 to 72? +2 does not really do it… I end up with 21.6%… is there a trick ? or is float not correct for humidity?
Looks like you’ve got this all sorted but I did it differently.
Rather than creating a new temperature, resulting in having both the original and adjusted temperatures, I wanted to just fix the original temperature directly so simply subtracted the value I wanted when the value was being gathered in the first place. It seems to work for me, but maybe I have a different goal than you. If nothing else then it may be helpful to someone else doing the same as me in the future.
This is from an ESP8266 via JSON from MQTT.
Mad that 2 DS18B20 sensors are so wildly different, 5.5 degrees in my case!
Altough i get the following error Invalid config for [binary_sensor.template]: invalid template (TemplateSyntaxError: expected token ',', got 'x286d970001010cd0_temperature') for dictionary value @ data['sensors']['xiaomi_temp_1_calibrated']['value_template']. Got '{{ (float(states.sensor.0x286d970001010cd0_temperature.state) - 3.2 ) }}'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/binary_sensor.template/