Loxone & Surveillance Station interactions

823 views
Skip to first unread message

Arnaud

unread,
Oct 25, 2018, 9:26:42 AM10/25/18
to Loxone English
Hello,
I'm tackling a subject that's been going on in my head for quite some time: the interactions between Loxone and Synology Surveillance Station.

More specifically, I want to enable/disable Synology's HOME mode from Loxone.

I found on different forums the commands to send, but I'm not good enough in programming (or smart enough in the Loxone configuration?) to implement them. 

In case someone is able to help us move forward, here's where I am: 

1/ you must first authenticate on the Synology before you can do anything: 
url :  http://<syno_ip_address>:<syno_ip_port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<surveillance_station_user>&passwd=<mypassword>&session=SurveillanceStation&format=sid

By calling this url we get a variable allowing us to authenticate ourselves in the futur url according to : 
"{"data":{"sid": "MzNGJNpoqCP6M1550N4N747204"}, "success":true}; 
this famous SID changes with each authentication unfortunately.

2/ URL to switch from HOME to ON/OFF mode: 
http://<syno_ip_address>:<syno_ip_port>/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=true&_sid=MzNGJNpoqCP6M1550N4N747204 (we see the SID at the end of the url)

synology returns the answer: {"success":true} when everything is going well.

To switch the Home Mode to OFF, simply replace ON with OFF in the same URL.

well, as an option (I'm not sure it's necessary) url to make a logout: 
http://<syno_ip_address>:<syno_ip_port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Logout&version=1

Here, my problem comes from this variable: SID which changes every time, I don't know how to get it back in Loxone (if possible), to integrate it in the URL........

thank you in advance.

Tico

unread,
Oct 25, 2018, 10:33:50 AM10/25/18
to Loxone English
The Miniserver doesn't have the capability to do anything better than BASIC authentication. So I think you're out of luck doing this with Loxone Virtual Outputs in their generic state.

That's not to say it's impossible though...there might be a remote possibility but I haven't tried it.

Set up a Virtual Output with the URL as published above, and also set "Save HTTP reply" to user/common/answer.html (you'll find that half way down the Virtual Output Properties).

Trigger the Virtual Output then....

In another tab of your browser, navigate to -

http://Your_miniserver_IP_address:Port/answer.html (type in username and password when prompted).

and see what's there.

If you get the sid, that's a great start!

Arnaud

unread,
Oct 25, 2018, 10:46:30 AM10/25/18
to Loxone English
thank you for your quick answer,

I'll look at it as soon as I can and publish the result.

otherwise I saw that we could also authenticate without the famous SID, Cookies method they call it.

Does it seem more likely to work with this method in Loxone as a result? (just need username / password), in the web browser it works.

so the url becomes that: 
http://<syno_IP:port>/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<username>&passwd=<password>&session=SurveillanceStation

Tico

unread,
Oct 25, 2018, 6:00:22 PM10/25/18
to Loxone English
I don't think the Miniserver will store cookies. Someone else might confirm? You can only just try and see what happens.

The method with sid is the one I think might work given a few more steps.

David Wallis

unread,
Oct 26, 2018, 7:10:18 AM10/26/18
to Loxone English
you could do that with loxberry and the run command stuff and then use a bash script and curl to acheive that easily enough.. crude but would work.

FWIW - Once I get authentication working in C# libs I plan to do something similar to loxberry but in C# using MEF to allow extensions to be addded.. but still struggling for time to sort the auth and a lack of response from project owners on github.

Tico

unread,
Nov 10, 2018, 6:00:07 PM11/10/18
to Loxone English
Did you succeed in getting the SID recorded by the 'Save HTTP reply'?


On Thursday, October 25, 2018 at 10:46:30 PM UTC+8, Arnaud wrote:

Arnaud

unread,
Nov 12, 2018, 11:08:23 AM11/12/18
to Loxone English
yes, 
i know Loxberry but i'm trying to integrate Surveillance Station Loxone interaction has commercial offer, so for me, loxberry is not an option, has far has i can't install it on a basic synology, without docker because lot of entry level synology don't accept Docker, but are good solutions for surveillance station, Plesk, etc.

Arnaud

unread,
Nov 12, 2018, 11:09:06 AM11/12/18
to Loxone English
hello, 
no, i was totaly over booked last weeks but i'll find time this week to progress.
thanks again.

Arnaud

unread,
Nov 12, 2018, 11:28:37 AM11/12/18
to Loxone English
Got '404 Error' actually .... 

I'm checking what I did, I must have made a mistake somewhere.
it's not very intuitive for me this part.



Le dimanche 11 novembre 2018 00:00:07 UTC+1, Tico a écrit :

Arnaud

unread,
Nov 12, 2018, 11:54:29 AM11/12/18
to Loxone English
here are some images of my configuration, I don't know / don't understand what I did wrong.
Synology virtual output

img1.png



Virtual control for Synology authentication

img2.png



for visualization, I created a switch and connected the virtual controller

img3.png



in the application I can do an ON/OFF but the result (answer.html) always indicates a 404 error.

img4.png



you see something I did wrong?

thanks again for help.

Tico

unread,
Nov 12, 2018, 9:05:26 PM11/12/18
to Loxone English

One aspect that might need adjusting is changing the string to be URL encoded -

Original unencoded URL string -

/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=<surveillance_station_user>&passwd=<mypassword>&session=SurveillanceStation&format=sid

URL encoded string -

%2Fwebapi%2Fauth.cgi%3Fapi%3DSYNO.API.Auth%26method%3DLogin%26version%3D3%26account%3D%3Csurveillance_station_user%3E%26passwd%3D%3Cmypassword%3E%26session%3DSurveillanceStation%26format%3Dsid

If you have trouble working out where to place the user/password, copy the original string and insert the appropriate user/password, then paste into a URL encoder like -




You should end up with a string like above except with your username/password. Also get rid of any special characters in the username/password if you have them. They tend to be troublesome.


If that doesn't work, in the entry for 'HTTP extensions for On', try entering the following -

Content-Type: application/json

John Verdicchio

unread,
Nov 13, 2018, 1:17:15 AM11/13/18
to Loxone English
When attempting to debug http type activity I use Postman. When I know I'm successfully talking and receiving with Postman I then try with the actual device.

A. It's quicker than Loxone config.
B. Rule out any quirky http reading/writing on actual device.

Message has been deleted

Arnaud

unread,
Nov 13, 2018, 3:34:49 AM11/13/18
to Loxone English
thanks for the info, I'll try that, actually it's a little tedious to test the URLs from Loxone directly.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages