Page 1 of 1

Hue labs, dzVents and curl

Posted: Monday 01 February 2021 16:02
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

Re: Hue labs, dzVents and curl

Posted: Monday 01 February 2021 17:08
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
}

Re: Hue labs, dzVents and curl

Posted: Tuesday 02 February 2021 7:23
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!