Overview SONOS (local)



This function block controls SONOS speakers directly over the network. Control is performed locally using the Sonos network protocol (UPnP) — no additional software and no cloud connection is required.

The speakers are discovered automatically on the network. Zones are addressed by their room name (exactly as shown in the Sonos app). If speakers are grouped, playback functions (Play, Pause, Next, ...) affect the whole group, while volume and mute affect the individual speaker.

Changes to the Sonos system take some time: The controller reads the zones and speakers again every 5 minutes. If a zone is renamed, a speaker is added or removed or a group is rearranged in the Sonos app, it can therefore take up to 5 minutes until the controller adopts the change — only test afterwards. This applies in particular to the zone sayall, which only reaches new speakers after the zones have been read again. If a command fails or the zone is unknown, the controller additionally reads the zones again immediately. Restarting the controller also takes effect immediately.

The Text to Speech function uses an external service (Google) which is currently free of charge. If this changes in the future, a different service has to be used. We have no influence on this and therefore this function cannot be guaranteed. Once generated, announcements are stored locally and do not require internet access on subsequent calls.


Inputs

TR
Trigger
Trigger for execution

Outputs

ER
Error
Error of the last command: 1 = command could not be executed (zone not found, speaker not reachable, Text to Speech failed), 0 = last command successful.

Parameters


Zone name
Name of the zone. The name must be entered exactly as shown in the SONOS app.
If sayall is entered instead of a zone name, the function applies to all speakers. Volume and mute are set on each speaker individually, all other functions act once per group. So if speakers are grouped in the SONOS app, the group receives the command only once.

Function
Function to execute
  • Play
  • Pause
  • Play/Pause
  • Mute
  • Unmute
  • Next
  • Previous
  • Volume Inc.
  • Volume Dec.
  • Volume val., data field is 0-100
  • Volume abs., data field is 0-100
  • Favorites, data field is the name
  • Playlist, data field is the name
  • Text to Speech., data field is "Text/language code/volume", for example "Lunch is ready/en/50" announces the text "Lunch is ready" in English (en) at 50% volume. If "sayall" is entered as the zone name, the text is announced on all speakers. The current playback is interrupted for the announcement and resumed automatically afterwards. The text may be up to approx. 200 characters long.

Note: With "Volume val." the volume setpoint is provided via the input, therefore the trigger must be set to All telegrams.


Trigger
  • 0->1 rising edge
  • 1->0 falling edge
  • Telegram

Data
Optional data. E.g. the name of the favorite when Favorites is selected.

Debug
Only when enabled, the controller outputs additional debug messages in the messages (e.g. discovered speakers, executed commands). Errors are always reported.

Updating existing projects

Old SONOS blocks (the variant using external additional software) that are still part of the project can continue to be used and will keep working. However, the old block can no longer be added to a project.

When the project is edited, the old blocks should be replaced by this new variant: no external software is required any more and more resources become available on the controller.

How to replace:

Network functions

The block uses the following network mechanisms:

Important: Speakers and controller should be in the same network (subnet). If they are separated by a router, a VLAN or a guest network, problems can occur: the automatic discovery does not find any speakers (multicast is not routed), NAT or firewall rules can block the control connections, and for Text to Speech the speakers cannot reach the controller. Devices with "IGMP snooping" (some switches) or wireless access points with client isolation enabled can also prevent the discovery or the control.

FAQ - what to test in case of problems



See also the common parameters of all function blocks.