Blink Video Save on Triggered Motion

Hi,

Can someone help me understand why the following automation is not correct?

- id: save_blink_video_on_motion
  alias: Save Blink Video on Motion
  trigger:
      - platform: state
        entity_id: binary_sensor.blink_front_door_motion_detected
        to: 'on'
      - platform: state
        entity_id: binary_sensor.blink_garage_door_motion_detected
        to: 'on'
      - platform: state
        entity_id: binary_sensor.blink_side_door_motion_detected
        to: 'on'
      - platform: state
        entity_id: binary_sensor.blink_back_yard_motion_detected
        to: 'on'
  action:
      service: blink.save_video
      data_template:
          name: {% if is_state({{ trigger.entity_id }} = 'binary_sensor.blink_front_door_motion_detected') %}
            Front Door
            {% elif is_state({{ trigger.entity_id }} = 'binary_sensor.blink_garage_door_motion_detected') %}
            Garage Door
            {% elif is_state({{ trigger.entity_id }} = 'binary_sensor.blink_side_door_motion_detected') %}
            Side Door
            {% elif is_state({{ trigger.entity_id }} = 'binary_sensor.blink_back_yard_motion_detected') %}
            Back Yard
            {% else %}
            Garage Door
            {% endif %}
          filename: "/share/video/camera.blink_front_door_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4"

What I am trying to do is to use the trigger.entity_id to select the correct name for the camera that triggered the motion. In other words, if the trigger is

      - platform: state
        entity_id: binary_sensor.blink_garage_door_motion_detected
        to: 'on'

then I need to pass ‘Garage Door’ as the name variable to the data_template for the service blink.save_video.

Couple of problems with your templates. I’ve corrected the first one:

      data_template:
        name: >
          {% if trigger.entity_id == 'binary_sensor.blink_front_door_motion_detected' %}
            Front Door
          {% elif trigger.entity_id == etc...

Note the use of the comparison operator ‘==’ not the assign value operator ‘=’

X = 1 # sets x to 1.
X == 1 # tests if x is 1.