From a061d88fe4e654bf8ead74900aca5feaa04af0c1 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Wed, 22 Jun 2022 00:19:20 +0300 Subject: [PATCH] Music improvements --- .../home_dashboard/preferences_dashboard.yaml | 31 +++++++++---------- .../devices/bathroom/bathroom_switch.yaml | 1 - .../devices/bedroom/bedside_switch.yaml | 4 +-- config/packages/modes/simulation.yaml | 18 +++++++++-- config/packages/modules/media/music.yaml | 20 ++++++++++-- config/packages/routines/good_night.yaml | 6 +++- config/packages/routines/leaving_home.yaml | 6 +++- config/packages/routines/waking_up.yaml | 25 +++++++++++++-- 8 files changed, 81 insertions(+), 30 deletions(-) diff --git a/config/lovelace/home_dashboard/preferences_dashboard.yaml b/config/lovelace/home_dashboard/preferences_dashboard.yaml index 6fe603b..d2c6407 100644 --- a/config/lovelace/home_dashboard/preferences_dashboard.yaml +++ b/config/lovelace/home_dashboard/preferences_dashboard.yaml @@ -76,22 +76,6 @@ entity: input_boolean.simulation_mode name: Simulation - - type: horizontal-stack - cards: - - type: custom:button-card - template: v3_button - entity: binary_sensor.pi_hole_enabled - name: Pi-Hole - icon: mdi:pi-hole - - type: custom:button-card - template: v3_button - entity: switch.mercury_home_mode - name: Mercury - - type: custom:button-card - template: v3_button - entity: input_boolean.coming_home_play_music - name: Coming home music? - - type: horizontal-stack cards: - type: custom:button-card @@ -112,13 +96,28 @@ service_data: entity_id: input_select.guest_bedroom_mode + - type: horizontal-stack + cards: + - type: custom:button-card + template: v3_button + entity: binary_sensor.pi_hole_enabled + name: Pi-Hole + icon: mdi:pi-hole + - type: custom:button-card + template: v3_button + entity: switch.mercury_home_mode + name: Mercury + - type: custom:decluttering-card template: v3_section_title variables: - title: Media - type: entities entities: + - input_boolean.coming_home_play_music - input_number.bathroom_high_volume + - input_number.wake_up_volume + - input_text.wake_up_spotify_playlist - type: vertical-stack cards: diff --git a/config/packages/devices/bathroom/bathroom_switch.yaml b/config/packages/devices/bathroom/bathroom_switch.yaml index 45822ea..3dfff0a 100644 --- a/config/packages/devices/bathroom/bathroom_switch.yaml +++ b/config/packages/devices/bathroom/bathroom_switch.yaml @@ -1,7 +1,6 @@ input_number: bathroom_high_volume: name: Bathroom high volume - mode: box min: 0 max: 1 step: 0.05 diff --git a/config/packages/devices/bedroom/bedside_switch.yaml b/config/packages/devices/bedroom/bedside_switch.yaml index 362de1d..7a9e3d8 100644 --- a/config/packages/devices/bedroom/bedside_switch.yaml +++ b/config/packages/devices/bedroom/bedside_switch.yaml @@ -35,8 +35,8 @@ automation: # brightness_pct: "{{ is_state('input_select.bedroom_mode', 'night') | iif(40, 100)}}" double_click: - - service: media_player.media_play_pause - entity_id: media_player.master_bedroom + - service: light.toggle + entity_id: light.bedside hold: - service: script.toggle_bedroom_mode diff --git a/config/packages/modes/simulation.yaml b/config/packages/modes/simulation.yaml index 7748401..0f55d9e 100644 --- a/config/packages/modes/simulation.yaml +++ b/config/packages/modes/simulation.yaml @@ -46,7 +46,11 @@ automation: - service: light.turn_off entity_id: light.all - service: media_player.media_stop - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room - alias: Simulation mode · 1100 trigger: @@ -61,7 +65,11 @@ automation: at: "14:00:00" action: - service: media_player.media_stop - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room - alias: Simulation mode · 1700 trigger: @@ -78,4 +86,8 @@ automation: at: "22:00:00" action: - service: media_player.media_stop - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room diff --git a/config/packages/modules/media/music.yaml b/config/packages/modules/media/music.yaml index 1c9703e..a0ef2e4 100644 --- a/config/packages/modules/media/music.yaml +++ b/config/packages/modules/media/music.yaml @@ -1,16 +1,30 @@ script: - music_play: - alias: Music · Play + music_prepare: + alias: Music · Prepare + mode: queued sequence: - service: script.sonos_join_bedroom - service: media_player.volume_set - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room data_template: volume_level: "{{ volume_level | default(0.2) }}" - service: media_player.shuffle_set entity_id: media_player.master_bedroom data_template: shuffle: "{{ shuffle | default(true) }}" + + music_play: + alias: Music · Play + mode: queued + sequence: + - service: script.music_prepare + data_template: + shuffle: "{{ shuffle | default(true) }}" + volume_level: "{{ volume_level | default(0.2) }}" - service: media_player.select_source entity_id: media_player.master_bedroom data_template: diff --git a/config/packages/routines/good_night.yaml b/config/packages/routines/good_night.yaml index 9df67b1..cfdaee5 100644 --- a/config/packages/routines/good_night.yaml +++ b/config/packages/routines/good_night.yaml @@ -31,7 +31,11 @@ script: alias: Routine · Going to sleep sequence: - service: media_player.media_stop - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room # Turn off everything else - service: homeassistant.turn_off diff --git a/config/packages/routines/leaving_home.yaml b/config/packages/routines/leaving_home.yaml index d47b5f5..8e44930 100644 --- a/config/packages/routines/leaving_home.yaml +++ b/config/packages/routines/leaving_home.yaml @@ -13,7 +13,11 @@ script: - fan.philips_airpurifier - service: media_player.media_stop - entity_id: group.all_sonos + entity_id: + - media_player.master_bedroom + - media_player.bathroom + - media_player.kitchen + - media_player.living_room - service: light.turn_on entity_id: diff --git a/config/packages/routines/waking_up.yaml b/config/packages/routines/waking_up.yaml index dcacb00..36a1564 100644 --- a/config/packages/routines/waking_up.yaml +++ b/config/packages/routines/waking_up.yaml @@ -1,3 +1,16 @@ +input_text: + wake_up_spotify_playlist: + name: Waking up Spotify playlist + icon: mdi:spotify + +input_number: + wake_up_volume: + name: Waking up volume + min: 0 + max: 1 + step: 0.05 + icon: mdi:volume-high + script: routine_waking_up: alias: Routine · Waking up @@ -29,10 +42,16 @@ script: # data: # message: "Here's some music to start the day!" # - delay: 00:00:02 - - service: script.music_play - data: - volume_level: 0.1 + - service: script.music_prepare + data_template: + volume_level: "{{ states('input_number.wake_up_volume') | float }}" shuffle: true + - service: media_player.play_media + target: + entity_id: media_player.master_bedroom + data_template: + media_content_type: "music" + media_content_id: "{{ states('input_text.wake_up_spotify_playlist') }}" routine_bedroom_morning: alias: Routine · Bedroom · Morning