Run a script with same name as an input boolean?

Hi,

I have a trigger which is based on the state of an input boolean. I change the boolean and a script runs. I have 5 of these, booleans, and 5 scripts. The object_id of each boolean matches the object_id of a script.

I would like to combine the automations in to one, such as:

- alias: "heating boost to a room"
  trigger:
    - platform: state
      entity_id: input_boolean.heating_boost_james_room
      from: 'off'
      to: 'on'
  action:
    - service: input_number.set_value
      data:
        value: 5
      target:
        entity_id: input_number.heating_boost_upstairs
    - delay:
        seconds: 2
    - service: "script.{{trigger.object_id}}"

This dosn’t appear to work and I am too much of an idiot to figure out why - can anyone help? :slight_smile:

trigger.to_state.object_id

1 Like

Really helpful thanks. I’ve realised that one thing I need to do is list out the entity IDs in the state trigger, which is something I’ve found with another automation recently. Might you be able to suggest a suitable method of using templates or wildcards in entity_id of a state trigger? :slight_smile: