Page 1 of 1

How to add device schedule in dzvents (addtimer)

Posted: Wednesday 24 April 2019 17:59
by OlivierFR
Hello,
I'm trying to add a schedule to a device from within a dzvents script.

Here is the API of the command :

Code: Select all

../json.htm?type=command&param=addtimer&idx=DeviceRowID&active=true&timertype=2&hour=0&min=20&randomness=false&command=0&days=1234567
I thought about using SendCommand() but it does not seem to work.

What is the right way to do this?

Thanks!
Olivier

Re: How to add device schedule in dzvents (addtimer)

Posted: Wednesday 24 April 2019 21:21
by waaren
OlivierFR wrote: Wednesday 24 April 2019 17:59 I'm trying to add a schedule to a device from within a dzvents script.
What is the right way to do this?
I would use a dzVents function for this.

Code: Select all

local function addSchedule(idx,action,hour,minute)
    local command = 0 -- On
    if action:lower() == "off" then 
        command = 1 -- Off
    end       
    local jsonString  = "/json.htm?type=command&param=addtimer&idx=" .. idx ..
                         "&active=true&timertype=2&hour=" .. hour .. 
                         "&min=" .. minute .. 
                         "&randomness=false&command=" .. command ..
                         "&days=1234567" 
    domoticz.openURL( domoticz.settings["Domoticz url"] .. jsonString )
end

addSchedule(xxx,"On",hh,mm) -- replace xxx with your device number, hh with the hour and mm with the minute. Only  "On" and "Off" can be used in this function 

Re: How to add device schedule in dzvents (addtimer)

Posted: Thursday 25 April 2019 14:16
by OlivierFR
Thanks!
This works perfectly.