I wanted to create a way to calibrate a temperature sensor using a number sensor that can be changed in Home Assistant frontend, much like this sensor (as an example of a number sensor):
The intent is to enter the measured temp of the sensor into the Frontend input number template sensor to change the filters: calibration_linear: datapoints:
of a Dallas temp sensor.
# Temperature Probes 1
- platform: dallas
id: temp_1
icon: mdi:thermometer-lines
index: 0
name: "Temperature"
filters:
- calibrate_linear:
method: least_squares
datapoints:
- 0.0 -> ${cal_0}
- 100.0 -> ${cal_100}
# - 0.0 -> 0.0
# - 100.0 -> 100.0
Using number sensors like these:
# Calibration Temp. at 0C - Ice Bath
- platform: template
name: "Calibration Temp. at 0C - Ice Bath"
id: cal_0
icon: mdi:snowflake-alert
optimistic: true
min_value: -10.0
max_value: 10.0
step: .1
restore_value: True
initial_value: 0.0
entity_category: "Config"
# Calibration Temp. at 100C - Boiling
- platform: template
name: "Calibration Temp. at 100C - Boiling"
id: cal_100
icon: mdi:snowflake-alert
optimistic: true
min_value: 90.0
max_value: 110.0
step: .1
restore_value: True
initial_value: 100.0
entity_category: "Config"
but the only thing I can substitute into datapoints are substitutions:
like this
substitutions:
cal_0: "0.0"
cal_100: "100.0"
But I want to be able to change them, and I don’t think substitutions can be variables, or is there a way? I was thinking of globals:
and setting the value based on the number sensor but I am not familiar with that and do not know if that’s even an option, I get an error expected float
, as expected if I can’t pass a float into datapoints…
globals:
- id: cal_0
type: float
restore_value: yes
initial_value: '0.0'
I want a UI frontend method of calibration. Is this even possible with ESPHome and Home Assistant? Is there someway to pass variables into datapoints of a filter? Or perhaps a way to alter a substitution from the frontend? Please and thank you.
This post was asking the same question:
Calibrate Linear Filter using a Global Variable?