I am attempting to create my first blueprint and I’m using Studio Code Server to create the file. I copied and pasted the YAML from a working automation as the initial basis for the blueprint, inserted the code at the top to define the blueprint and input variables but when I replace the entities in the automation code with !input tags I get an “Unresolved tag: !input” error for every one.
I thought I was doing something fundamentaly wrong with the blueprint definition, but even pasting code from the Home Assistant documentation into the file gives me the same error. This makes me think it’s some sort of configuration issue with Studio Code Server. However, I can’t find any mention of this with searches and now I’m stuck.
Would anyone be able to point me in the right direction for a solution to this, please?
Post the blueprint. Also automations do not support the yaml from blueprints.
I pasted the automation yaml into a blueprint file to amend not the other way round.
As I said, I get the error with the automation code provided in the Home Assistant documentation where every !input generates an error, which is:
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target: !input light_target
Sorry, that reply looked a bit blunt. Thanks for the quick response.
Yes, I’m trying to clarify how you are attempting to run this. That blueprint looks fine, however if you tried to treat that like an automation, it will fail validation. Meaning, you have to import that as a blueprint, you can’t copy/paste that into your automations.
Sorry if I am being unclear. I haven’t got as far as running the blueprint. The error is being raised while I am editing in Studio Code Server.
I would ignore the errors in studio code editor as they probably don’t understand blueprints. If it thinks it’s an automation, it will have squiggles.
I suspected that may be the case and thought this was something to do with configuring Studio code server. I started by watching a tutorial on blueprints by Smart Home Junkie and he used the editor without any of these errors.
is your blueprint in the correct blueprint location?
It’s in the blueprints folder
Is it in a sub directory or in the root directory?
I’ve tried placing it in the root, automation, home assistant and my own sub directory with no success
For what it’s worth, I just set your blueprint up and it’s working fine in my system when located in config\blueprints\automation
.
There are some deprecation warnings, but they go away when you use filter properly.
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
filter:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target: !input light_target
It turns out that it works fine for me too except in the editor. Most annoying but workable.
What do you mean by using the filter properly? What filter is that?
Ah, filter in the code!
Much appreciate all of your assistance. Thanks!
Fixed it!!!
I feel really, really, really stupid! The whole issue was down to a typo in the file extension name. Corrected my fat finger typing from .yalm to .yaml and the !input errors disappeared like magic!
Thanks again for all your assistance whern the issue was my being a dolt!
Thank you, your error helped me fix mine also. I didn’t put the file extension…