Automation Throwing 'required key not provided @ data['entity_id']'

I’m new to HA and it’s great to learn something new, but I can’t figure out what I’m doing wrong. I know I should probably stick to the Automation Editor, but I edited the YAML for this one.

I want my dusk/dawn, motion sensor light, to stay on when I manually turn them on via the HA Android app, instead of turning off after the normally set time. The motion activation is great, but I do work at night and need them to stay on until I mantually turn them off. I tried using the automation from HERE (automations.yaml also produced below).

I’m getting an Automation is unavailable. Actions: required key not provided @ data[‘entity_id’] error and I’m not sure why. All my entity ids seem correct and I’m at a loss.

- id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  alias: Front Porch Sengled (with Override)
  description: Front Porch Sengled (with Override)
  trigger:
  - platform: device
    type: turned_on
    device_id: 16771b88b4fa87d72ea9eb62e1540ef3
    entity_id: light.sengled_e13_n11_light_2
    domain: light
    id: light.sengled_e13_n11_light_2 on
  - platform: device
    type: turned_off
    device_id: 16771b88b4fa87d72ea9eb62e1540ef3
    entity_id: light.sengled_e13_n11_light_2
    domain: light
    id: light.sengled_e13_n11_light_2 off
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 on
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id == none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id == none }}'
      sequence:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 on
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id == none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id != none }}'
      sequence:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 on
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id == none }}'
      sequence:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 off
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id == none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id == none }}'
      sequence:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 off
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id == none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id != none }}'
      sequence:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  - choose:
    - conditions:
      - condition: trigger
        id: light.sengled_e13_n11_light_2 off
      - condition: template
        value_template: '{{ trigger.to_state.context.id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.parent_id != none }}'
      - condition: template
        value_template: '{{ trigger.to_state.context.user_id == none }}'
      sequence:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.front_porch_sengled
  mode: single
- id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  alias: Front Porch Motion Lights Detection
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 16771b88b4fa87d72ea9eb62e1540ef3
    entity_id: binary_sensor.sengled_e13_n11_motion_2
    domain: binary_sensor
  condition: []
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: input_boolean.front_porch_sengled
        state: 'off'
      sequence:
      - type: turn_on
        device_id: 16771b88b4fa87d72ea9eb62e1540ef3
        domain: light
      - delay:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 16771b88b4fa87d72ea9eb62e1540ef3
        domain: light
  mode: single

That type of error is often caused by missing quotations or improper indentation.

Regarding the automation, if I not mistaken, it seems you are currently changing the state of the boolean not matter what the context of the light trigger is. Also, keep in mind when using context to limit automations based on UI action may want to specify the user so that other users in the household don’t foil your designs.

Your User ID can be in the Users menu:

Open your Home Assistant instance and show your users.

- id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  alias: Front Porch Sengled (with Override)
  description: Front Porch Sengled (with Override)
  trigger:
  - platform: state
    to:
      - 'on'
      - 'off'
    from:
      - 'on'
      - 'off'
    entity_id: light.sengled_e13_n11_light_2
    variables:
      user: "{{ trigger.to_state.context.user_id }}"
condition: 
  - condition: template
    value_template: "{{ user == YOUR_USER_ID }}"
action:
  - service: input_boolean.turn_{{ trigger.to_state.state }}
    data: {}
    target:
      entity_id: input_boolean.front_porch_sengled
  mode: single

With your motion automation I would set it up

- id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  alias: Front Porch Motion Lights Detection
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.sengled_e13_n11_motion_2
    to: 'on'
    from: 'off'
    id: 'on' 
  - platform: state
    entity_id: binary_sensor.sengled_e13_n11_motion_2
    to: 'off'
    from: 'on'
    for: '00:01:00'
    id: 'off'
  condition: []
  action:
  - choose:
    - alias: Turn light on when motion is detected
      conditions:
        - condition: trigger
          id: 'on'
      sequence:
        - service: light.turn_on
          target:
            entity_id_id: light.sengled_e13_n11_light_2
    - alias: Turn light off when motion clears and override is off
      conditions:
        - condition: trigger
          id: 'off'
        - condition: state
          entity_id: input_boolean.front_porch_sengled
          state: 'off'
      sequence:
        - service: light.turn_off
          target:
            entity_id_id: light.sengled_e13_n11_light_2
  mode: single