I have an Mqtt sensor defined that tracks the number of hours that my HVAC runs. This value is updated daily to total cumulative run time by adding run time for for each day through an automation. This part is all working. However, I want to set up another automation that triggers based on a max value, lets say 300 hours. When the 300 hours is exceed, I’ve defined an action that alerts me to change the filter. The action part of the automation is working, but the trigger is not working. I’ve tried a numeric_state platform trigger, no luck. Next I moved on to a template platform, and again no luck. I would like some help with the trigger. Here is my sensor definition:
sensor:
- platform: mqtt
state_topic: 'ha/fan_run_hours'
name: "Fan Run Hours"
unit_of_measurement: "hours"
value_template: '{{ value_json.fan_hours }}'
Here is my attempt at the trigger:
- alias: 'Filter change'
trigger:
- platform: template
value_template: "{% if states('sensor.fan_run_hours') | float > 300.0 %} true {% endif %}"
action:
- service: mqtt.publish
data_template:
topic: "switch/filter_change/cmd"
payload: "1"
I believe I’m not accessing the numeric value correctly. Possibly I need to use a Mqtt trigger. Can someone provide some guidance, thanks…