I’m having trouble combining 4 automations I have into 1. I currently have a couple automations setup which trigger an IFTTT action based on entering on leaving zones like this:
- alias: Arrive at Work
trigger:
platform: zone
entity_id: device_tracker.bob_s8
zone: zone.work
event: enter
action:
service: ifttt.trigger
data:
event: work_arrive
value1: "Bob arrived at work"
- alias: Leave Work
trigger:
platform: zone
entity_id: device_tracker.bob_s8
zone: zone.work
event: leave
action:
service: ifttt.trigger
data:
event: work_leave
value1: "Bob left work"
And 2 more automations for the home zone. These all work well.
I’m trying to combine this into 1 automation.
How can I implement a second condition in the IF-statement?
Example: I want to add values to the action based on 2 conditions in the trigger: zone and state (enter or leave).
This is what I have now:
- alias: Presence Log
trigger:
platform: zone
entity_id: device_tracker.bob_s8
zone: zone.home, zone.work
event: enter, leave
action:
service: ifttt.trigger
data_template:
event: >
{% if is_state ("trigger.zone", "zone.work") and ("trigger.event", "enter") %}
event: work_arrive
value1: "Bob arrived at work"
{% elif is_state ("trigger.zone", "zone.work") and ("trigger.event", "leave") %}
event: work_leave
value1: "Bob left work"
{% elif is_state ("trigger.zone", "zone.home") and ("trigger.event", "enter") %}
event: home_arrive
value1: "Bob arrived at home"
{% elif is_state ("trigger.zone", "zone.home") and ("trigger.event", "leave") %}
event: home_leave
value1: "Bob left home"
{% endif %}
This gives me the following error:
2017-05-11 21:37:01 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID zone.home, zone.work is an invalid entity id for dictionary value @ data['trigger'][0]['zone']. Got None
not a valid value for dictionary value @ data['trigger'][0]['event']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 418). Please check the docs at https://home-assistant.io/components/automation/
It’s driving me crazy…