I have script ruuning which is sending a number to the mqtt topic. The mqqt is integrated in home assitant and i am able to receive messages.
My question - Is there a way to trigger an alert in HA if the new value coming to topic is greater than the previous value. For example, i send number 10 every 10 seconds and as soon as it changes to 11 it sends an alert or atleast show a mesaage on the dashboard.
I am pretty new to Home assistant and looking for help on this topic
trigger:
platform: state
entity_id: sensor.your_mqtt_sensor_here
to: # null "to:" triggers on any state change but not attribute change
condition:
condition: template
value_template: "{{ trigger.to_state.state|float(0) - trigger.from_state.state|flaot(0) > 0 }}"
action:
service: persistent_notification.create
data:
title: "The sensor is increasing"
message: "Value changed from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}"
Ok, that does not work because you changed the trigger to look at an attribute of a sensor, not the sensor state. Thus there is no trigger.to_state, or trigger.from_state.
For this to work it has to trigger on a sensor state.
You could create a template sensor to break out the attribute into its own sensor. Then use that as the trigger.
Thanks for the quick turnaround. I have a ruuvitag and my plan is to put this tag on a door and monitor when it is opened. The final plan is that when I leave the home I will arm the automation (add another condition to check for a flag) and if any one tries to open the door it alerts me.
I live in an apartment and dont want to invest money in buying a door/windows sensor right now.
I am very new to Home Assistant still trying to learn the basics.