Question about usage of targets

Running homeassistant (2020.12.2) on docker

I have this automation

blueprint:
  name: Presence Automations
  description: 'Disable automation(s) when someone arrives. Re-enable them when they
    leave.'
  domain: automation
  input:
    person:
      name: Person
      description: 'Select the person to be monitored.'
      selector:
        entity:
          domain: person
    automation:
      name: Automation
      description: 'Select the automation(s) that need to be turned off.'
      selector:
        target:
          entity:
            domain: automation
    inverted:
      name: Invert Blueprint
      description: 'This will cause the selected automations to enable when the person
        comes home, instead of disabling them as per default. This will in turn disable
        the automation when the person leaves.'
      default: false
      selector:
        boolean: {}
  source_url: https://gist.github.com/dbeltman/b90156effaaa0ea963642334934e541e
trigger:
- platform: state
  entity_id: !input 'person'
condition: []
variables:
  inverted: !input 'inverted'
action:
- choose:
  - conditions:
    - condition: state
      entity_id: !input 'person'
      state: home
    sequence:
    - choose:
      - conditions: '{{ inverted }}'
        sequence:
        - service: automation.turn_on
          data: {}
          target: !input automation
      default:
      - service: automation.turn_off
        data: {}
        target: !input automation
  - conditions:
    - condition: state
      entity_id: !input 'person'
      state: not_home
    sequence:
    - choose:
      - conditions: '{{ inverted }}'
        sequence:
        - service: automation.turn_off
          data: {}
          target: !input automation
      default:
      - service: automation.turn_on
        data: {}
        target: !input automation
  default: []

Which works! However when i change the input identifier from “automation” to “target_automation”, it throws me the following error. I’m doing this to make the input identifier less ambiguous.

Invalid config for [automation]: Missing input target_automation (See /config/configuration.yaml, line 9).

Here is the changed final blueprint which throws the error (so the only difference is prepending “automation” with “target_” on 5 occasions)

blueprint:
  name: Presence Automations
  description: 'Disable automation(s) when someone arrives. Re-enable them when they
    leave.'
  domain: automation
  input:
    person:
      name: Person
      description: 'Select the person to be monitored.'
      selector:
        entity:
          domain: person
    target_automation:
      name: Automation
      description: 'Select the automation(s) that need to be turned off.'
      selector:
        target:
          entity:
            domain: automation
    inverted:
      name: Invert Blueprint
      description: 'This will cause the selected automations to enable when the person
        comes home, instead of disabling them as per default. This will in turn disable
        the automation when the person leaves.'
      default: false
      selector:
        boolean: {}
  source_url: https://gist.github.com/dbeltman/b90156effaaa0ea963642334934e541e
trigger:
- platform: state
  entity_id: !input 'person'
condition: []
variables:
  inverted: !input 'inverted'
action:
- choose:
  - conditions:
    - condition: state
      entity_id: !input 'person'
      state: home
    sequence:
    - choose:
      - conditions: '{{ inverted }}'
        sequence:
        - service: automation.turn_on
          data: {}
          target: !input target_automation
      default:
      - service: automation.turn_off
        data: {}
        target: !input target_automation
  - conditions:
    - condition: state
      entity_id: !input 'person'
      state: not_home
    sequence:
    - choose:
      - conditions: '{{ inverted }}'
        sequence:
        - service: automation.turn_off
          data: {}
          target: !input target_automation
      default:
      - service: automation.turn_on
        data: {}
        target: !input target_automation
  default: []

In the docs they give an example as such:

~~~
  input:
      target_light:
      name: Lights
      description: The lights to keep in sync.
      selector:
        target:
          entity:
            domain: light
action:
  service: >
    {% if trigger.to_state.state == "on" %}
      light.turn_on
    {% else %}
      light.turn_off
    {% endif %}
  target: !input target_light

Am i missing something?
The doc example is basically what i’m doing,but for automations.

Thanks for your help in advance

If you created an automation with the first one and then changed the blueprint, then the automation will have the wrong key in it which would explain the error.

1 Like

That would explain a lot. I thought Reloading Automations was enough to give the associated automations the new key. Thanks for your answer, as i have now looked into automations.yaml and it gave me a clearer understanding of how homeassistant implements blueprints and its associated automations

1 Like