Hi, I have two temperature sensors in the greenhouse and the average of the same is calculated, which gives a result on the template sensor. The average works great in case there are readings from both sensors but if one falls then there is no average template sensor.
How to configure the sensor template to calculate the average and if there are no readings of one sensor, use the value of another sensor that is available?
sensor:
- platform: dht
pin: GPIO23
temperature:
id: "master_temp_up"
name: "Greenhous Temperature up"
accuracy_decimals: 2
humidity:
id: "master_hum_up"
name: "Greenhous Humidity up"
accuracy_decimals: 2
update_interval: 30s
- platform: dht
pin: GPIO22
temperature:
id: "master_temp_down"
name: "Greenhous Temperature down"
accuracy_decimals: 2
humidity:
id: "master_hum_down"
name: "Greenhous Humidity down"
accuracy_decimals: 2
update_interval: 30s
- platform: template
name: "Greenhouse Temperature Average"
id: "temp_avr"
unit_of_measurement: "°C"
accuracy_decimals: 2
lambda: |-
return (id(master_temp_up).state + id(master_temp_down).state)/2;
update_interval: 15s