How to add device schedule in dzvents (addtimer)

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

Moderator: leecollings

Post Reply
OlivierFR
Posts: 12
Joined: Friday 25 July 2014 18:32
Target OS: Linux
Domoticz version:
Contact:

How to add device schedule in dzvents (addtimer)

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
OlivierFR
Posts: 12
Joined: Friday 25 July 2014 18:32
Target OS: Linux
Domoticz version:
Contact:

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

Post by OlivierFR »

Thanks!
This works perfectly.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest