Author Topic: Start/Trigger Playlist on Synology from HTTP request  (Read 3293 times)

Offline EOppie

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +1/-0
Start/Trigger Playlist on Synology from HTTP request
« on: May 11, 2014, 11:28:10 am »
I dug around here, and elsewhere, but I couldn't find anything (that at least I could understand) on how to do this.

Goal: Trigger playlist from a scene on vera, have music begin playing through airplay connected device.  Seems simple  ???

Environment:
Synology DS412+
ROCKI (Airplay device) connected to amplifier/speakers
Vera 3

I installed Synology Audio Station, which works great for playing music to the ROCKI, so at least I know that part of the setup works okay.  What I can't figure out is a way to send an HTTP command to Audio Station to start playing a specific playlist (or song) to the ROCKI.

Seems like something pretty basic...however I can't figure out where/how  :D

Any help would be appreciated!

Offline Tommi

  • Sr. Newbie
  • *
  • Posts: 35
  • Karma: +0/-0
Re: Start/Trigger Playlist on Synology from HTTP request
« Reply #1 on: October 27, 2015, 10:32:27 am »
I dug around here, and elsewhere, but I couldn't find anything (that at least I could understand) on how to do this.

Goal: Trigger playlist from a scene on vera, have music begin playing through airplay connected device.  Seems simple  ???

Environment:
Synology DS412+
ROCKI (Airplay device) connected to amplifier/speakers
Vera 3

I installed Synology Audio Station, which works great for playing music to the ROCKI, so at least I know that part of the setup works okay.  What I can't figure out is a way to send an HTTP command to Audio Station to start playing a specific playlist (or song) to the ROCKI.

Seems like something pretty basic...however I can't figure out where/how  :D

Any help would be appreciated!

I'm thinking about the same but using BT speaker, maybe some progress?

Offline zonnetje

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: Start/Trigger Playlist on Synology from HTTP request
« Reply #2 on: January 24, 2016, 04:30:42 pm »
Here some luup code I use to connect to my synology DS audio Webapi. The Synology than plays directly to my Airport/Stereo when starting the scene.

In the code below my synology has the fictive id=403CFC043XXX but it can alsno be something like: __SYNO_USB_PLAYER__. You can find the id when logging into the api via the following two commands:

http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=myusername&passwd=mypassword&session=AudioStation&format=cookie
http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&version=2&method=list



Scene that starts the playlist 143:
-------------------------------
luup.log('Starting Playlist Play ' .. luup.version)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=myusername&passwd=mypassword&session=AudioStation&format=cookie", 1)

result2 = string.gsub(result,"{\"data\":{\"sid\":\"","")
result3 = string.gsub(result2,"\"},\"success\":true}","")
cookie = string.gsub(result3,string.char(10),"")
luup.log('Found Cookie:' .. cookie .. '')

luup.log('Load Playlist 143 ')
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=updateplaylist&library=shared&id=403CFC043XXX&offset=0&limit=0&play=true&version=2&containers_json=%5B%7B%22type%22%3A%22playlist%22%2C%22id%22%3A%22playlist_shared_normal%2F143%22%7D%5D&_sid=" .. cookie, 2)

luup.log('Play')
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=play&value=0&id=403CFC043XXX&version=2&_sid=" .. cookie, 2)

local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&version=2&method=getstatus&id=403CFC043XXX&_sid=" .. cookie, 2)
luup.log('Result Status:' .. result)

local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=logout&session=AudioStation", 1)
--------------

Scene that stops the playlist:
-----------------------------
luup.log('Stopping Playlist ' .. luup.version)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=myusername&passwd=mypassword&session=AudioStation&format=cookie", 1)

result2 = string.gsub(result,"{\"data\":{\"sid\":\"","")
result3 = string.gsub(result2,"\"},\"success\":true}","")
cookie = string.gsub(result3,string.char(10),"")
luup.log('Found Cookie:' .. cookie .. 'xxxxxxxx')

luup.log('Stop ')
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=stop&id=403CFC043XXX&version=2&_sid=" .. cookie,2)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&version=2&method=getstatus&id=403CFC04XXX&_sid=" .. cookie, 2)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=logout&session=AudioStation", 1)
------------------

Scene that starts the next song in playlist:
--------------------------------
luup.log('Play Next in Playlist ' .. luup.version)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=myusername&passwd=mypassword&session=AudioStation&format=cookie", 1)

result2 = string.gsub(result,"{\"data\":{\"sid\":\"","")
result3 = string.gsub(result2,"\"},\"success\":true}","")
cookie = string.gsub(result3,string.char(10),"")
luup.log('Found Cookie:' .. cookie .. 'xxxxxxxx')

luup.log('Volgende')
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&method=control&action=next&id=403CFC04XXX&version=2&_sid=" .. cookie, 2)
local status, result = luup.inet.wget("http://192.168.1.8:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=logout&session=AudioStation", 1)

If you need more options see https://github.com/JimRobs/syno/wiki/Audio-Station-API

Offline garvarma

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: Start/Trigger Playlist on Synology from HTTP request
« Reply #3 on: September 16, 2018, 04:47:34 am »
Hi,

My name is Manuel and i'm from Spain.

I have a Synology NAS and i would like to use the Synology Audio Station Api for my domotic system in my home, but first i need to create a python code from API.

I have little acknowledgment about programming (C++, java, Matlab, etc) but i'm not expert.

I tried the first api http commands like:
Quote
http://192.168.1.100:5050/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=myusername&passwd=mypassword&session=AudioStation&format=cookie

http://192.168.1.100:5050/webapi/AudioStation/remote_player.cgi?api=SYNO.AudioStation.RemotePlayer&version=2&method=list

and i i have these results:

Quote
{"data":{"sid":"PRGeQfzHlFAAU1720NZXXXXXX"},"success":true}

{"data":{"players":[]},"success":true}

Now i dunno which command more i need to use and which parameters i need to add in browser for the API by http.

thanks