Need help to debug on blueprint I created

Hi
I am trying to create an automation blueprint for motion trigger light:

blueprint:
  name: Motion Light Control with Illuminance
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: Motion Sensor
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    light_sensor:
      name: Light Sensor
      description: Light Sensor
      selector:
        entity:
          domain: binary_sensor
          device_class: light
    no_motion_wait:
      name: Wait Time
      description: Time to keep light on after last motion
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    light_switch:
      name: Light to Control
      selector:
        target:
          entity:
            domain: light

trigger:
- platform: state
  entity_id: !input motion_sensor
  to: 'on'
- platform: state
  entity_id: !input motion_sensor
  to: 'off'
  for:
    seconds: !input no_motion_wait

condition:
- condition: or
  conditions:
  - condition: and
    conditions:
    - condition: state
      entity_id: !input light_sensor
      state: 'off'
    - condition: state
      entity_id: !input light_sensor
      state: 'off'
  - condition: and
    conditions:
    - condition: state
      entity_id: !input light_sensor
      state: 'on'
    - condition: state
      entity_id: !input light_sensor
      state: 'on'

action:
- service: light.turn_{{ trigger.to_state.state }}
  target:
    entity_id: !input light_switch
mode: single

When I create one automation from this blueprint, assigning those inputs, I got this:
Message malformed: not a valid value for dictionary value @ data[‘action’][0][‘target’][‘entity_id’]

Which I have no idea what it means.
Can anyone help me out?

I’m not sure why the error, as it seems ok, but there are other things that should be cleaned up and then we can see if it works.

  • The condition and’ed statements are duplicated. Don’t know why.
  • The condition or’ed statements essentially mean the condition is if this light sensor is on or it is off. That means unless the sensor is offline, it will always be true and it really does nothing.
  • The entity selectors in the inputs are using the deprecated format. It still works, but it may break at a breaking change in the future. Need to add the filter: line. Selectors - Home Assistant.

Then let’s see if the error is still there after adding the filter: key and removing the condition statement.

Edit:
It doesn’t like the light service call. I suggest switching the light_switch input to an entity not a target, and use the entity_id straight-up in the service call.

This will work:

blueprint:
  name: Motion Light Control with Illuminance
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: Motion Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
            device_class: motion
    # light_sensor:
    #   name: Light Sensor
    #   description: Light Sensor
    #   selector:
    #     entity:
    #       filter:
    #         domain: binary_sensor
    #         device_class: light
    no_motion_wait:
      name: Wait Time
      description: Time to keep light on after last motion
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    light_switch:
      name: Light to Control
      selector:
        entity:
          filter:
            domain: light

trigger:
- platform: state
  entity_id: !input motion_sensor
  to: 'on'
- platform: state
  entity_id: !input motion_sensor
  to: 'off'
  for:
    seconds: !input no_motion_wait

action:
- service: light.turn_{{ trigger.to_state.state }}
  entity_id: !input light_switch
mode: single

If the suggestions listed solves your problem, please consider clicking the solution button to close the thread.

Appreciate your efforts to investigate. I changed it to entity for the light, still getting the same error:

blueprint:
  name: Motion Light Control with Illuminance
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: Motion Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
            device_class: motion
    light_sensor:
      name: Light Sensor
      description: Light Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
            device_class: light
    no_motion_wait:
      name: Wait Time
      description: Time to keep light on after last motion
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
    light_switch:
      name: Light to Control
      selector:
        entity:
          filter:
            domain: light

trigger:
- platform: state
  entity_id: !input motion_sensor
  to: 'on'
- platform: state
  entity_id: !input motion_sensor
  to: 'off'
  for:
    seconds: !input no_motion_wait

action:
- service: light.turn_{{ trigger.to_state.state }}
  entity_id: !input light_switch
mode: single

To answer your previous questions: my logic is when ambience is dark and light is off, turn on light by triggers, when ambience is bright and light is on, turn off light by triggers. I changed light to light_sensor for debugging purpose temporarily.
With above code, I still get the same error though.

My bad. I forgot the fact that I need to restart HA (at least automation section) after I update blueprint so kept getting the same error even I already fixed the issue in the file.
Now I am able to create automation rule from this blueprint.
Thank you very much for the help!

You are welcome.