Created At
Jul 17, 2026
Created At
Jul 17, 2026
Last Update
Jul 20, 2026
Platforms
HC 3
Views
13
Download
1
-------------------------------------------------------------------------------------------
-- SONOS Zone controller Version 1.5.2
-- Copyright (C) 2014-2021 Jean-Christophe Vermandé (https://github.com/Krikroff77)
-------------------------------------------------------------------------------------------
-- Change logs:
--
-- Version 1.5.2
-- Tested with Sonos OS: S2 - Version 13.4.1 (number 66423300)
-- Improved support for Sonos Amp & Sonos One Gen2/SL and communication performance improvement
-- Add new volume limiter feature: an option to prevent damage with unwanted high volume
-- Add support for "Device disabled" option available in quick app advanced panel
-- Add possibility to emits custom event when initiating a playback (playing), paused and stop playback state (just declare event name used in quick app variable panel ex: "event.stopped" or "event.playing" and the events in "General => Events".
-- You can now triggering scenes on events) (https://forum.fibaro.com/topic/55510-create-a-scene-when-sonos-play-it-activate-a-whall-socket/#comment-235990)
-- Fix a problem occured in some cases when zone controller browse device directory and parse items Declaration (DIDL) resulting an out of service for the QuickApp
--
-- Version 1.4.0
-- Fix for Sonos firmware version 13
-- Fix for Sonos ARC getPositionInfo and malformed xmlsoap (hope full supoport soon)
-- Add playNextRadio command to navigate the radios
-- Add play mode control from QA button (loop in NORMAL,REPEAT_ALL,REPEAT_ONE,SHUFFLE_NOREPEAT,SHUFFLE,SHUFFLE_REPEAT_ONE)
-- Fix Radio metadata strange behaviors in some situations
-- Tested with Sonos OS: S2 - Version 13 (number 62186220)
--
-- Version 1.3.8
-- Improved support for albumArt, now work with Sonos Radio, Amazon Music, Spotify, TuneIn, Music library
-- Add option 'protect' to playFile and playStream for disallow to restart a playing
-- Add Crossfade mode support with getCrossfadeMode, setCrossfadeMode and toggleCrossfadeMode commands
-- Add sleepTimer command
-- Add setPlayMode command, support: NORMAL,REPEAT_ALL,REPEAT_ONE,SHUFFLE_NOREPEAT,SHUFFLE,SHUFFLE_REPEAT_ONE
-- Add selectLineIn command
-- Add in variables panel, "notification" variable to enable or disable the "Device notification error", if disabled QA trace the message in QA console only
-- Various improvement
-- Tested with Sonos OS: S2 - Version 12.0.0 - 12.2.2 (number 61183220)
--
-- Version 1.3.1
-- Add support to use in block scenes (Play, Pause, Stop, Next, Prev, Set Volume, Set mute)
-- Support for album covers when available (cf. music library)
-- Performance improvement when initiating a playback
-- Improved radio playback and track information
-- Increase the number of supported radio stations (with auto configuration up to 9)
-- Support for Sonos playlists (with auto configuration up to 6 saved queues)
-- Add playFile command
-- Add playStream command
-- Add playSavedQueue command
-- Add startQueue command
-- Add clearQueue command
-- Add seek command
-- Add snapshot command
-- Add revert command
-- Add getListSavedQueues command
-- Add addURIToQueue command
-- Add checkForUpdate command
-- Add getTreble and setTreble commands
-- Add getBass and setBass commands
-- Add debug mode (set mode with a variable 'debug' with value 'true')
-- Add debug mode level (set level with a variable 'debugLevel' with 'warning' or 'trace' or 'debug')
-- Various Bug fixes (Polling when not configured, parsing ...)
-- Tested with Sonos Software Version: 56.0-76060 / Sonos OS: S2 - Version 12.0.5 & 12.1
--
-- Version 1.1.0
-- Support for TuneIn "My radio stations" (with auto configuration up to 6)
-- Deletion of the variable "isConfigured" used by internal FTI Configuration
-- Minor bug fixes (No route to host cause wrong configuration status)
-- Prepare for group support
-- Performance improvement
-- Tested with Sonos Software Version: 55.1-74250 and 56.0-76060
--
-- Version 1.0.3
-- Fix a problem with internal zoneGroups and ZoneGroupMembers parsing (Thanks to jgab, Alan Klepacz and robw)
--
-- Version 1.0.2
-- Minor bug fixes (Thanks to Macschimmi, Bodyart, minsad79)
--
-- Version 1.0.0
-- Based on my HC2 virtual Device and completely rewriten for HC3 v5.030.45 or highter
-- Very low latency and more robust device
-- Easy installation with auto configuration assist
-- Support standard capabilities (AVTransport, RenderingControl)
-- Displaying information on the currently playing or media loaded
-- Fully controllable from the LUA scenarios (see available command list)
--
-- Roadmap:
-- Support for multi-devices in group used for triggering in scene and prepare for group-ungroup
-- Support for TV source (if supporteed by device)
-- Support for group
-- Support for TTS (TextToSpeech)
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- Variables list
-------------------------------------------------------------------------------------------
-- ipAddress: IP address for the group coordinator
-- tcpPort: TCP Port (by default: 1400)
-- polling: Polling timeout (seconds, by default 2 seconds)
-- notification: Enable or disable the "Device notification error", if disabled QA trace the message in QA console only
-- debug: Debug state (true|false (default))
-- debugLevel: Debug level (trace|warning|debug|error) when debug state setted to true
-- iconId: icon id avalaible in HC3 (ex: stored in another QA)
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- Actions available
-------------------------------------------------------------------------------------------
-- Restart the QA Device
-- Ex: fibaro.call(QuickappID, "restart")
-- Set device debug state
-- @param boolean state [true|false]
-- Ex: fibaro.call(QuickappID, "setDebug", true)
-- Set device debug state level
-- Ex: fibaro.call(QuickappID, "setDebugLevel", "trace")
-- Initiate playback.
-- Ex: fibaro.call(QuickappID, "play")
-- Toogle playback.
-- Ex: fibaro.call(QuickappID, "togglePlay")
-- Pause playback
-- Ex: fibaro.call(QuickappID, "pause")
-- Stop playback.
-- Ex: fibaro.call(QuickappID, "stop")
-- Skip to the previous track.
-- Ex: fibaro.call(QuickappID, "previous")
-- Skip to the next track.
-- Ex: fibaro.call(QuickappID, "next")
-- Get player volume and mute state.
-- Ex: fibaro.call(QuickappID, "getVolume")
-- Set player volume to a specific level and unmute the player if muted.
-- Ex: fibaro.call(QuickappID, "setVolume", 10, "MASTER")
-- Increase or decrease player volume.
-- Ex: fibaro.call(QuickappID, "setRelativeVolume", -5, "MASTER")
-- Mute or unmute the player.
-- @param boolean state [true|false]
-- Ex: fibaro.call(QuickappID, "setMute", true)
-- Get player mute state
-- Ex: fibaro.call(QuickappID, "getMute")
-- Toogle player mute state
-- Ex: fibaro.call(QuickappID, "toggleMute")
-- Get player loudness state
-- Ex: fibaro.call(QuickappID, "getLoudness")
-- Set player loudness state
-- @param boolean state [true|false]
-- Ex: fibaro.call(QuickappID, "setLoudness", true)
-- Toogle player loudness state
-- Ex: fibaro.call(QuickappID, "toggleLoudness")
-- Get group LED state
-- Ex: fibaro.call(QuickappID, "getLEDState")
-- Set group LED state
-- @param boolean state [true|false]
-- Ex: fibaro.call(QuickappID, "setLEDState", true)
-- Set and load desired radio station (by index) and initiate playback.
-- @param number index : the radio station index
-- Ex: fibaro.call(QuickappID, "playRadio", 1)
-- Set and load desired playlist (from saved queues) by index and initiate playback
-- @param number index : the playlist index
-- Ex: fibaro.call(QuickappID, "playSavedQueue", 1)
-- Make a snapshot
-- Ex: fibaro.call(QuickappID, "snapshot")
-- Revert to latest snapshot if available to restore the previous state (queue, selected track, playing ...)
-- Ex: fibaro.call(QuickappID, "revert")
-- Play a file available on local network and registrered in SONOS music library
-- @param string path
-- @param string restore [boolean:true(default)|false] makes a snapshot before and restore after has played the file
-- @param number volume : the volume
-- Ex: fibaro.call(QuickappID, "playFile", "WIN-35HTGV34R7S/Musique/CD/Dream Theater/A Change of Seasons/01-A Change of Seasons [Medley].flac")
-- Ex: fibaro.call(QuickappID, "playFile", "192.168.1.200/Musique/TTS/Google parle aussi en Français.mp3", true, 10)
-- Play a stream from uri (ressource or internet radio for example)
-- @param string uri : the uri
-- @param boolean restore [true(default)|false] makes a snapshot before and restore after has played the file
-- @param number volume [number|nil(preserve current volume)] : the volume
-- @param number duration : the duration in milliseconds
-- EX: fibaro.call(QuickappID, "playStream", "https://s3.amazonaws.com/smartapp-media/sonos/bell1.mp3", true, 10, 8000)
-- Try to remove all tracks from queue
-- EX: fibaro.call(QuickappID, "clearQueue")
-- Try to start current queue
-- EX: fibaro.call(QuickappID, "startQueue")
-- Add URI to current queue
-- @param string uri : the uri
-- EX: fibaro.call(QuickappID, "addURIToQueue", "file:///jffs/settings/savedqueues.rsq#1")
-- Get current trable value
-- EX: fibaro.call(QuickappID, "getTreble")
-- Set desired trable value
-- @param number value : the treble value
-- EX: fibaro.call(QuickappID, "setTreble", 0)
-- Get current value
-- EX: fibaro.call(QuickappID, "getBass")
-- Set desired bass value
-- @param number value : the bass value
-- EX: fibaro.call(QuickappID, "setBass", 0)
-- Seeks to a given position (HH:MM:SS or H:MM:SS) in the current track or track number x
-- @param string type 'REL_TIME' for time position (xx:xx:xx) or 'TRACK_NR' for track in current queue
-- @param string position 'xx:xx:xx' or track number x
-- EX: fibaro.call(QuickappID, "seek", {type = "TRACK_NR", position = 1})
-- Name: getCrossfadeMode
-- Description: Retrieve the current crossfade mode
-- @param number instanceId option (default is 0))
-- EX: fibaro.call(QuickappID, "getCrossfadeMode", 0)
-- Name: setCrossfadeMode
-- Description: Set CrossfadeMode 0 or 1 - type is number
-- @param boolean state (default is 0) 0|1 or false|true)
-- @param number instanceId option (default is 0))
-- EX: fibaro.call(QuickappID, "setCrossfadeMode", 1, 0)
-- Name: togglerCrossfadeMode
-- Description: Toggle player Croosfade mode state
-- @param number instanceId option (default is 0))
-- EX: fibaro.call(QuickappID, "togglerCrossfadeMode", 1, 0)
-- Name: sleepTimer
-- Description: Stop playing after set sleep timer
-- @param number duration - Time to stop after, as hh:mm:ss
-- Ex: fibaro.call(1673, "sleepTimer", '00:00:10')
-- Name: setPlayMode
-- Description: Set the PlayMode
-- @param string playMode [ NORMAL,REPEAT_ALL,REPEAT_ONE,SHUFFLE_NOREPEAT,SHUFFLE,SHUFFLE_REPEAT_ONE ]
-- @param number instanceID option (default is 0))
-- EX: fibaro.call(QuickappID, "setPlayMode", 'SHUFFLE_NOREPEAT')
-- Name: selectLineIn
-- Description: Switch the speaker's input to line-in.
-- EX: fibaro.call(QuickappID, "selectLineIn")
-- Name: Play next radio
-- Description: Play next radio station (return to first index if the increment comes to the end. no action if no radio available in QA)
-- EX: fibaro.call(1673, "playNextRadio")
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- Reserved, waiting fibaro.call evolution and ability to return a value after the call
-------------------------------------------------------------------------------------------
-- Name: getCurrentTransportActions
-- Description: retrieve available actions for current media
-- EX: fibaro.call(QuickappID, "getCurrentTransportActions")
-- EX: fibaro.call(QuickappID, "getZpStatus")
-- EX: fibaro.call(QuickappID, "getZoneGroupAttributes")
-- EX: fibaro.call(QuickappID, "getTransportInfo")
-- EX: fibaro.call(QuickappID, "getMediaInfo")
-- EX: fibaro.call(QuickappID, "getPositionInfo")
-- EX: fibaro.call(QuickappID, "getListRadioStations")
-- EX: fibaro.call(QuickappID, "getListSavedQueues")
-- EX: fibaro.call(QuickappID, "getZoneGroupState")
-- EX: fibaro.call(QuickappID, "checkForUpdate")
-------------------------------------------------------------------------------------------