Could someone help develop a plugin for controlling Synology Audio Station?
Moderators: leecollings, remb0
Could someone help develop a plugin for controlling Synology Audio Station?
I currently use Synology's Audio Station and DS Audio app to control speakers connected to a few Airport Expresses around my house. I'd like to find a way to control them through Domoticz. Below is a link to some API documentation. I don't really know where to start with implementing something here.
https://github.com/kwent/syno/wiki/Audio-Station-API
https://github.com/kwent/syno/wiki/Audio-Station-API
-
- Posts: 3
- Joined: Saturday 08 December 2018 14:21
- Target OS: NAS (Synology & others)
- Domoticz version: Stable
- Location: France
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
Yes please, domoticz can send url but its not recived by audio station cause of the need tou be logged.
Very frustrating, ... All works fine with a web browser but nothing with domoticz.... Aaaarrggggg
Please a plugin, please
Very frustrating, ... All works fine with a web browser but nothing with domoticz.... Aaaarrggggg
Please a plugin, please
NAS Syno, Last Stable Ver°
RFLink 433.92+NRF24L01 : 6 THN132N, 5 KIT_FP433TEMP / ++MiLights / ++DI-O
HarmonyHub : FreeRev, TV LG, Amp Sony
Cabasse StreamAmp100, 3 Awox StriimLightWifi
KLF200 : 5 Somfy IO
IFTTT : GoogleAgenda
Blockly, DzVents, Bash
Tasker
RFLink 433.92+NRF24L01 : 6 THN132N, 5 KIT_FP433TEMP / ++MiLights / ++DI-O
HarmonyHub : FreeRev, TV LG, Amp Sony
Cabasse StreamAmp100, 3 Awox StriimLightWifi
KLF200 : 5 Somfy IO
IFTTT : GoogleAgenda
Blockly, DzVents, Bash
Tasker
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
I'm currently completing a first version of a plugin for running an Audio Station playlist. The playlist can for instance contain a bunch of MP3 stored or Internet Radio streams stored in a playlist (for me the latter was the trigger).
The streams of that playlist can be set-up in Domoticz as a dummy switch (with switch type Selector). By hitting one of those buttons in the Selector Switch a bash script will be triggered which integrates Synology Audio Station with a receiver.
In my case the receiver is a Denon AVR-2200W a for the last few weeks this works fine. A lot of information on the integration was available already and I reused this (of course). Will share on short notice.
The streams of that playlist can be set-up in Domoticz as a dummy switch (with switch type Selector). By hitting one of those buttons in the Selector Switch a bash script will be triggered which integrates Synology Audio Station with a receiver.
In my case the receiver is a Denon AVR-2200W a for the last few weeks this works fine. A lot of information on the integration was available already and I reused this (of course). Will share on short notice.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
So, version to be used in the outside world is ready
This version 3.2 contains the bash scripts only, as that is the base for playing streams via the Audio Station API.
Background for this solution is that my receiver (Denon AVR-2200W) was not able to play internet radio anymore. Decision by Denon was to made this would become a paid service. The Synology NAS has the ability to store Internet Radio streams and play those (for free) on the Denon by using the Audio Station package. Backdraw was that the package needed to be opened (either on a PC or Phone).
Way forward is to use Domoticz to switch on the Denon and play automatically the previous selected stream. Besides that you would be able to select another stream which then would be played.
Solution is tested under Synology DSM7.2. At least next is required:
1) Bash scripting active (version 4.4 or higher).
2) Jquery active (package jq version 1.5 or higher).
3) Audio Station running under DSM7.
Example to run: bash /opt/domoticz/userdata/apps/AudioPlayerv3/play_audio_station.sh 0 1 13 'Denon AVR-X2200W (AirPlay)' 'Internet Radio' 27 -L -D >/opt/domoticz/userdata/apps/AudioPlayerv3/audio.log
The zip file contains read.me for more detailed information.

Background for this solution is that my receiver (Denon AVR-2200W) was not able to play internet radio anymore. Decision by Denon was to made this would become a paid service. The Synology NAS has the ability to store Internet Radio streams and play those (for free) on the Denon by using the Audio Station package. Backdraw was that the package needed to be opened (either on a PC or Phone).
Way forward is to use Domoticz to switch on the Denon and play automatically the previous selected stream. Besides that you would be able to select another stream which then would be played.
Solution is tested under Synology DSM7.2. At least next is required:
1) Bash scripting active (version 4.4 or higher).
2) Jquery active (package jq version 1.5 or higher).
3) Audio Station running under DSM7.
Example to run: bash /opt/domoticz/userdata/apps/AudioPlayerv3/play_audio_station.sh 0 1 13 'Denon AVR-X2200W (AirPlay)' 'Internet Radio' 27 -L -D >/opt/domoticz/userdata/apps/AudioPlayerv3/audio.log
The zip file contains read.me for more detailed information.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
Domoticz setup is below..
Three dummy switches have been created (no specific setup required in those switches):
I’ve defined several DzVents script and I’m also using user variables to make my scripts more independent. The variable names are used in the scripts, the current value of the value is the exact name of the switch.
In next section the scripts will be shown.
Three dummy switches have been created (no specific setup required in those switches):
I’ve defined several DzVents script and I’m also using user variables to make my scripts more independent. The variable names are used in the scripts, the current value of the value is the exact name of the switch.
In next section the scripts will be shown.
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
First script is to kick off the bash script. This script is stored in the .helpers section, so can be called from multiple other scripts:
Code: Select all
, performPlayStream = function (domoticz, loadIndicator)
local mapName = "/opt/domoticz/userdata/apps/AudioPlayerv3/" -- in what folder are the bash scripts stored.
local curStreamId = domoticz.variables('CurrentStreamId').value -- retrieve currently played stream from user variable.
local newStreamId = math.modf(domoticz.devices(domoticz.variables('ReceiverStream').value).level/10) - 1 -- represents the selector choice: 0 is selector 10, 1 is 20, etc.
local numberStreams = #domoticz.devices(domoticz.variables('ReceiverStream').value).levelNames - 1 -- number of entries of playlist according to Domoticz.
local player = "Denon AVR-X2200W (AirPlay)" -- name of the player in Audio Station.
local playlist = "Internet Radio" -- name of the playlist in Audio Station.
local volumeLevel = domoticz.devices(domoticz.variables('ReceiverVolumeDevice').value).level -- retrieve current volume level receiver.
local debugIndicator = "" -- show debugmessages in logfile, value should be -D otherwise leave empty.
local RunCommand = "bash " -- the commandline to be executed.
if loadIndicator == "Load" then -- clear streams from receiver and load again. Value Load will be translated into -L
loadIndicator = "-L"
else
loadIndicator = ""
end
RunCommand = RunCommand..mapName.."play_audio_station.sh "
RunCommand = RunCommand..curStreamId.." "..newStreamId.." "..numberStreams
RunCommand = RunCommand.." '"..player.."' '"..playlist.."' "..volumeLevel
RunCommand = RunCommand.." "..loadIndicator.." "..debugIndicator
RunCommand = RunCommand.." >"..mapName.."audio.log &"
domoticz.helpers.printMessage (domoticz, "PlayStream command = "..RunCommand, "high")
domoticz.helpers.executeCommandOS(domoticz, RunCommand)
if curStreamId ~= newStreamId then
domoticz.variables('CurrentStreamId').set(newStreamId) -- set the new selected stream as the current stream (user variable)
end
end
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
Two other helper scripts (executeCommandOS and printMessage) are used in this kick off script. For simplification purposes printMessages does nothing more than printing a message in the log file of Domoticz (mine is somewhat more extended):
Code: Select all
--
-- ** execute OS commandline
--
, executeCommandOS = function (domoticz, RunCommand)
domoticz.executeShellCommand(RunCommand)
end
--
-- ** print message in Domoticz log depending on logType (low, medium, high, always) of the message and the internal setting of the logType to apply.
--
--
, printMessage = function (domoticz, messageToPrint, logType)
print (messageToPrint)
end
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
- Marathon2010
- Posts: 37
- Joined: Tuesday 02 February 2021 23:02
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Could someone help develop a plugin for controlling Synology Audio Station?
The base script from controlling the receiver actions I’ve stored in a separate DzVents script (mine is called receiver.lua). Also simplified the script as mine has more interactions.
Denon is known for its buffer issues, so restart every hour – if yours runs fine you can remove the timer functionality. My Denon is placed behind a smart plug, so for start-up and retrieve IP address it takes 60 second – if yours has always power you can simplify this as well):
Denon is known for its buffer issues, so restart every hour – if yours runs fine you can remove the timer functionality. My Denon is placed behind a smart plug, so for start-up and retrieve IP address it takes 60 second – if yours has always power you can simplify this as well):
Code: Select all
--
-- last change 1-Sep-23
--
return
{ active = true
, on = {devices = {'Denon AVR-2200W'
,'Denon Streaming'
,'Denon Volume'
}
,customEvents = {'activateDenonAfterReceiverSwitchedOn',
}
,timer = {'at *:50'
}
}
, execute = function(domoticz, item)
if item.isTimer then
-- Start the stream again to clear the buffer of the receiver (every hour).
domoticz.helpers.printMessage (domoticz, "Reload Receiver.", "low")
domoticz.helpers.performPlayStream(domoticz, "Load")
end
if item.isDevice then
if item.name == domoticz.variables('ReceiverVolumeDevice').value then
--
-- Overview volume level and dB values
--
-- Volume | Decibel
-- 0 -80 (sound is off)
-- 10 -70
-- 20 -60
-- 30 -50
-- 40 -40
-- 50 -30
--
ReceiverMaxVolume = 50
ReceiverValue = 0
ReceiverPercToVolume = 80
ReceiverValue = tonumber(item.level)
if ReceiverValue > ReceiverMaxVolume then
ReceiverValue = ReceiverMaxVolume
domoticz.helpers.printMessage (domoticz, "Volume receiver maximized on " ..ReceiverMaxVolume, "always")
end
ReceiverCalcValue = ReceiverValue - ReceiverPercToVolume
domoticz.helpers.performCommandReceiver(domoticz, "VOL", ReceiverCalcValue)
end
if item.name == domoticz.variables('ReceiverStream').value then -- Selector Stream is changed, start that stream to the receiver.
if (domoticz.devices(domoticz.variables('ReceiverName').value).state == "Off" -- Check if receiver is Off, so first switch on, wait for one minute and then start stream.
) then
domoticz.helpers.printMessage (domoticz, "Receiver (Denon) set On on selector choice, delay 60 secs.", "medium")
domoticz.devices(domoticz.variables('ReceiverName').value).switchOn().checkFirst() -- switch on Receiver
domoticz.emitEvent('activateDenonAfterReceiverSwitchedOn').afterSec(60)
else
domoticz.helpers.performPlayStream(domoticz, "NoLoad") -- Just load the new stream that is selected.
end
end
if (item.name == domoticz.variables('ReceiverName').value and
item.state == "On" -- When receiver is set to On wait for one minute and then start stream.
) then
domoticz.helpers.printMessage (domoticz, "Receiver (Denon) set On initially, delay 60 secs.", "medium")
domoticz.emitEvent('activateDenonAfterReceiverSwitchedOn').afterSec(60)
end
end
if item.isCustomEvent then
domoticz.helpers.printMessage (domoticz, "Receiver (Denon) set On, delayed for 60 secs. Now start the stream.", "high")
domoticz.helpers.performPlayStream(domoticz, "Load") -- Receiver is set to On and waited for one minute, now start stream.
end
end
}
Synology NAS DS920+ DSM7 (Docker) | Integrations: Audio, Heating, Gas, Electricity, Water, Alarm, Car, Camera, Doorbell, Garage | SW: Tasmota, DzVents, Pushbullet | Plugins: GPSLogger, BatteryLevel, Hyundai KIA, Rhasspy
Who is online
Users browsing this forum: No registered users and 1 guest