Page 1 of 1

turn on for x minutes

Posted: Wednesday 20 November 2024 16:02
by vespino
Using the following API endpoint I turn one of my lights on: json.htm?type=command&param=switchlight&idx1&switchcmd=On

Is it possible to turn it on for x minutes using the API?

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:18
by jannl
If you call it form a script, a simple wait or sleep or (depending on the language) coud do the trick.

ie
ON
sleep (xxx)
Off

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:35
by vespino
Yes that is what I'm doing now, but there's no way to do it using the API then?

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:37
by waltervl
The application that sends that Domoticz API call should handle that....

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:39
by waltervl
jannl wrote: Wednesday 20 November 2024 16:18 If you call it form a script, a simple wait or sleep or (depending on the language) coud do the trick.

ie
ON
sleep (xxx)
Off
Never use a sleep in Domoticz scripts.
in dzvents use command options https://wiki.domoticz.com/DzVents:_next ... riggering)

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:42
by vespino
I'm using PHP so it's easy to wait the number of seconds I want, but it requires an extra call to the API that's why I was hoping it was an option in the API but if not I'm gonna go with that. Cheers.

Re: turn on for x minutes

Posted: Wednesday 20 November 2024 16:47
by waltervl
The Api is developed as interface between the Web User interface and the Domoticz Core application. So every action you do on the web UI results in one or more API calls. So Domoticz core is ready to handle multiple API calls ;-)