Just part of the script runs

Hi,
I have a script that triggers several scripts, sometime it works, sometime just part of the included scripts are triggered. I cannot find any logic to it.

The script are suppose to turn on Zone 1 and Zone 2 on my Denon reciever and also set the volume on both the Zones. Works on their own and sometimes all together. I tried with delays if it could have to do with the reciever having problems to cope with several commands at the same time - but still same result - works sometimes, and parts of the script sometimes.

Ideas?

Share the script! Be sure to use proper formatting (see the blue box up top for tips).

This is the main script:

'1517488964572':
  alias: Denon zones on
  sequence:
  - data:
      entity_id: script.1516823953771
    service: homeassistant.turn_on
  - data:
      entity_id: script.1516824075921
    service: homeassistant.turn_on
  - data:
      entity_id: script.1516824237807
    service: homeassistant.turn_on
  - data:
      entity_id: script.1516824325735
    service: homeassistant.turn_on
  - data:
      entity_id: switch.baslada_vardagsrum
    service: switch.turn_on
  - data:
      entity_id: media_player.denon
      volume_level: '0.5'
    service: media_player.volume_set

These are the scripts that are suppose to be triggered:

'1516823953771':
  alias: X - Source vardagsrum - no delay
  sequence:
  - data:
      entity_id: media_player.denon_avrx2300w
      source: DVD
    service: media_player.select_source

'1516824075921':
  alias: X - Set volume vardagsrum - delay 2 sek
  sequence:
  - data:
      entity_id: media_player.denon_avrx2300w
      volume_level: '0.5'
    service: media_player.volume_set
  - delay: 00:00:02

'1516824237807':
  alias: X - Source matsal - delay 3 sek
  sequence:
  - data:
      entity_id: media_player.matsal
      source: DVD
    service: media_player.select_source
  - delay: 00:00:03

'1516824325735':
  alias: X - Vol set matsal - delay 5 sek
  sequence:
  - data:
      entity_id: media_player.matsal
      volume_level: '0.5'
    service: media_player.volume_set
  - delay: 00:00:05Preformatted text

You missed the part where they said to use proper formatting…

select all the code portions of your post and click the </> symbol in the editor window.

no one can help if they can’t see the code formatted exactly the way you have it in your configuration.

I’m fairly sure that all of your delays are doing nothing meaningful.

The turn_on service calls from the main script are non-blocking. That means that each sub-script is going to run at exactly the same time, perform their action, and then call for a delay. You are better off adding the delays to your main script. In fact, I’m not even sure why you have sub-scripts.

If you show all of the scripts in the GUI and watch their state you should see them all flip on, and then off at different intervals based on your delays.

1 Like

I can’t find it now but I remember (and obey) not to use numbers in script names or at least not to start with numbers. Something like you have to format it different elsewhere.

It was here, I thought I had problem with script numbers but perhaps it was only entities in templating.

If your template uses an entity_id that begins with a number (example: states.device_tracker.2008_gmc) you must use a bracket syntax to avoid errors caused by rendering the entity_id improperly. In the example given, the correct syntax for the device tracker would be: states.device_tracker[‘2008_gmc’]

1 Like

Hi,
Ok, so in my case the call for the reciever avrx2300w might be the problem you mean?
Or the call for the scripts? “script.1516824325735”

Thanks,

Per-Henrik

There is nothing wrong with your script names, otherwise you would be seeing errors in your log and it would probably throw errors on a card in the front end that it couldn’t load the component. However, those are poor script names, since they don’t convey meaning. Yes, they do “cause problems” in templates, but as pointed out also that can be solved with [], so they aren’t a problem.

Anyways, try this since it is what I suggested (actual sequential calls with delays) and will probably work if you extend delays to fix anything that doesn’t execute properly (I hope formatting is correct, it is based off of what you posted).

turn_on_denon_zones:
  alias: Denon zones on
  sequence:
    - service: media_player.select_source
      data:
        entity_id: media_player.denon_avrx2300w
        source: DVD
    - service: delay 00:00:01
    - service: media_player.volume_set
      data:
        entity_id: media_player.denon_avrx2300w
        volume_level: '0.5'
    - service: delay 00:00:01
    - service: media_player.select_source
      data:
        entity_id: media_player.matsal
        source: DVD
    - service: delay 00:00:03
    - service: media_player.volume_set
      data:
        entity_id: media_player.matsal
        volume_level: '0.5'
    - service: delay 00:00:05
    - service: switch.turn_on
      data:
        entity_id: switch.baslada_vardagsrum
    - service: service: media_player.volume_set
      data:
        entity_id: media_player.denon
        volume_level: '0.5'