I am trying to create an automation which triggers a restful command to update my Slack status based on entering work/home zones. The automation triggers, but when it does I get the
homeassistant.exceptions.TemplateError: UndefinedError: 'trigger' is undefined
error. I thought this was because I was manually testing it which I have read is because the zone trigger is not actually triggering. However I came into work this morning and I still get the same error. My automation is;
- id: 'Arrived_Work'
alias: 'Arrived Work'
trigger:
- platform: zone
entity_id: device_tracker.my_device
zone: zone.work
event: enter
action:
- service_template: rest_command.slack_status_set_from_zone
I have another rest command to set my status to {{states.media_player.playstation_4.attributes.source}} which works just fine and also another one which sets my status using the state of my device tracker but I’m struggling with the zone trigger template.
I’m on HA version 0.70.1 (just going to update today!) and the latest Hassbian.
Ah, ok that’s a shame. That was the reason for me using the zones, as I could set an icon for the zone and pull that through. I guess I could put an IF statement in the template and set the icon from there.
Another option, if you know it’s for a given device_tracker entity, and you know that entity is in a defined zone (e.g., it just entered a zone, which triggered an automation that runs the rest_command ), could be something like:
Well nothing I tried here worked so I just gave up and created specific commands/automations for the few case scenarios I have. Thanks for your input @pnbruckner and @petro.