Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # RESOURCES:
- # 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
- ###### CUSTOMIZE ----------------------------------------
- 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
- ###### INPUT SELECT ------------------------------------------
- input_select:
- ambient_sound:
- name: 'Select Radio Station:'
- options:
- - Babbling brook sounds
- - Oscillating fan sounds
- - Fireplace sounds
- - Forest sounds
- - Country night sounds
- - Ocean sounds
- - Rain sounds
- - River sounds
- - Thunderstorm sounds
- - White noise
- google_home:
- name: 'Select Speakers:'
- options:
- - Livingroom
- - Bedroom
- - Kitchen
- - 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
- ###### SCRIPTS ------------------------------------------
- script:
- ambientsounds:
- alias: Play Ambient Sounds
- sequence:
- - service: media_player.volume_set
- data:
- entity_id: media_player.bedroom_speaker
- volume_level: '0.35'
- - service: media_player.volume_set
- data:
- entity_id: media_player.kitchen_speaker
- volume_level: '0.20'
- - service: media_player.volume_set
- data:
- entity_id: media_player.google_home
- volume_level: '0.30'
- - service: media_player.play_media
- data_template:
- entity_id: >
- {% if is_state("input_select.google_home", "Livingroom") %} media_player.google_home
- {% elif is_state("input_select.google_home", "Bedroom") %} media_player.bedroom_speaker
- {% elif is_state("input_select.google_home", "Kitchen") %} media_player.kitchen_speaker
- {% elif is_state("input_select.google_home", "Everywhere") %} media_player.home_group
- {% endif %}
- media_content_id: >
- {% if is_state("input_select.ambient_sound", "Babbling brook sounds") %} https://www.gstatic.com/voice_delight/sounds/long/brook.mp3
- {% elif is_state("input_select.ambient_sound", "Oscillating fan sounds") %} https://www.gstatic.com/voice_delight/sounds/long/oscillating_fan.mp3
- {% elif is_state("input_select.ambient_sound", "Fireplace sounds") %} https://www.gstatic.com/voice_delight/sounds/long/fireplace.mp3
- {% elif is_state("input_select.ambient_sound", "Forest sounds") %} https://www.gstatic.com/voice_delight/sounds/long/forest.mp3
- {% elif is_state("input_select.ambient_sound", "Country night sounds") %} https://www.gstatic.com/voice_delight/sounds/long/country_night.mp3
- {% elif is_state("input_select.ambient_sound", "Ocean sounds") %} https://www.gstatic.com/voice_delight/sounds/long/ocean.mp3
- {% elif is_state("input_select.ambient_sound", "Rain sounds") %} https://www.gstatic.com/voice_delight/sounds/long/rain.mp3
- {% elif is_state("input_select.ambient_sound", "River sounds") %} https://www.gstatic.com/voice_delight/sounds/long/river.mp3
- {% elif is_state("input_select.ambient_sound", "Thunderstorm sounds") %} https://www.gstatic.com/voice_delight/sounds/long/thunder.mp3
- {% elif is_state("input_select.ambient_sound", "White noise sounds") %} https://www.gstatic.com/voice_delight/sounds/long/pink_noise.mp3
- {% endif %}
- media_content_type: 'audio/mp4'
- ###############################################################################
- # Automations
- ###############################################################################
- automation:
- - alias: '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.ambient_sound", "Livingroom") %} media_player.google_home
- {% elif is_state("input_select.ambient_sound", "Bedroom") %} media_player.bedroom_speaker
- {% elif is_state("input_select.ambient_sound", "Kitchen") %} media_player.kitchen_speaker
- {% elif is_state("input_select.ambient_sound", "Everywhere") %} media_player.home_group
- {% endif %}
- volume_level: '{{ states.input_number.volume_ambientsounds.state }}'
Add Comment
Please, Sign In to add comment