Page 1 of 1

Timers API questions & remarks

Posted: Monday 29 December 2025 11:53
by jvdz
I have been playing with the timers API's for both addtimer and addsetpointtimer and found some quirks and have some questions:

The "/json.htm?type=command&param=getschedules" only returns the timers that are none-persistent for both the switches and setpoint devices. Is this intentional?
eg: output for getschedules:

Code: Select all

{
	"result" : 
	[
		{
			"Active" : "true",
			"Color" : "",
			"Date" : "",
			"Days" : 1234567,
			"DevName" : "DeviceName",
			"DeviceRowID" : 57,
			"IsThermostat" : "false",
			"Level" : 40,
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"Randomness" : "false",
			"ScheduleDate" : "2025-12-29 15:20:00",
			"Time" : "15:20",
			"TimerCmd" : 0,
			"TimerID" : 1,
			"TimerType" : 2,
			"TimerTypeStr" : "On Time",
			"Type" : "Device"
		},
		{
			"Active" : "true",
			"Date" : "",
			"Days" : 1234567,
			"DevName" : "Devicename3",
			"DeviceRowID" : 59,
			"IsThermostat" : "true",
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"ScheduleDate" : "2025-12-29 15:05:00",
			"Temperature" : "15.6",
			"Time" : "15:05",
			"TimerID" : 2,
			"TimerType" : 2,
			"TimerTypeStr" : "On Time",
			"Type" : "Device"
		}
	],
	"status" : "OK",
	"title" : "getschedules"
}
the "/json.htm?type=command&param=gettimers&idx=57" does return them all:

Code: Select all

{
	"result" : 
	[
		{
			"Active" : "true",
			"Cmd" : 0,
			"Color" : "",
			"Date" : "",
			"Days" : 1234567,
			"Level" : 40,
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"Persistent" : "false",
			"Randomness" : "false",
			"Time" : "15:20",
			"Type" : 2,
			"idx" : "1"
		},
		{
			"Active" : "true",
			"Cmd" : 0,
			"Color" : "",
			"Date" : "",
			"Days" : 127,
			"Level" : 100,
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"Persistent" : "true",
			"Randomness" : "true",
			"Time" : "11:05",
			"Type" : 2,
			"idx" : "2"
		},
		{
			"Active" : "true",
			"Cmd" : 0,
			"Color" : "",
			"Date" : "",
			"Days" : 134,
			"Level" : 100,
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"Persistent" : "true",
			"Randomness" : "true",
			"Time" : "11:10",
			"Type" : 2,
			"idx" : "3"
		},
		{
			"Active" : "true",
			"Cmd" : 0,
			"Color" : "",
			"Date" : "",
			"Days" : 13,
			"Level" : 100,
			"MDay" : 0,
			"Month" : 0,
			"Occurence" : 0,
			"Persistent" : "true",
			"Randomness" : "true",
			"Time" : "11:16",
			"Type" : 2,
			"idx" : "4"
		}
	],
	"status" : "OK",
	"title" : "gettimers"
}
Maybe I am not properly understanding what persistent really means, other than that one can't override them, but I did expect the "/json.htm?type=command&param=getschedules" to return them all!?

Some Wiki remarks:

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"
- is missing the persistent option
- states that "days = 1=Mon, 2=Tue, 3=Wed, 4=Thurs, 5=Fri, 6=Sat, 7=Sun", but that should be:

Code: Select all

	-- days bit position: 1=mon (1), 2=tue (2), 3=wed (4), 4=thu (8), 5=fri (16), 6=sat (32), 7=sun (64). 
	     Add the values in the brackets together for the days to be activated.  eg 40=thu+sat
	-- 128 = all days
	-- 256 = weekdays
	-- 512 = weekends


The addsetpointtimer/updatesetpointtimer/deletesetpointtimer api's aren't documented in the wiki yet:

Code: Select all

/json.htm?type=command&param=addsetpointtimer&idx=IDX&active=true&timertype=2&hour=12&min=0&persistent=false&tvalue=15&vunit=%C2%B0C&days=1234567
/json.htm?type=command&param=updatesetpointtimer&idx=Timer_Id&active=true&timertype=2&hour=12&min=0&persistent=false&tvalue=15&vunit=%C2%B0C&days=1234567
will add stuff when i encounter more stuff.

Re: Timers API questions & remarks

Posted: Monday 29 December 2025 13:02
by waltervl
Persistent: Will be available in all timer plans when enabled. (available from beta dd 20-12-2023) ( https://wiki.domoticz.com/Managing_Devi ... ice_Timers )

I suppose that is why persistent are not listed with getschedules. Where is this API call used in the gui?

You are free to update the wiki when needed ;-)

Re: Timers API questions & remarks

Posted: Monday 29 December 2025 14:03
by jvdz
waltervl wrote: Monday 29 December 2025 13:02 Persistent: Will be available in all timer plans when enabled. (available from beta dd 20-12-2023)
I've seen that but it simply isn't clear in my mind yet what that means. So what exactly is the difference between a persistent and non persistent timer as far as behaviour?
waltervl wrote: Monday 29 December 2025 13:02 I suppose that is why persistent are not listed with getschedules. Where is this API call used in the gui?
I don't suppose anything when coding in general and am looking for logic answers when having my coderbrain switched on. 😉
waltervl wrote: Monday 29 December 2025 13:02 You are free to update the wiki when needed ;-)
Understood, but I only document stuff I understand.

Re: Timers API questions & remarks

Posted: Monday 29 December 2025 14:23
by jvdz
To answer the question why they are not in getschedules, i looked in the sourcecode and it is because TimerPlan==9999 aren't selected:

this is in the sql WHERE statement for getschedules:

Code: Select all

"SELECT t.ID, t.Active, d.[Name], t.DeviceRowID AS ID, 0 AS IsScene, 0 AS IsThermostat, t.[Date], t.Time, t.Type, t.Cmd, t.Level, t.Color, 0 AS Temperature, t.Days, t.UseRandomness, t.MDay, t.Month, t.Occurence"
" FROM Timers AS t, DeviceStatus AS d"
" WHERE (d.ID == t.DeviceRowID) AND (t.TimerPlan==%d)"
" ORDER BY d.[Name], t.Time"
...
missing TimerPlan  in Select and no field "persistent" is created for the result.
and this for gettimers:

Code: Select all

("SELECT ID, Active, [Date], Time, Type, Cmd, Level, Color, Days, UseRandomness, MDay, Month, Occurence, TimerPlan"
" FROM Timers "
" WHERE (DeviceRowID==%" PRIu64 ") AND ((TimerPlan==%d) OR (TimerPlan==9999))"
" ORDER BY ID"
.... result field definition...
root["result"][ii]["Persistent"] = (atoi(sd[13].c_str()) == 9999) ? "true" : "false";
So question remains whether this is deliberate or a missed update when persistent was introduced. :-)

Re: Timers API questions & remarks

Posted: Monday 29 December 2025 14:33
by waltervl
There is only one to ask ;-)

But where in the gui is getschedules used? I do not think it is used somewhere. So probably the reason it was not changed during introduction of the persistent timers as it has no influence on the gui of Domoticz.

Re: Timers API questions & remarks

Posted: Wednesday 07 January 2026 20:52
by JanJaap
Hey,

I'm getting the same result (all timers) on "/json.htm?type=command&param=getschedules"
but the other command "/json.htm?type=command&param=gettimers&idx=545" (both with idx for switch and setpoint devices) returns just this:

Code: Select all

{
	"status" : "OK",
	"title" : "gettimers"
}


not sure still how to make a timer persistent. As far as I understand the term 'persistent', all timers are?

btw, updatesetpointtimer works fine with the given params