#Troubleshooting Scripts and events

1 messages · Page 1 of 1 (latest)

dull condor
#

Hi everyone, need some pointers. I have set up a script then setup a button on my dashboard (and an automation). I've tried it and it worked..... at least once lol. Now, however, it'll start and a second later go idle. I can't get it to fire off now, and not sure how to isolate. Here are my bits, perhaps someone can see the galring error?

Script

alias: Play White Noise Loop
sequence:
  - target:
      entity_id: media_player.home_assistant_voice_90210_media_player
    data:
      media_content_id: >-
        media-source://media_source/local/Unraid/media/music/Sleep/White-Noise-60min.mp3
      media_content_type: music
    action: media_player.play_media
  - wait_template: >-
      {{ not is_state('media_player.home_assistant_voice_90210_media_player',
      'playing') }}
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 100
  - target:
      entity_id: script.play_white_noise_loop
    action: script.turn_on
    data: {}
description: ""

Button:

show_name: true
show_icon: true
type: button
name: Play White Noise
icon: mdi:sleep
tap_action:
  action: call-service
  service: script.play_white_noise_loop

Any ideas would be super appreciated!

low rapids
#

Kind of an odd looking script... maybe you need to use mode: restart ?

#

If you try to call a mode: single script from itself it might just refuse to start.

#

I could image that occasionally working due to race conditions, but don't know if it will work reliably.

dull condor
dapper ether
#

You don't need the script at all. Just do in the button:

tap_action:
  action: call-service
  service: media_player.play_media
  target:
    entity_id: ...
  data:
    media_content_id: ...
#

Unless you intend to play this media through other means besides pressing this button?

dull condor
#

I have 2 use cases; an automation where other lights turn off/dim/etc then it plays OR by a button on the dashboard.

#

I've deleted it out, and tried to play with the builder again, and this seems to be working:

alias: Play White Noise Loop
sequence:
  - metadata:
      title: White-Noise-60min.mp3
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
        - media_content_type: ""
          media_content_id: media-source://media_source/local/Unraid
        - media_content_type: ""
          media_content_id: media-source://media_source/local/Unraid/media
        - media_content_type: ""
          media_content_id: media-source://media_source/local/Unraid/media/music
        - media_content_type: ""
          media_content_id: media-source://media_source/local/Unraid/media/music/Sleep
    target:
      entity_id: media_player.home_assistant_voice_90210_media_player
    data:
      media_content_id: >-
        media-source://media_source/local/Unraid/media/music/Sleep/White-Noise-60min.mp3
      media_content_type: audio/mpeg
    action: media_player.play_media
  - delay:
      milliseconds: 100
  - metadata: {}
    target:
      entity_id: media_player.bedroom_speaker
    data:
      repeat: one
    action: media_player.repeat_set
description: Play White Noise