Sonos


The sonos component allows you to control your Sonos HiFi wireless speakers and audio components from Home Assistant. By default it supports auto-discovery provided by Home Assistant, and you don’t need to add anything to your configuration.yaml.

If you don’t have the discovery component enabled, you can configure the Sonos component by going to the integrations page inside the config panel.

Services

Sonos makes various services available to allow configuring groups. They are currently registered under the media player component.

Service media_player.sonos_snapshot

Take a snapshot of what is currently playing on one or more speakers. This service, and the following one, are useful if you want to play a doorbell or notification sound and resume playback afterwards. If no entity_id is provided, all speakers are snapshotted.

The queue is not snapshotted and must be left untouched until the restore. Using media_player.play_media is safe and can be used to play a notification sound, including TTS announcements.

Configuration Variables

entity_id

(entity_id)(Optional)The speakers to snapshot.

with_group

(boolean)(Optional)Should we also snapshot the group layout and the state of other speakers in the group.

Service media_player.sonos_restore

Restore a previously taken snapshot of one or more speakers. If no entity_id is provided, all speakers are restored.

The playing queue is not snapshotted. Using media_player.sonos_restore on a speaker that has replaced its queue will restore the playing position, but in the new queue!

A cloud queue cannot be restarted. This includes queues started from within Spotify and queues controlled by Amazon Alexa.

Configuration Variables

entity_id

(entity_id)(Optional)The speakers that should have their snapshot restored.

with_group

(boolean)(Optional)Should we also restore the group layout and the state of other speakers in the group.

Service media_player.sonos_join

Group players together under a single coordinator. This will make a new group or join to an existing group.

Configuration Variables

master

(entity_id)(Required)A single entity_id that will become/stay the coordinator speaker.

entity_id

(entity_id)(Optional)The speakers to join to the master.

Service media_player.sonos_unjoin

Remove one or more speakers from their group of speakers. If no entity_id is provided, all speakers are unjoined.

Configuration Variables

entity_id

(entity_id)(Optional)The speakers to separate from their coordinator speaker.

Service media_player.sonos_set_sleep_timer

Sets a timer that will turn off a speaker by tapering the volume down to 0 after a certain amount of time. Protip: If you set the sleep_time value to 0, then the speaker will immediately start tapering the volume down.

Configuration Variables

entity_id

(entity_id)(Required)The speakers that will have their timers set.

sleep_time

(integer)(Required)Number of seconds that the speaker should wait until it starts tapering. Cannot exceed 86399 (one day).

Service media_player.sonos_clear_sleep_timer

Clear the sleep timer on a speaker, if one is set.

Configuration Variables

entity_id

(entity_id)(Required)The speakers that will have their timers cleared.

Service media_player.sonos_update_alarm

Update an existing Sonos alarm.

Configuration Variables

entity_id

(entity_id)(Required)The speaker that will have its alarm updated.

alarm_id

(integer)(Required)Integer that is used in Sonos to refer to your alarm.

time

(time)(Optional)Time to set the alarm.

volume

(float)(Optional)Float for volume level (0.0-1.0).

enabled

(boolean)(Optional)Boolean for whether or not to enable this alarm.

include_linked_zones

(boolean)(Optional)Boolean that defines if the alarm also plays on grouped players.

Service media_player.sonos_set_option

Set Sonos speaker options.

Night Sound and Speech Enhancement modes are only supported when playing from the TV source of products like Sonos Playbar and Sonos Beam. Other speaker types will ignore these options.

Configuration Variables

entity_id

(entity_id)(Required)The speakers that will have their options set.

night_sound

(boolean)(Optional)Boolean to control Night Sound mode.

speech_enhance

(boolean)(Optional)Boolean to control Speech Enhancement mode.

Advanced use

For advanced uses, there are some manual configuration options available.

If you have multiple network devices, you can provide the IP address of the device that should be used for Sonos auto-discovery.

# Example configuration.yaml entry using Sonos discovery on a specific interface
sonos:
  media_player:
    interface_addr: 192.0.2.1

You can also specify one or more hosts to connect to if they cannot be found with Sonos auto-discovery.

# Example configuration.yaml entry with manually specified addresses
sonos:
  media_player:
    hosts: 192.0.2.25

or, for multiple hosts:

# Example configuration.yaml entry with manually specified addresses
sonos:
  media_player:
    hosts:
      - 192.0.2.25
      - 192.0.2.26
      - 192.0.2.27