I created a blueprint from working automation but get the error: "Entity ID entity_id is an invalid entity id for dictionary value"

I am having trouble preparing this automation for a blueprint. The automation works fine by itself but when combined with the blueprint it does not work.

I receive the below error when I attempt to create an automation from the blueprint.
light.living_room_lamp_left is a valid entity id that I used for testing the original automation (which I disable when testing this blueprint).

Any thoughts?

Error:

2021-01-05 10:22:46 ERROR (MainThread) [homeassistant.components.automation] Blueprint BLUEPRINT NAME generated invalid automation with inputs OrderedDict([('light_brightness', '255'), ('target_lights', OrderedDict([('entity_id', 'light.living_room_lamp_left')]))]): Entity ID entity_id is an invalid entity id for dictionary value @ data['entity_id']. Got None

Blueprint:

The HA File Editor gives this error when I open the blueprint:
Error:

unknown tag !<!input> at line 56, column 36:
      entity_id: !input 'target_lights'
                           ^

Blueprint:

blueprint:
  name: Reset light's brightness and color temperature to your default when it turns
    on
  description: Resets bulb(s)'s color and brightness when it turns on. Although Home
    Assistant has a Default Turn-on Value (https://www.home-assistant.io/integrations/light/#default-turn-on-values)
    for lights it does not support color temperature, and some bulbs do not quickly
    check when they are first physically powered on versus turned on by automation,
    UI, or smart switch.
  domain: automation
  input:
    target_lights:
      name: Lights
      description: The lights you want to auto reset to default settings when they
        turn on.
      selector:
        target:
          entity:
            domain: light
    light_color_temperature:
      name: Color Temperature
      description: 'Choose the color temperature. Examples: Cool White: 154; Daylight White: 181; White: 250; Soft White: 370; Warm White: 454'
      default: 370
      selector:
        number:
          min: 154.0
          max: 500.0
          unit_of_measurement: mireds
          mode: slider
          step: 1.0
    light_brightness:
      name: Brightness
      description: Choose the brightness.
      default: 255
      selector:
        number:
          min: 1.0
          max: 255.0
          mode: slider
          step: 1.0
  source_url: https://gist.github.com/NobleWolf/ecd60fd4f3540ac1cc1083783d3ba28a
alias: Bulb toggle set to default (Soft White) (BP)
description: 'see blueprint description'
trigger:
  - platform: state
    entity_id: !input target_lights
    from: 'off'
    to: 'on'
condition: []
action:
  - service: light.turn_on
    data:
      color_temp: !input light_color_temperature
      brightness: !input light_brightness
      entity_id: '{{ trigger.entity_id }}'
mode: parallel
max: 100

Try to remove the “target:” line between “selector:” and “entity:” lines.

You are using a Target Selector but handling it like an Entity Selector.

If you use a Target Selector, the key name within the automation is target:

Either change the key name in the automation or use an Entity Selector instead of a Target Selector (but if you do that you will lose the ability to select multiple entities).

1 Like

Okay, I sort of understand. So to allow the blueprint to work with multiple entities I need to:

Leave the selector as a target > entity > domain: light

  input:
    target_lights:
      name: Lights
      description: The lights you want to auto reset to default settings when they
        turn on.
      selector:
        target: 
          entity:
            domain: light

Change the Trigger
from entity_id: !input target_lights
to target: !input 'target_lights'
like below:

trigger:
- platform: state
  target: !input 'target_lights'
  from: 'off'
  to: 'on'
condition: []
action:
- service: light.turn_on
  data:
    color_temp: !input 'light_color_temperature'
    brightness: !input 'light_brightness'
    entity_id: '{{ trigger.entity_id }}'

I just tried this, but it did not work. What did I miss?

Possibly because target doesn’t support any other options (like from, to, for). Unfortunately, there are precious few examples in the documentation so the only way one discovers what does or doesn’t work is by experimentation.

Is there any blueprint devs active in the forums who could answer this? Or a contact method like bug reports that are suggested?

I just tried using a trigger template but that wasn’t valid either, but it did work in an automation.

trigger:
- platform: state
  target: !input 'target_lights'
condition:
  - condition: template
    value_template: '{{ ''true'' if trigger.from_state.state == ''off'' else ''false''}}'
action:
- service: light.turn_on
  data:
    color_temp: !input 'light_color_temperature'
    brightness: !input 'light_brightness'
    entity_id: '{{ trigger.entity_id }}'

I’m not sure what is your point. You have demonstrated what is already known.

  • Your functional example uses target in a State Trigger without options (valid).
  • Your non-functional example uses target in a State Trigger with options (invalid).

I was testing to see that if the options were part of the ‘condition’ instead of the ‘trigger’ it would be valid. But my test showed that moving the options to the ‘condition’ did not make the blueprint valid.

So my point is that my test of moving the condition elsewhere did not work. I’m hoping this will help others in the future, or that you or others would see a mistake that could be corrected.

The answer is in the documentation:

The value of the input will contain a special target format, that is accepted by service calls.

I achieved the goal of allowing multiple entities by including instructions to add more entities manually separated by a comma. But like @123 said in this comment it’s not a user friendly option. Alas, I’ll update it when a Blueprint update comes with that feature.