diff --git a/configuration/automations/bathroom-music-button.yaml b/configuration/automations/bathroom-music-button.yaml index f7b4f78..000f18d 100644 --- a/configuration/automations/bathroom-music-button.yaml +++ b/configuration/automations/bathroom-music-button.yaml @@ -40,12 +40,7 @@ entity_id: media_player.bathroom data: shuffle: true - - service: media_player.play_media - target: - entity_id: media_player.bathroom - data: - media_content_id: "{{ states('input_text.bathroom_playlist') }}" - media_content_type: music + - service: script.bathroom_music_play - id: bathroom-music-button-play alias: '[Bathroom] Music button - play' @@ -68,16 +63,7 @@ entity_id: media_player.bathroom state: playing action: - - service: media_player.shuffle_set - entity_id: media_player.bathroom - data: - shuffle: true - - service: media_player.play_media - target: - entity_id: media_player.bathroom - data: - media_content_id: "{{ states('input_text.bathroom_playlist') }}" - media_content_type: music + - service: script.bathroom_music_play - id: bathroom-music-button-pause alias: '[Bathroom] Music button - play/pause' diff --git a/configuration/configuration.yaml b/configuration/configuration.yaml index a073f60..f0233be 100644 --- a/configuration/configuration.yaml +++ b/configuration/configuration.yaml @@ -101,6 +101,11 @@ input_select: - Party - Away icon: "mdi:home" + music_service: + name: Music service + options: + - Spotify + - Apple Music input_text: bathroom_playlist: name: Bathroom playlist diff --git a/scripts/120.music-bathroom.yaml b/scripts/120.music-bathroom.yaml new file mode 100644 index 0000000..5bfc676 --- /dev/null +++ b/scripts/120.music-bathroom.yaml @@ -0,0 +1,29 @@ +bathroom_music_play: + alias: '[Bathroom] Music play' + sequence: + - choose: + - conditions: + - condition: state + entity_id: input_select.music_service + state: 'Apple Music' + sequence: + - service: media_player.select_source + data: + source: Party 2.1 + target: + entity_id: media_player.bathroom + - conditions: + - condition: state + entity_id: light.hallway_light + state: 'Spotify' + sequence: + - service: media_player.play_media + target: + entity_id: media_player.bathroom + data: + media_content_id: "{{ states('input_text.bathroom_playlist') }}" + media_content_type: music + - service: media_player.shuffle_set + entity_id: media_player.bathroom + data: + shuffle: true