I have a very simple set of timers which all trigger with different events. I’d like to get a notification when any of them fire the timer.finished event. I could create an automation for each one of them, but I’d rather use a template in the notification which shows the name of the timer. I have all of that working, but can’t extract the name from the ‘trigger’ object in the template for the notification message.
To simplify things I reduced the bigger problem to a simple example which behaves identically:
The timer looks like this:
The automation looks like this: ( the message template is basic to see the trigger object, I know this won’t give me the name like that ) done via the UI, shown as YAML
I can’t figure out how to get the entity_id so I can access the ‘name’. The ‘event’ object is empty, there is no ‘to/from_state’. The ‘data’ object is empty in the notification template as well.
Running version 2021.1.5 in a docker container.
Thanks, I did try something similar as both should have worked. But the “trigger.event” object is empty, once it gets to the notify.
Which I can’t figure out why, as the trigger event_data “entity_id” matches correctly.
No error is thrown in the log, but I get a blank message as the template works out to be an empty string.
Interesting. I get the same results as you for persistent_notification. Both with the “create” as you’ve done and with notify.persistent_notification.
Using notify.mobile_app_XX the event object is empty. So there is clearly a difference between the notify.mobile_app and notify.persistent_notification in how the field are populated.
As far I know, the Trigger Object should be consistent in what it returns from the Event Trigger. Changing the action’s service call shouldn’t affect what the Trigger Object contains (at least not in my opinion).
You may want to post this as an Issue in the Core repository. Be sure to mention the two examples where it works in one but not the other.
Thanks for your help narrowing this down.
It looks to be an artifact with the Android notification, as the iOS one works the same as the persistant one.
Even with the entity extracted I can’t get the common or friendly name out of the timer object. I just get “None” for any attributes.
In my more expanded need I only need this 4 times, so I’ve just created an automation for each.
Perhaps someone could explain how to go from {{trigger.event.data.entity_id}} in a timer event to the ‘name’ as defined at the begining.
Thanks! That does work. and that works for the Android too… Even though earlier it was empty.
It seems the order might matter, calling the iOS first. But then changing it back, still has it work.