Blueprints variables !input not working !Edit! Solved

Tags: #<Tag:0x00007fc41d24cd70>

I have tried to use variables in a blueprint to import the inputs of the blueprint into a template. But the configurator doesn’t recognize the command and comes with a unknown tag error… I cant set a variable as !input. I hope someone can help :slight_smile:
I have also tried pasting variables !input from other blueprints into my blueprint and they dont get recognized either.

The errormessage:

unknown tag !<!input> at line 27, column 56:
… t: !input string_aktuel_setpunkt

Here is my blueprint:

blueprint:
  name: set temp in HA for IHC varmestyring
  description: Uses a input_number to set the temperatur in the IHC varmestyring funktionsblok
  domain: automation
  input:
    input_number:
      name: temp
      selector:
        entity:
          domain:
            input_number
    string_aktuel_setpunkt:
      name: ID aktuel setpunkt
      selector:
        number:
          min: 0
          max: 9999999999
          mode: box
    string_setpunkt_normal:
      name: ID Setpunkt normal
      selector: 
        number:
          min: 0
          max: 999999999
          mode: box
variables:
  string_aktuel_setpunkt: !input string_aktuel_setpunkt
  string_setpunkt_normal: !input string_setpunkt_normal
  input_number: '{{states("{{ !input input_number }}")}}'
  

trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: input! input_number
          
action:
# set aktuel setpunkt
  - service: ihc.set_runtime_value_float
    data_template:
      ihc_id: "{{ string_aktuel_setpunkt }}"
      value: '{{states("{{ input_number }}") | float}}'
# set setpunkt normal
  - service: ihc.set_runtime_value_float
    data_template:
      ihc_id: "{{ string_setpunkt_normal }}"
      value: '{{ "{{ input_number }}" | float}}'
mode: single

I’m seeing the same issues – did you ever make progress?

So I was getting a similar error from another blueprint and what I found that worked for me was to remove the !input in front of your variable. After that I saved it, reloaded my automations and tested and it fired off exactly as I was expecting it to.

action:
domain: mobile_app
type: notify
device_id: !input notify_device
message: “{{ trigger.event.data.new_state.attributes.friendly_name }} has deteced a leak.”
title: “Leak detected!”

changed to:

action:
domain: mobile_app
type: notify
device_id: notify_device
message: “{{ trigger.event.data.new_state.attributes.friendly_name }} has deteced a leak.”
title: “Leak detected!”

Don’t know if this will fix it for you but worth a shot.

I will try that, thanks

@antonpallavicini I think the issue here is that you cannot use an !input statement inside a Jinja statement.

This won’t work:

variables:
  string_aktuel_setpunkt: !input string_aktuel_setpunkt
  string_setpunkt_normal: !input string_setpunkt_normal
  input_number: '{{states("{{ !input input_number }}")}}'

but try this:

variables:
  string_aktuel_setpunkt: !input string_aktuel_setpunkt
  string_setpunkt_normal: !input string_setpunkt_normal
  _input_number: !input input_number
  input_number: '{{ states(_input_number) }}'

It is just wierd that in the documentation, this is the way they say it is supposed to be set up.

But I cant put the !input in front of the inputs - pretty wierd.

I finally got it to work… Jaay…

The solution is - dont get distracted by the configurator saying the variables !input is a unknown tag. as it does work. I found out that you can go in to the automations menu in the configurationenu and tap on the image
all the way to the left of the automation, on this page you can see if the information is passed on through your automation. Very nice feature.

I also had a problem with the input_number not being seen as the trigger entity. But everything is working now

blueprint:
  name: set temp in HA for IHC varmestyring V3
  description: Uses a input_number to set the temperatur in the IHC varmestyring funktionsblok
  domain: automation
  input:
    input_number:
      name: temp
      selector:
        entity:
          domain:
            input_number
    aktuel_setpunkt:
      name: ID aktuel setpunkt
      selector:
        number:
          min: 0
          max: 9999999999
          mode: box
    setpunkt_normal:
      name: ID Setpunkt normal
      selector: 
        number:
          min: 0
          max: 999999999
          mode: box
variables:
  aktuel_setpunkt_id: !input aktuel_setpunkt
  setpunkt_normal_id : !input setpunkt_normal
  _input_number: !input input_number
  input_temp : '{{ states(_input_number) | float }}'
  

trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: !input input_number
          
action:
# set aktuel setpunkt
  - service: ihc.set_runtime_value_float
    data_template:
      ihc_id: "{{ aktuel_setpunkt_id }}"
      value: "{{ input_temp }}"
# set setpunkt normal
  - service: ihc.set_runtime_value_float
    data_template:
      ihc_id: "{{ setpunkt_normal_id }}"
      value: "{{ input_temp }}"
mode: single

Thansk to you all for helping, I took a little advice from all of you to get it to work. And some from this post: Passing a variable to a service call in a Blueprint

You misunderstood the documentation; you were not doing what it suggested.

This is a YAML directive:

!input some_variable

It serves as a placeholder for a value. The YAML processor replaces the placeholder with its actual value.

For example:

some_option: !input some_variable

gets replaced with the value of some_variable. It the value is 100 then the YAML processor does this:

some_option: 100

What the YAML processor will not do is alter the contents of a Jinja2 template. That’s why when you did this it failed to work:

  input_number: '{{states("{{ !input input_number }}")}}'

Everything between the {{ ... }} is meant for the Jinja2 interpreter, not for the YAML processor. In addition, it was an invalid template because you cannot nest templates.

That’s why the documentation states inputs are YAML tags and not template variables. It continues to explain you first need to assign the input to a script variable and then you can reference the script variable in the template.

Which is what wizbang suggested (and deserves to be marked as the Solution post because it was first to offer the correct solution):

  _input_number: !input input_number
  input_temp : '{{ states(_input_number) | float }}'

I will set him as the solution, but that was not my first problem, the first problem was that the configurator said that

variables:
  some_var: !input my_var

had an unknown tag ( !input) in the variables section, but that just seems to be an error in the configurator. Because even after it is working it still says there is a problem. This was the first problem I tried to fix, if I knew that it actually wasn’t an error I could have continued and found the other problem. But I will let him have the solution :slight_smile:

But I have learned a valuable lesson about variables :smiley:

Thank you for clarifying on the subject

Post the entire message it reports now, for the latest blueprint you posted above.

It is a little odd, now I have exported the blueprint to another Home Assistant installation and this says there are no issues… I am setting up Home Assistant multiple places, so I dont have the Home Assistant installation where I made the blueprint at hand right now.

But I will send a picture later. Maybe it is because it isn’t running the latest version


Here you go

If you run Configuration > Server Controls > Check Configuration, does it also report that line in the automation?

Nope, only in the file editor

That’s what I thought.

The File Editor Add-on is independent of Home Assistant. My guess is whatever rules it uses to check YAML syntax probably haven’t been updated.

The real deal is Developer Tools > Server Controls > Check Configuration. If it spots an error, Home Assistant is likely to refuse to load the defective configuration until the error is corrected.