Script "mode: single": suppress "Script is already running!" warning

I am running a script that should never run multiple instances in parallel and parallel calls can be discarded (hence the mode: single). I know that there will be further calls while the script is running (the script contains repeat: and delay:). But this fills the ESP (wireless) log with Script is already running! (mode: single) messages. In Home Assistant there’s the option max_exceeded: silent. But this option seems not to exist in ESPHome.
Is there a way to suppress those warning messages in the ESP’s log output?

Example code that creates those messages:

interval:
  - interval: 100ms
    then:
      - script.execute: indicate_heater_level

script:
  - id: indicate_heater_level
    mode: single
    #max_exceeded: silent
    then: 
      - repeat:
          count: !lambda 'return (uint8_t)id(power_level_selection).active_index().value();'
          then:
            - output.turn_on: indicator_led
            - delay: 100ms
            - output.turn_off: indicator_led
            - delay: 200ms
      - delay: 1000ms

As a workaround you could only execute the script if it is not already running?

https://esphome.io/components/script.html#script-is-running-condition

Running the script only if it’s not already running is exactly the job of mode: single. But yes, doing the check yourself before running the actual script is an option. It just would be nice if you didn’t need to to get rid of the warning message.

In the end I did something different. I made the script an infinite loop that I start at bootup, and got rid of the interval. I used the interval more or less as a placeholder for the trigger of the script, implementing another trigger later (I thought I’d like to control whether the “LED flashing” is on or not). I found I don’t need it.

This solved the issue in this case (only because the prerequisite for it no longer exists), but I’d still like an option to explicitly state “I know the script might be running already; it’s fine; no need to tell me about”. It’s a poor man’s kind of exception (or here rather warning) handling, which is better than non at all. Showing someone (most likely myself :sweat_smile:) later that I know what is happening is good practice.

Code (which is NOT a solution to the original problem):

esphome:
  on_boot:
    - priority: 0
      then:
        - script.execute: indicate_heater_level

script:
  - id: indicate_heater_level
    mode: single
    then: 
      - while:
          condition:
            lambda: 'return 1;'
          then:      
            - repeat:
                count: !lambda 'return (uint8_t)id(power_level_selection).active_index().value();'
                then:
                  - output.turn_on: indicator_led
                  - delay: 100ms
                  - output.turn_off: indicator_led
                  - delay: 300ms
            - delay: 1000ms

Hi @Lupin

Have you tried this:

automation:
  - mode: single
    max_exceeded: silent

This is described in the documentation.

Yes, it’s in the documentation for Home Assistant. But we are talking about ESPHome here (see the category of the topic).