Skip to content

Instantly share code, notes, and snippets.

@sethiele
Created November 30, 2023 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethiele/03f8cc3bbee527f5371928c1eb15409d to your computer and use it in GitHub Desktop.
Save sethiele/03f8cc3bbee527f5371928c1eb15409d to your computer and use it in GitHub Desktop.
Spiele Weihnachtslieder (Musik) über einen Button im UI.
- type: vertical-stack
title: Weihnachtsmusik
cards:
- type: entities
entities:
- entity: input_select.player_auswahl # Ein Input Select Helper mit der Liste der Speaker
- type: grid
cards:
- type: picture
image: https://i.scdn.co/image/ab67706f000000022548f76332c45eb3d57dba43 # Spotify-Cover
tap_action:
action: call-service
service: script.play_xmas_songs # Script (siehe script_play_xmas_songs.yaml)
data:
playlist: "https://open.spotify.com/playlist/37i9dQZF1DXaf9K2UnDhgp?si=2810f5a91a964a54" # URL der Playliste als Parameter
- type: picture
image: https://i.scdn.co/image/ab67706f00000002a9081bbbac1ab12e085091a4
tap_action:
action: call-service
service: script.play_xmas_songs
data:
playlist: "https://open.spotify.com/playlist/37i9dQZF1DXb7KOnsvmh8V?si=622f8c91bfe74a34"
play_xmas_songs:
mode: single
alias: Spiele Weihnachtslieder ab
variables:
player_select: # Helper Variable um aus der Auswahl des input_select.player_auswahl in Entity-Namen umzuwandeln
arbeitszimmer_sonos: media_player.sonos_arbeitszimmer # Name des input_select.player_auswahl klein und mit _
wohnzimmer_sonos: media_player.sonos_wohnzimmer
schlafzimmer_sonos: media_player.sonos_schlafzimmer
kinderzimmer_sonos: media_player.sonos_kinderzimmer
ueberall: media_player.uberall # Alexa
player: "{{ states('input_select.player_auswahl').lower()|replace(' ', '_') }}" # Hier wird die Auswal in eine Variable geschrieben
sequence:
- service: media_player.play_media
target:
entity_id: "{{player_select[player]}}" # Player wird ausgewählt (Zeile 5 - 10 & 11)
data:
media_content_type: "music"
media_content_id: "{{ playlist }}" # Parameter an das script aus dem Frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment