Blueprint error with conditions

I’m trying to make blueprints for my lights automations (mostly turning on and off lights in the morning and evening).

I’m trying to get the state of the choosen light and use it in a condition, but I can’t get it to work. This is the error I get:

Blueprint Fade in light at sunset (light_timer_on_evening) generated invalid automation with inputs OrderedDict([('time_offset', '-00:45:00'), ('time_trigger_before', 'input_datetime.edvin_window_timer_off_evening_time'), ('light_target', 'light.edvin_window_all')]): expected a dictionary for dictionary value @ data['action'][1]['target']. Got None

And this is my Blueprint:

blueprint:
  name: Fade in light at sunset (light_timer_on_evening)
  description: Fade in lights at sunset, with offset
  domain: automation
  input:
    time_trigger_before:
      name: input_datetime, don't trigger after
      selector:
        entity:
          domain: input_datetime
    time_offset:
      name: offset
      selector:
        time:
      default: -00:45:00
    light_target:
      name: Window light to trigger
      selector:
        entity:
          domain: light

mode: single

trigger:
  - platform: sun
    event: sunset
    offset: !input time_offset

condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: !input light_target
        state: 'off'
      - condition: numeric_state
        entity_id: !input light_target
        attribute: brightness
        below: '16'
  - condition: time
    before: !input time_trigger_before

action:
  - delay: '{{ range(0, 901)|random }}'
  - service: light.turn_on
    target: !input light_target
    data:
      brightness: 255
      transition: 900

Anyone who can help me?

Your missing target in your target.

You have

    light_target:
      name: Window light to trigger
      selector:
        entity:
          domain: light

the example

    target_light:
      name: Lights
      description: The lights to keep in sync.
      selector:
        target:
          entity:
            domain: light

what’s different?

I’m confused by this target:

In the example in the docs are two selector inputs,one with and one without target:

motion_sensor:
      name: Motion Sensor
      description: This sensor will be synchronized with the light.
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    target_light:
      name: Lights
      description: The lights to keep in sync.
      selector:
        target:
          entity:
            domain: light

The difference is the created UI

The reason he is getting an error is because he’s using a entity_id selector in the target field, which doesn’t work.

EDIT: Another way to look at is:

selector -> 1 entity

target selector -> multiple entities

3 Likes

I had an issue with ‘target’ too…

Still no replies from anyone in the know, but can confirm that changing target to entity_id works and the only difference I can see is the service difference between light.turn_on and homeassistant.turn_on

Thanks! That solved it. And thanks for your other explanation. Made me understand better :slight_smile:

Is it possible to use the condition statement with the “type” target?

1 Like