I am using mqtt to bring a value from a pressure sensor into HA, and it works most of the time; however, sometimes the decimal of the float value gets disregarded and number ends up being x1000. So I wanted to check the value with a template and only keep the values less than 30.0. I am attempted to read in the mqtt data sensor.pool_sand_filter_pressure
, check that it is below 30.0 with an if statement. When the IF statement is true pass the value to the variable filtered_press
, then assign it to the template sensor This my latest attempt. Can someone point out whats wrong?
template:
- sensor:
- name: Filter Pressure Template
- unit_of_measurement: "PSI"
state: >
{% if states("sensor.pool_sand_filter_pressure") | float <= 30.0 %}
set filtered_press = states("sensor.pool_sand_filter_pressure") | float
{% endif %}
{{filtered_press}}
I get the following log message but I don’t understand what it means
Logger: homeassistant.config
Source: config.py:864
First occurred: 3:47:45 PM (1 occurrences)
Last logged: 3:47:45 PM
Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 80).