Wondering if any kind devs might be able to help shed some light on an error i am getting when attempting to run a windows .bat file from a http call using an open source service named SleepOnLan. The service is from here:
Multi-platform process allowing to sleep on LAN a linux or windows computer, through wake-on-lan (reversed) magic packets or through HTTP REST requests. - SR-G/sleep-on-lan
and i have it running on my PC and can successfully sleep my pc from calling http://i.paddress:8009/sleep
I have been attempting to alter this service to run a local .bat file from http://i.paddress:8009/dson
call and by adding the following to to a sol.json file in the same directory as the sol.exe
{
“Listeners” : [“UDP:9”, “HTTP:8009” ],
“LogLevel” : “INFO”,
“BroadcastIP” : “255.255.255.255”,
“Commands” : [
{
“Operation” : “dson”,
“Command” : “C:\Scripts\DreamScreenCommander-master\DsOn.bat”
]}
but when the sol.exe tries to read the sol.json file i get the following error:
INFO: 2019/10/12 17:20:16 configuration.go:59: Configuration file found under [C:\Tools\SleepOnLan\sol.json], now reading content
ERROR: 2019/10/12 17:20:16 configuration.go:64: error while loading configuration : invalid character ‘S’ in string escape code
I probably have some incorrect syntax or character…
Appreciate any assistance
INFO: 2019/10/12 20:22:07 configuration.go:59: Configuration file found under [C:\Tools\SleepOnLan\sol.json], now reading content ERROR: 2019/10/12 20:22:07 configuration.go:64: error while loading configuration : invalid character ']' after object key:value pair
Nice,
That worked, thanks heaps. I now have a method to call a .bat file which executes a python script with arguments to turn on and off my dreamscreen when a movie is played and stopped (using Chefs Vera plugin for emby and a http call in a scene from vera )
This is the working sol.json
(Once again, I reformatted your code in the post to show \\ rather than \ for the benefit of any interested readers. It’s best to use the correct forum formatting with the buttons on the top of the post – makes things so much more readable.)
To answer your question, I’m not sure, because I don’t know the syntax required by your target application. However, I would guess from the JSON structure:
If your still around Akbooer, i have 1 final hurdle
I have a scene that i already use to call when a movie is started with the following luup code:
local dID = 595 – Device ID of your VirtualSwitch
local allow = true – true runs scene if switch is on, false blocks it
local status = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,dID)
return ((status == “1”) == allow)
To this scene and luup i would like to add the following http call:
luup.inet.wget(‘http://i.p address:8010/dson’)
If i just add a new line to the existing luup i get an error, might you please be able to assist with the correct way to make both call in a single vera scene ?
luup.inet.wget(‘http://i.p.address:8010/dson’)
local dID = 595 – Device ID of your VirtualSwitch
local allow = true – true runs scene if switch is on, false blocks it
local status = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,dID)
return ((status == “1”) == allow)
luup.inet.wget "http://i.p.address:8010/dson"
local dID = 595
local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "Status", dID)
return status == “1”
I don’t know whether it’s a function of the way that you’ve cut and pasted the code, or the forum software, but I am concerned that the double quotes have been turned into inverted commas and the double minus sign, for comments, converted to an em-dash. These will certainly give syntax errors. I’ve tried to cut out all the gratuitous stuff (including the comments) in the code to make it simpler.
It’s also possible that you should use:
local dID = 595
local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "Status", dID)
if status ~= “1” then return false end
luup.inet.wget "http://i.p.address:8010/dson"
return true
…depending on the effect you are actually trying to achieve.