I have the following automations working as expected:
- alias: 'Send IP Cam photo - Livingroom'
trigger:
platform: state
entity_id: binary_sensor.live__the_residentie__livingroom_motion_active
from: 'off'
to: 'on'
condition:
condition: state
entity_id: device_tracker.bob
state: 'not_home'
action:
service: notify.galaxy_s6_edge
data:
title: 'Home Assistant'
message: 'Photo'
data:
photo:
url: http://10.0.0.160:8080/photo.jpg
username: xxxx
password: xxxx
caption: Motion detected in de Residentie Livingroom
- alias: 'Send IP Cam photo - Bedroom'
trigger:
platform: state
entity_id: binary_sensor.live__the_residentie__bedroom_motion_active
from: 'off'
to: 'on'
condition:
condition: state
entity_id: device_tracker.bob
state: 'not_home'
action:
service: notify.galaxy_s6_edge
data:
title: 'Home Assistant'
message: 'Photo'
data:
photo:
url: http://10.0.0.30:8080/photo.jpg
username: xxxx
password: xxxx
caption: Motion detected in de Residentie Bedroom
I would like to combine these in 1 automation but the following does not work:
- alias: 'Send IP Cam photo'
trigger:
- platform: state
entity_id: binary_sensor.live__the_residentie__livingroom_motion_active
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.live__the_residentie__bedroom_motion_active
from: 'off'
to: 'on'
condition:
condition: state
entity_id: device_tracker.bob
state: 'not_home'
action:
service: notify.galaxy_s6_edge
data:
title: 'Home Assistant'
message: 'Photo'
data_template:
photo:
url: >
{% if is_state("trigger.entity_id", "binary_sensor.live__the_residentie__livingroom_motion_active") %} http://10.0.0.160:8080/photo.jpg
{% elif is_state("trigger.entity_id", "binary_sensor.live__the_residentie__bedroom_motion_active") %} http://10.0.0.30:8080/photo.jpg
{% endif %}
username: xxxx
password: xxxx
caption: >
{% if is_state("trigger.entity_id", "binary_sensor.live__the_residentie__livingroom_motion_active") %} Motion detected in de Residentie Livingroom
{% elif is_state("trigger.entity_id", "binary_sensor.live__the_residentie__bedroom_motion_active") %} Motion detected in de Residentie Bedroom
{% endif %}
Can someone help me out?