Hue labs, dzVents and curl

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Hue labs, dzVents and curl

Post by Sarcas »

I did the things described here in the forum to get a curl thing to enable and disable a hue labs scene. I fail miserably to convert the curl command to a dzVents command. I have this:

The curl command

Code: Select all

curl --header "Content-Type: application/json"   --request PUT  --data '{"status":1}'   http://192.168.8.177/api/<myAPI>/sensors/97/state
The dzVents part I made:

Code: Select all

domoticz.openURL({
url = 'http://192.168.8.177/api/<myAPI>/sensors/97/state',
method = 'PUT',
headers = { ['Content-Type'] = 'application/json' },
postData = { ['status'] = '1' }
})
I changed brackets and apostrophes but it just doesn’t work. What did I do wrong?

Thx
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Hue labs, dzVents and curl

Post by waaren »

Sarcas wrote: Monday 01 February 2021 16:02 I did the things described here in the forum to get a curl thing to enable and disable a hue labs scene. I fail miserably to convert the curl command to a dzVents command. I have this:
The right syntax to convert a curl PUT to dzVents openURL is

curl -H 'Content-Type: application/json' -X PUT -d '{"bri": 1,"ct":450}' h ttp://192.168.192.72/api/<API Key>/lights/27/state

Code: Select all

return {
    on = {
        devices = {
            'Hue Trigger',
        }
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'hue',
    },

    execute = function(dz)

        dz.openURL(
        {
            url  = 'http://192.168.192.72/api/<API Key>/lights/27/state',
            method = 'PUT',
            headers = { ['Content-Type'] = 'application/json' },
            postData = '{ "bri": 123,"ct":450 }'
        })

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Re: Hue labs, dzVents and curl

Post by Sarcas »

I knew it had something to do with the #$%@ '-s and "-'s! I really should figure out what the syntax is.

Thanks @waaren!
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest