Hue script Json Curl Windows not working.

Moderator: leecollings

Post Reply
Tjeerd13
Posts: 34
Joined: Thursday 07 May 2015 16:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Assen
Contact:

Hue script Json Curl Windows not working.

Post by Tjeerd13 »

Hello

Im new to scripting for domoticz and i'm trying to use my Hue lamp with curl and Json Scripts on a windows (2008) PC

I'm trying to start Easy :)

I want to switch my HUE lamp with Device ID 5 with a Json scirpt With a Dummy On/Off Switch named Hue1 (Type Lightnig 1, X10, On/Off)
(And yes i know it can be Easyer. But i want to start easy with Json later on i want use scene's groups etc... ;) )

What i did.

When i run in a "cmd box "on windows 2008

Code: Select all

curl -X PUT -d "{\"on\":true}" http://192.168.1.15/api/myID/lights/5/state
The lights turns on :D

Code: Select all

curl -X PUT -d "{\"on\":false}" http://192.168.1.15/api/myID/lights/5/state
and the lights turns off. :D

When i create .bat file with the name 5on.bat and 5off.bat and i run the .bat file the lighst switches on/off :D

The batch files are placed in

Code: Select all

C:\Program Files (x86)\Domoticz\scripts
And i like to keep them only there but i can't get it running from the "domoticz script map".

When i place 5on.bat and 5off.bat in the c:\ and use

Code: Select all

script://5on.bat
and

Code: Select all

script://5off.bat
I can see in the log the Script is excecuted but nothing happens.

Code: Select all

2015-05-07 17:11:18.269 (Dummy) Lighting 1 (Hue1)
2015-05-07 17:11:19.106 Executing script: /5off.bat
2015-05-07 17:11:25.657 (Dummy) Lighting 1 (Hue1)
2015-05-07 17:11:26.127 Executing script: /5on.bat
What i want. I would love to keep the .bat file in the /scrips map.
Is it possible to use this Json code without the / strings? What's the right/easy way to use a json code in Domoticz?
How do i get the .bat file running?
Pi3, Pi4, Pi4 for Testing, Dashticz, RFXtrx433, Nest: "Thermostat V2, V3, Hello". Honywell Lyric T6R, RFXCom, KaKu, HUE, P1, Open Zwave USB,
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Hue script Json Curl Windows not working.

Post by ThinkPad »

Have you tried other .bat scripts to see if that works? A simple test script that creates a .txt file or something?
I am not active on this forum anymore.
Tjeerd13
Posts: 34
Joined: Thursday 07 May 2015 16:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Assen
Contact:

Re: Hue script Json Curl Windows not working.

Post by Tjeerd13 »

I make a test.bat add the c:\

Code: Select all

cd\
md test
When i run the .bat file manualy it create a dir.
When i run it with the dumy switch nothing happening only a message in the log file with

Code: Select all

(Dummy) Lighting 1 (Hue1)
Executing script: /test.bat
thats indicates thath the file is found.

Help :D :o :o ;)
Pi3, Pi4, Pi4 for Testing, Dashticz, RFXtrx433, Nest: "Thermostat V2, V3, Hello". Honywell Lyric T6R, RFXCom, KaKu, HUE, P1, Open Zwave USB,
matt
Posts: 3
Joined: Friday 17 July 2015 20:09
Target OS: Windows
Domoticz version: 2.2657
Contact:

Re: Hue script Json Curl Windows not working.

Post by matt »

I have this issue, did you find a fix??
Tjeerd13
Posts: 34
Joined: Thursday 07 May 2015 16:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Assen
Contact:

Re: Hue script Json Curl Windows not working.

Post by Tjeerd13 »

No i did not... I bought a Raspberry II [FACE SAVOURING DELICIOUS FOOD]
Pi3, Pi4, Pi4 for Testing, Dashticz, RFXtrx433, Nest: "Thermostat V2, V3, Hello". Honywell Lyric T6R, RFXCom, KaKu, HUE, P1, Open Zwave USB,
foggy75
Posts: 1
Joined: Monday 23 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Hue script Json Curl Windows not working.

Post by foggy75 »

I had the same problem, and figured out how to make it work:

First, rename the batch file _domoticz_main.bat file to domoticz_main.bat in the scripts folder.
Now this script will get executed each time you toggle a switch.

In this sample script however, there is a problem caused by the default install location for domoticz on windows has spaces in the pathname, which leads to the variables inside the main batch file not being set correctly.
To fix this, update set commands in the batch file like this:

Code: Select all

REM due to install location containing spaces, parameters %1 through %3 are all pieces of the startup_path
set startup_path=%1 %2 %3
set hardware_id=%4
set device_id=%5
set status=%6
set status2=%7
set devname=%8
Then from this script I could launch my custom script using the path, devname and status variables.

Another trick for troubleshooting: add the pause command at the end of the domoticz_main.bat file, this will cause the window to stay open until a key is pressed...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest