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.
|
TR
|
Trigger
|
Trigger for execution
|
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. |
|
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:
- Add a new "Sonos (local)" block and copy the parameters (zone name,
function, trigger, data) from the old block — the settings are
structured identically.
- Connect the trigger address to the TR input. The new block no
longer has an enable input (FG); any enable logic configured there
has to be moved in front of the trigger if required.
- Delete the old block afterwards. As long as both blocks with the
same trigger and the same function are part of the project, the
command is executed twice.
Network functions
The block uses the following network mechanisms:
- Automatic discovery (SSDP): The speakers are found via a
multicast search (UDP to 239.255.255.250, port 1900). The speakers'
replies are returned to the controller as regular UDP packets.
Multicast only works within the same network segment — a router
between the speakers and the controller does not forward the
search.
- Control: Commands are sent as HTTP connections (TCP, port
1400) directly to the speakers.
- Text to Speech: The speakers download the announcement file
from the controller (TCP, port 1402, or 1403-1410 if occupied). The
connection is established from the speaker to the controller — the
controller must be reachable from the speakers' point of view.
- Remembering the player address: One working speaker IP per
Sonos system is stored and queried directly during the regular
update (every 5 minutes). If the multicast search fails (e.g. after a
restart in a network with blocked multicast), the speakers therefore
remain reachable.
- Several Sonos systems: A speaker only knows the rooms of its
own system. If several systems run in the same network (e.g. older S1
devices alongside S2, a second apartment), the rooms of all systems
found are merged. If a configured zone is not found, the controller
searches the network again (at most once per minute). If the same room
name exists in two systems, the one found first is used. The zone
sayall addresses the
speakers of all systems.
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
- No speakers are found (ER = 1 for every command):
- Are the speakers and the controller in the same subnet? Compare
IP addresses and subnet mask (e.g. both 192.168.1.x).
- Ping a speaker from a PC in the same network or open
http://<speaker
IP>:1400/xml/device_description.xml in a browser — if
an XML page is returned, the speaker is reachable.
- Does the Sonos app work on a phone in the same WLAN? If not,
the problem is in the network, not in the controller.
- Temporarily disable IGMP snooping / multicast filters on the
switch or access point, disable client/AP isolation in the WLAN.
- Check the controller's firewall: incoming UDP replies of the
discovery and incoming TCP connections on port 1402 (TTS) must be
allowed (on Windows the Windows firewall).
- Zone is not found, other commands work: Enter the zone name
exactly as shown in the Sonos app (case does not matter, but the name
must match completely). After renaming in the app it can take up to 5
minutes until the change is adopted — or restart the controller. The
error message "ZONE '…' NOT FOUND" in the diagnostic window lists all
rooms known to the controller and the IPs they were queried from. If
rooms are missing there, they belong to a Sonos system the controller
cannot reach.
- Play/Next affects a different room: The speaker is part of a
group — playback commands always affect the whole group (the group
coordinator). Dissolve the group in the Sonos app if the room should
be controlled individually.
- Text to Speech: no announcement audible:
- To generate an announcement for the first time, the controller
needs internet access to Google services (check firewall/proxy)
and a runtime variant with SSL support. Without SSL the block
reports an error for Text to Speech, all other functions work
normally.
- The speakers must be able to reach the controller on port 1402
(firewall on/in front of the controller, router/VLAN in
between).
- Shorten the text (max. approx. 200 characters) and remove
special characters or invisible Unicode characters.
- Limit of the Google service exceeded, e.g. if the trigger was
fired continuously (error in the project). Announcements that
have already been generated are not affected (local storage).
- Music does not resume after the announcement: With some
sources (e.g. streaming via AirPlay or TV sound) the previous
playback cannot be restored — this is a limitation of the speakers,
not of the controller.
- Commands are delayed: After an error the block automatically
performs a new discovery and repeats the command once — this can take
a few seconds. Frequent errors indicate a network problem (see
above).
See also the common parameters of all
function blocks.