Script trace order wrong

Hello everyone,

Today I noticed something strange while trying to debug a script. I’m using the trace for this script, and I noticed the first step in the script is shown above the starting of the script (turned on). This does not seem logical at all, but maybe I am missing something? Here is the yaml for the script, I run it manually for debugging.

alias: TV kijken
sequence:
  - service: remote.send_command
    target:
      entity_id: remote.rm_pro_plus
    data:
      device: radio
      command: cd
    alias: Stereo aanzetten (cd)
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: remote.send_command
    target:
      entity_id: remote.rm_pro_plus
    data:
      device: radio
      command: tvsound
    alias: Stereo op tv geluid (tv-sound)
  - service: switch.turn_on
    target:
      entity_id:
        - switch.stopcontact_tv_woonkamer
    data: {}
    alias: TV schakelaar aanzetten
  - service: media_player.turn_off
    target:
      entity_id: media_player.woonkamer_stereo
    data: {}
    alias: Woonkamer stereo uitzetten
  - alias: >-
      Als script niet wordt gestart vanuit playstation script, dan volume
      regelen
    if:
      - condition: not
        conditions:
          - condition: template
            value_template: "      {{ from_playstation }}"
        alias: Testen of variabele niet bestaat
    then:
      - service: script.stereo_volume_regulier
        data: {}
        alias: Script 'Volume regulier' starten
mode: single

I also added a screenshot of the trace.
Does anybody have some guidance maybe?
Thanks everybody!!

There’s nothing to worry about here. All my scripts do the same. I’m not sure if it’s a race condition, or perhaps the state of the script is set to on only once the first command is executed. Either way it’s not affecting anything.

Okay thanks for the insight. Just thought it was strange, but as long as the script is working correctly (and it does, as far as I can tell), we’ll learn to live with it then.

FWIW, I checked the Trace Timeline of all my scripts and none report turning themselves on.

For example, here’s the Trace Timeline for script.evening_interior. The timeline doesn’t show that the script was turned on.

image

Just a guess, but I wonder if it’s a consequence of having excluded the script domain from recorder (i.e. a script’s state-changes are not recorded in the database).

image