I have worked with other software that handles notification and in doing so, there was always a way to add variables into the notification message to indicate what triggered the message. I got to assume this function is built into HA.
How would I craft that message body or title with the device that triggered the automation along with the state of the device. For example, if the kitchen window triggered my automation, I would like to know my kitchen window did it because the window was opened.
A variable for “time” and “date” would be awesome but I would think the time I received the notification should be close. But, it would be nice to have it in the message in case it was a while before I got to it.
In the other software I have messed with, it was always something like %devicename% or %trigger% or %time%, etc.
Is there anyway someone can tell me how to get this done? In the automation, I have a box for Target and another one for Data. I just do not understand where to add this.
I don’t know how you tested it but be advised that you cannot test an automation using its Run command if it contains a reference to the trigger object (such as trigger.entity_id).
The trigger object is defined only when the automation is triggered by one of its triggers (and will be undefined if you execute the automation via the Run command).
I am guessing I should ignore the “isual editor is not supported for this configuration” error. Here is what it gave me. Step 1 was add the title and then step 2 your code. It looks like it created the title entry in there once I added the message text. Based on Taras’s reply, I may have to wait for one to trigger. Thank you all, until I can confirm…and then I am sure it is still Thank you, all.
Yep, this error message you can ignore, these kind of things can’t be done via UI, it needs some YAML code. And Taras is right (as usual ), you need to wait for a trigger.
And btw. this wasn’t my code, it’s from @Olivier1974s post from above. I only showed how to get it into the UI, with one missed “shot”.
Let us know, if it works ok, or if there are more things to do.
PS: if it works, please mark Oliviers first answer from above as solution, so others can find it in the future. Thanks!
Thank you, all. I set my “Alarm:ON” and “Alarm:OFF” automations that place my home into those modes based on whether or not I am home to use the notification you gave me and both indicated that my cell phone left the area at the date and time it did so I can safely assume that should I get an intrusion or smoke/CO trips, I will be getting those notices.
I am an engineer…not a programmer. But, I am learning.