In this post, I’m going to show you two automations with the Sonos Roam with my smart home. I will be playing music automatically from my speakers in my bathroom as soon as I start taking a shower. I’m doing this thanks to a water leak sensor positioned in my shower tray. In my second automation, I’m doing multi room music, without having to manually join speakers together, just using a motion sensor!
To do this project you will need:
- Sonos Roam
- Home Assistant
- Motion Sensor
- Water Leak sensor
- Songs / Playlist add to my Sonos with app.
Here is the code!
Shower Playlist
Replace the ID, the entity id of the water leak sensor and replace the sonos roam with your entity id.
The source needs to be the exact same song, radio or playlist.
- id: '1618936299346'
alias: Shower Playlist
description: ''
trigger:
- platform: state
entity_id: binary_sensor.zignito_water_sensor
from: 'off'
to: 'on'
condition: []
action:
- service: media_player.select_source
target:
entity_id: media_player.sonos_roam
data:
source: X Ray Vision - Slynk
mode: single
Multiroom audio
Replace the ID, the entity id of the motion sensor, the input boolean (you would need to create a helper for this, then copy&paste the entity id)
Now replace the sonos_roam with the name of your sonos speaker. Set the volume level 1 = 100%
The input boolean will enable you to turn on or off party mode, this is in case you don’t always want music following you!
- id: '1618936827351'
alias: Sonos Party Motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.zignito_motion_sensor
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: media_player.lounge
state: playing
- condition: state
entity_id: input_boolean.sonos_party_mode
state: 'on'
action:
- service: sonos.join
data:
master: media_player.lounge
entity_id: media_player.sonos_roam
- service: media_player.volume_set
target:
entity_id: media_player.sonos_roam
data:
volume_level: 0.5
mode: single
New to home assistant?
Take my free home assistant course