Files
fresh-home/components/packages/ambientsounds.yaml
T
2024-04-14 16:02:53 -04:00

195 lines
10 KiB
YAML

--- ###### CUSTOMIZE ----------------------------------------
# RESOURCES:a
# Credit to /u/dsgraham on Reddit - https://www.reddit.com/r/homeassistant/comments/9n0llr/google_ambient_sound_urls/
# Script adapted from Bob_NL on Home Assistant Forums - https://community.home-assistant.io/t/chromecast-radio-with-station-and-player-selection/12732
# Google webpage: https://support.google.com/googlehome/answer/7364558?hl=en
# Updating to use DLNA
homeassistant:
customize:
script.ambientsounds:
icon: mdi:play
friendly_name: Start Playing
###### GROUPS ----------------------------------------
group:
Ambient Sounds:
name: Ambient Sounds
entities:
- input_select.ambient_sound
- input_select.google_home
- script.ambientsounds
- input_number.volume_ambientsounds
Home Group:
name: Home Group
entities:
- media_player.great_room
- media_player.kitchen
- media_player.front_room_hub
- media_player.nursery_hub
- media_player.bathroom_mini
- media_player.master_bedroom_clock
- media_player.computer_area_hub
###### INPUT SELECT ------------------------------------------
input_select:
ambient_sound:
name: "Select Radio Station:"
options:
- Random White Noise
- Random Kids Noise
- Babbling Brook
- Female Baby Shusher
- Male Baby Shusher
- Country Night
- Fireplace
- Forest
- Female Lullaby
- Male Lullaby
- Ocean
- Oscillating Fan
- Pink Noise
- Rain
- River
- Female Rock-a-bye Baby
- Male Rock-a-bye Baby
- Thunderstorm
- Female Twinkle Twinkle
- Male Twinkle Twinkle
- White Noise
google_home:
name: "Select Speakers:"
options:
- Front Room
- Master Bedroom
- Kitchen
- Nursery
- Computer Area
- Downstairs
- Master Bathroom
- Everywhere
initial: Everywhere
icon: mdi:speaker-wireless
###### INPUT NUMBER ------------------------------------------
input_number:
volume_ambientsounds:
name: Volume
icon: mdi:volume-high
min: 0
max: 1
step: 0.05
initial: 0.45
###### SCRIPTS ------------------------------------------
script:
ambientsounds:
alias: Play Ambient Sounds
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.google_home", "Front Room") %} media_player.front_room_hub
{% elif is_state("input_select.google_home", "Master Bedroom") %} media_player.master_bedroom_clock
{% elif is_state("input_select.google_home", "Master Bathroom") %} media_player.great_room
{% elif is_state("input_select.google_home", "Kitchen") %} media_player.kitchen
{% elif is_state("input_select.google_home", "Nursery") %} media_player.nursery_hub
{% elif is_state("input_select.google_home", "Computer Area") %} media_player.computer_area_hub
{% elif is_state("input_select.google_home", "Downstairs") %} media_player.downstairs_public
{% elif is_state("input_select.google_home", "Everywhere") %} media_player.all_speakers
{% endif %}
volume_level: "0.0"
- delay: "00:00:02"
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.google_home", "Front Room") %} media_player.front_room_hub
{% elif is_state("input_select.google_home", "Master Bedroom") %} media_player.master_bedroom_clock
{% elif is_state("input_select.google_home", "Master Bathroom") %} media_player.great_room
{% elif is_state("input_select.google_home", "Kitchen") %} media_player.kitchen
{% elif is_state("input_select.google_home", "Nursery") %} media_player.nursery_hub
{% elif is_state("input_select.google_home", "Computer Area") %} media_player.computer_area_hub
{% elif is_state("input_select.google_home", "Downstairs") %} media_player.downstairs_public
{% elif is_state("input_select.google_home", "Everywhere") %} media_player.all_speakers
{% endif %}
media_content_id: >
{% if is_state("input_select.ambient_sound", "Babbling Brook") %} media-source://media_source/local/Sounds/relaxing/babbling_brook.mp3
{% elif is_state("input_select.ambient_sound", "Female Baby Shusher") %} media-source://media_source/local/Sounds/relaxing/baby_shusher_hol.mp3
{% elif is_state("input_select.ambient_sound", "Male Baby Shusher") %} media-source://media_source/local/Sounds/relaxing/baby_shusher_jmp.mp3
{% elif is_state("input_select.ambient_sound", "Country Night") %} media-source://media_source/local/Sounds/relaxing/country_night.mp3
{% elif is_state("input_select.ambient_sound", "Fireplace") %} media-source://media_source/local/Sounds/relaxing/fireplace.mp3
{% elif is_state("input_select.ambient_sound", "Forest") %} media-source://media_source/local/Sounds/relaxing/forest.mp3
{% elif is_state("input_select.ambient_sound", "Female Lullaby") %} media-source://media_source/local/Sounds/relaxing/luh_lullaby_hol.mp3
{% elif is_state("input_select.ambient_sound", "Male Lullaby") %} media-source://media_source/local/Sounds/relaxing/luh_lullaby_jmp.mp3
{% elif is_state("input_select.ambient_sound", "Ocean") %} media-source://media_source/local/Sounds/relaxing/ocean.mp3
{% elif is_state("input_select.ambient_sound", "Oscillating Fan") %} media-source://media_source/local/Sounds/relaxing/oscillating_fan.mp3
{% elif is_state("input_select.ambient_sound", "Pink Noise") %} media-source://media_source/local/Sounds/relaxing/pink_noise.mp3
{% elif is_state("input_select.ambient_sound", "Rain") %} media-source://media_source/local/Sounds/relaxing/rain.mp3
{% elif is_state("input_select.ambient_sound", "River") %} media-source://media_source/local/Sounds/relaxing/river.mp3
{% elif is_state("input_select.ambient_sound", "Female Rock-a-bye Baby") %} media-source://media_source/local/Sounds/relaxing/rock_a_bye_baby_hol.mp3
{% elif is_state("input_select.ambient_sound", "Male Rock-a-bye Baby") %} media-source://media_source/local/Sounds/relaxing/rock_a_bye_baby_jmp.mp3
{% elif is_state("input_select.ambient_sound", "Thunderstorm") %} media-source://media_source/local/Sounds/relaxing/thunderstorm.mp3
{% elif is_state("input_select.ambient_sound", "Female Twinkle Twinkle") %} media-source://media_source/local/Sounds/relaxing/twinkle_twinkle_hol.mp3
{% elif is_state("input_select.ambient_sound", "Male Twinkle Twinkle") %} media-source://media_source/local/Sounds/relaxing/twinkle_twinkle_jmp.mp3
{% elif is_state("input_select.ambient_sound", "White Noise") %} media-source://media_source/local/Sounds/relaxing/white_noise.mp3
{% elif is_state("input_select.ambient_sound", "Random White Noise") %}
{% set noises = ['media-source://media_source/local/Sounds/relaxing/babbling_brook.mp3',
'media-source://media_source/local/Sounds/relaxing/country_night.mp3',
'media-source://media_source/local/Sounds/relaxing/oscillating_fan.mp3',
'media-source://media_source/local/Sounds/relaxing/rain.mp3',
'media-source://media_source/local/Sounds/relaxing/river.mp3',
'media-source://media_source/local/Sounds/relaxing/thunderstorm.mp3'] %}
{{ noises|random }}
{% elif is_state("input_select.ambient_sound", "Random Kids Noise") %}
{% set noises = ['media-source://media_source/local/Sounds/relaxing/baby_shusher_hol.mp3',
'media-source://media_source/local/Sounds/relaxing/luh_lullaby_hol.mp3',
'media-source://media_source/local/Sounds/relaxing/twinkle_twinkle_hol.mp3'] %}
{{ noises|random }}
{% endif %}
media_content_type: "audio/mp4"
- delay: "00:00:01"
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.google_home", "Front Room") %} media_player.front_room_hub
{% elif is_state("input_select.google_home", "Master Bedroom") %} media_player.master_bedroom_clock
{% elif is_state("input_select.google_home", "Master Bathroom") %} media_player.great_room
{% elif is_state("input_select.google_home", "Kitchen") %} media_player.kitchen
{% elif is_state("input_select.google_home", "Nursery") %} media_player.nursery_hub
{% elif is_state("input_select.google_home", "Computer Area") %} media_player.computer_area_hub
{% elif is_state("input_select.google_home", "Downstairs") %} media_player.downstairs_public
{% elif is_state("input_select.google_home", "Everywhere") %} media_player.all_speakers
{% endif %}
volume_level: "{{ states.input_number.volume_ambientsounds.state }}"
###############################################################################
# Automations
###############################################################################
automation:
- alias: "Set Radio Volume"
id: automation_set_radio_volume
trigger:
platform: state
entity_id: input_number.volume_ambientsounds
action:
service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.google_home", "Front Room") %} media_player.front_room_hub
{% elif is_state("input_select.google_home", "Master Bedroom") %} media_player.master_bedroom_clock
{% elif is_state("input_select.google_home", "Master Bathroom") %} media_player.great_room
{% elif is_state("input_select.google_home", "Kitchen") %} media_player.kitchen
{% elif is_state("input_select.google_home", "Nursery") %} media_player.nursery_hub
{% elif is_state("input_select.google_home", "Computer Area") %} media_player.computer_area_hub
{% elif is_state("input_select.google_home", "Downstairs") %} media_player.downstairs_public
{% elif is_state("input_select.google_home", "Everywhere") %} media_player.all_speakers
{% endif %}
volume_level: "{{ states.input_number.volume_ambientsounds.state }}"