WTH is it so hard to create blueprints?

I recently discovered blueprints and it looks awesome, except that it is so hard to get it work…
Often time it seems to work until I try to use it in an automation and after having set everyting, it fails when I save the automation with a very helpful message like:

It’s an automation or script or template with 1 extra variable… (!input).

The instructions show you to start with a working automation (implying also a working script or template as well), then add in the substitution stuff.

It’s only as hard as the automation (script, template) you started with, TBH.

Your example shows an error with a template, which can be in blueprints but are also can be in EVERYTHING else.

Should your question maybe be ‘why are templates so hard’, YES, I’ll vote for that one. 100% agree with templates are hard.

1 Like

If a user is facing an issue with a particular blueprint - may be this thread should be a bit renamed and moved to Configuration?

That error tells you exactly where to look. Lets break it down:

template value should be a string @ data['actions][0]['target]['device_id'][0]

  1. go to your action section (data['actions']).

  2. look at the first action ([0])

  3. look at the target for the first item (['target']).

  4. look at the targets device_id (['device_id']]

  5. look at the first item in the device_id ([0])

  6. That value should be a string template value should be a string

3 Likes

Thanks a lot for the explanation. I will analyze it this evening to see whether I’m able to sort it out.

Along the lines of what Sir_Goodenough said, a basic blueprint is usually only a little bit more complicated than configuring a similar automation in YAML. But, most of the time, for a blueprint to actually be useful it needs to be more flexible/dynamic than the original automation. That takes a higher level of understanding of all the components and configuration options available to be used in an automation.

And to take it one step further, a blueprint you share with the unwitting public, you need to understand the failure modes and pitfalls of each of those components. Because many of the people who install it won’t; and you should do everything you can to make it easy for them to use, but difficult for them to mess things up (or, at the very least, warn them about what might cause trouble).

3 Likes

My post wasn’t intended to make my issue solved but more to discuss about a solution to ease the Blueprint usage which looks really seems to be an awesome tool to me.
Maybe an UI would help a lot guiding the designer not to write wrong things.
BTW does anyone know if a “blueprints for dummies” is available somewhere?
The only link I found is https://www.home-assistant.io/docs/blueprint/tutorial/, which to me is not very deep.
Anyway, going back to my problem, I tried to look at your explanation and to be honest it didn’t help me much.
Here is the blueprint result I have which is what I wanted to have:

Selection of a device as trigger and selection of an entity as target.
Here is my yaml code:

blueprint:
  name: Button to toggle an Entity
  description: Select a Button to toggle an entity
  domain: automation
  input:
    button_trigger:
      name: Button to use
      description: The Button used to toggle the entity
      selector:
        device:
    entity_target:
      name: entity
      description: The entity to be toggled.
      selector:
        target:
          entity:
            domain:
              - light
              - switch
              - input_boolean
triggers:
  - domain: mqtt
    device_id: !input button_trigger
    type: action
    subtype: single
    trigger: device
conditions: []
actions:
  - action: homeassistant.toggle
    target:
      entity_id: !input entity_target
    data: {}
mode: single

something also strange to me (as a beginner) is that I put as selector of the target an entity and I can select “area, devices, entity and label”…

You made a target selector not an entity selector

1 Like

it works! thanks