Calling a script from within a script not possible?

I need to send a command multiple times (turn on a chime) until a condition is met (alarm stopped), but the below code gives error: not possible to call a script within a script? I tried also to make two scripts, but receive error as well

script:
  trigger_siren_three:
    alias: 'Turn on siren three'
    sequence:
      - condition: state
        entity_id: alarm_control_panel.house
        state: 'triggered'
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/rf-bridge/backlog'
          payload: 'rfkey16'
      - service: script.turn_on
        entity_id: trigger_siren_three

nvalid config for [script]: not a valid value for dictionary value @ data[‘script’][‘trigger_siren_three’][‘sequence’][2][‘entity_id’]. Got ‘trigger_siren_three’. (See /config/configuration.yaml, line 30). Please check the docs at https://home-assistant.io/components/script/

Your entity is “script.trigger_siren_three” not just the second part. But doesn’t matter - HA doesn’t allow you to call a script from itself. You can create recursion by using two scripts that call each other.

I thought about that, but also puting a different name in the script called I still get error

  trigger_siren_three:
    alias: 'Turn on siren three'
    sequence:
      - condition: state
        entity_id: alarm_control_panel.house
        state: 'triggered'
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/rf-bridge/backlog'
          payload: 'rfkey16'
      - service: script.turn_on
        entity_id: trigger_siren_three_loop

Invalid config for [script]: not a valid value for dictionary value @ data[‘script’][‘trigger_siren_three’][‘sequence’][2][‘entity_id’]. Got ‘trigger_siren_three_loop’. (See /config/configuration.yaml, line 30). Please check the docs at https://home-assistant.io/components/script/

What about:

      - service: script.turn_on
        entity_id: script.trigger_siren_three_loop
1 Like

Ehhh, I am getting old …
Calling within a script the same script (itself) is allowed? The below code does not give any error when checked in configuration validation

  trigger_siren_three:
    alias: 'Turn on siren three'
    sequence:
      - condition: state
        entity_id: alarm_control_panel.house
        state: 'triggered'
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/rf-bridge/backlog'
          payload: 'rfkey16'
      - service: script.turn_on
        entity_id: script.trigger_siren_three

that won’t work. Scripts can only be run 1 at a time. And because you script is running when you call it, nothing will happen because it’s already running. Making a loop w/ scripts is a pain in the ass.

Something like this then? Maybe adding a delay??

  trigger_siren_three:
    alias: 'Turn on siren three'
    sequence:
      - condition: state
        entity_id: alarm_control_panel.house
        state: 'triggered'
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/rf-bridge/backlog'
          payload: 'rfkey16'
      - service: script.turn_on
        entity_id: script.trigger_siren_three_loop
  trigger_siren_three_loop:
    alias: 'Turn on siren three loop'
    sequence:
      - condition: state
        entity_id: alarm_control_panel.house
        state: 'triggered'
      - service: mqtt.publish
        data_template:
          topic: 'cmnd/rf-bridge/backlog'
          payload: 'rfkey16'
      - service: script.turn_on
        entity_id: script.trigger_siren_three

I mean, that would just loop forever. You might need a delay to slow it down too.

The unmet condition will not stop it? Until alarm is triggered the siren should sound

Will add a delay to both

Ah, I didn’t notice the condition. That will break the loop. Just as long as you know it will loop forever if the alarm never stops triggering.

Also, is an automation calling this? Have you looked into the alert component by chance?

EDIT: That might not help you, not sure what you’re doing with that MQTT topic.

I am sending an rf signal from Sonoff RF bridge to an rf siren. Need the loop because the command is for one chime only (i was surprised the rf siren works this way)

1 Like

Yes usually alarm work that way, the siren should never stop until alarm is off