Home assistant service call from an Esphome node to another node

Hi, I have a strange behaviour in an Esphome script: in an automation routine I need to call a service in HA that switch on another entity in another esphome device. It seems simple but If I call the service from the automation it works, If I call from a script it makes the device reboot. Why?

EXAMPLE:

rf_bridge:
  on_code_received:
    then:
    - if:
        condition:
          lambda: 'return (data.code - 123456789);'
        then:
        else:
          - homeassistant.service:
              service: switch.turn_on
              data:
                entity_id: switch.test1
            // this call works    
    - if:
        condition:
          lambda: 'return (data.code - 987654321);'
        then:
        else:
          - script.execute: script1
         
script:
  - id: script1
    mode: single
    then:
      - homeassistant.service:
           service: switch.turn_on
           data:
             entity_id: switch.test1
          //this one not, and reboot device

The first problem I noticed is that all device names are lower case.

Sorry for capslock, consider lowercase, I just renamed my entity for clarity.
I could have just call from the automation, but I need to filter the multiple received RF signal, so I used a script single mode…

EDIT:

Probably there is a problem handling multiple (2/3 max) automation:
if I delay before HA service call in order to wait for busy automation, it works:


- id: script1
    mode: single
    then:
      - delay: 1s
      - homeassistant.service:
          service: switch.toggle
          data:
            entity_id: switch.test1

Really helpful to post your code but not your code.

Do you need wifi settings too? I think when looking for a problem it’s best to remove all unnecessary parts to focus on the defect. In this case, as I have already written, the bug occurs if the same radio code is received 2 or three times in a short time; if the script is still running, despite being in single mode,The service call generates a reboot(memory?). By keeping the loop busy with a delay I solved it. It would be advisable to be able to filter the signals received directly in the automation…