Blueprint with script as input field

I’m rather new to HA and still getting to grips with YAML. Unfortunately, I couldn’t find an answer to my problem even after searching the forums etc. for quite some time.

I’m trying to create a blueprint that allows for a script to be selected as input, which is then run as one of the actions.

What I have so far:

blueprint:
  input:
    script_target:
      name: Script
      description: Script to run when motion is detected
      selector:
        target:
          entity:
            domain: script

action:
  - alias: "run script"
    service: !input "script_target"
    data: {}

What am I missing or doing wrong? Any help and input appreciated!

Remove the " around “script_target”.

Thanks @Didgeridrew, but I’ve already tried that. These have actually only been inserted by the formatting helper of this forum, i.e. there are no " around script_target in my blueprint. But it’s still not working. Any other idea?

I the current form, I can save the blueprint and even create a new automation from it. However, when I try to save this new automation, I get an error saying

Message malformed: value should be a string for dictionary value @ data['action'][0]['service']

The issue is that you indicated a Target selector instead of an Entity selector. A Target selector will return a dictionary {'entity_id': 'script.example'} instead of just the entity ID.

blueprint:
  name: Script Selector
  description: ''
  domain: automation
  input:
    script_target:
      name: Script
      description: Script to run when motion is detected
      selector:
        entity:
          filter:
            - domain: script
trigger:
  - platform: state
    entity_id: binary_sensor.example
action:
  - alias: "run script"
    service: !input script_target

EDIT: Removed Options after seeing underlying issue with selector type.

1 Like

I’ve tried your option 1 and it worked like a charm. You are my hero!

Thank you very much!