Play Playlist Depending on the Day of Week at Sun Set

alias: Play Playlist Depending on the Day of Week
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "+00:30:00"
condition: []
action:
  - choose:
      - conditions:
          - condition: time
            weekday: [mon, thu, sun]
        sequence:
          - service: media_player.play_media
            data:
              media_content_type: AMAZON_MUSIC
              media_content_id: Evening Song tsk 1
            target:
              device_id: 772a5e877c0cfdc11e0573c1e59ab6c5
      - conditions:
          - condition: time
            weekday: [tue, fri]
        sequence:
          - service: media_player.play_media
            data:
              media_content_type: AMAZON_MUSIC
              media_content_id: Evening Song tsk 2
            target:
              device_id: 772a5e877c0cfdc11e0573c1e59ab6c5
    # ELSE
    default:
      - service: media_player.play_media
        data:
          media_content_type: AMAZON_MUSIC
          media_content_id: Evening Song tsk 3
        target:
          device_id: 772a5e877c0cfdc11e0573c1e59ab6c5
      
mode: single

Please do comment if there is better way to do this

Edit: amazon music has problem with Playlist Names “Evening Song tsk 2” change to “Evening Song tsktwo” this resolves issues, "Playlist not found"

1 Like

Another way to do the same thing:

alias: Play Playlist Depending on the Day of Week
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "+00:30:00"
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_type: AMAZON_MUSIC
      media_content_id: >
        {{ 'Evening Song tsk 1' if now().isoweekday() in [1, 4, 7] else
           'Evening Song tsk 2' if now().isoweekday() in [2, 5] else
           'Evening Song tsk 3' }}
    target:
      device_id: 772a5e877c0cfdc11e0573c1e59ab6c5
mode: single