We built a our basement bathroom from the ground up and it is my most completed room with regards to atomations. There are 3 sets of lamps, a ventilation fan, and in-floor heating.
What I came here to share is more related to the Google Home that I mounted on the wall. As we have a general kind of underwater feel to the room, I created an automation that will intiatiate a random starting postion from 8 hours of whale calls.
The yaml is isolated and triggered by a bool. I have it start when the bathroom door is closed. It stops when the lights go out after the room is vacant. It has work arounds for making sure there is no activation sound. This is done with Music Assistant (MA) as an intermediary and setting the volume to 0 until the device is actually in a ‘playing’ state. I used a youtube music track that i set to a favorite in MA. I looked at the media player’s state to pull the track ID from MA to call in the yaml.
Hope this is fun for a couple people at least. The wife enjoyed it being setup.
trigger:
- platform: state
entity_id: input_boolean.bathroom_soundscape
to: "on"
- platform: state
entity_id: input_boolean.bathroom_soundscape
to: "off"
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.bathroom_soundscape
state: "on"
sequence:
- target:
entity_id: media_player.basement_bathroom_2
data:
volume_level: 0
action: media_player.volume_set
- target:
entity_id: media_player.basement_bathroom_2
action: media_player.turn_on
data: {}
- target:
entity_id: media_player.basement_bathroom_2
data:
media_content_id: library://track/293
media_content_type: music
action: media_player.play_media
- wait_template: "{{ is_state('media_player.basement_bathroom_2', 'playing') }}"
timeout: "00:00:30"
continue_on_timeout: false
- target:
entity_id: media_player.basement_bathroom_2
data:
seek_position: "{{ (range(30, 25200)|random) }}"
action: media_player.media_seek
- target:
entity_id: media_player.basement_bathroom_2
data:
volume_level: 0.3
action: media_player.volume_set
- conditions:
- condition: state
entity_id: input_boolean.bathroom_soundscape
state: "off"
sequence:
- target:
entity_id: media_player.basement_bathroom_2
action: media_player.turn_off
data: {}