Passing entity_id as a variable in a script failing validation

I’ve dug around the forums for this, but I haven’t seen anyone that has had this issue yet. I’m trying to create a script that notifies a person only if they are home. I’ve found that this:

alias: Text KP
variables:
  target: person.kp
  data: notify.mobile_app_traveller
sequence:
  - condition: state
    entity_id: person.kp
    state: home
  - service: '{{ data }}'
    data:
      message: test
mode: single

works, but this:

alias: Text KP
variables:
  target: person.kp
  data: notify.mobile_app_traveller
sequence:
  - condition: state
    entity_id: '{{ target }}'
    state: home
  - service: '{{ data }}'
    data:
      message: test
mode: single

generates this error on saving:

Message malformed: Entity ID {{ target }} is an invalid entity ID for dictionary value @ data['sequence'][0]['entity_id']

What am I missing here?

You can’t use a template there. You could rewrite that condition like this:

  - condition: template
    value_template: "{{ is_state(target, 'home') }}"

That works, thanks!

Do conditions just only support templates in the template condition?

As an item in a script sequence, yes. Outside of an explicit template trigger/condition, templates are generally allowed in a service: and in target: and data: blocks, but the docs will show/tell you where they’re accepted, and in what form.