Page 1 of 1

add the FOR AFTER RANDOM command to the API

Posted: Tuesday 15 November 2016 22:57
by jmleglise
Complete the switch command API with the FOR, RANDOM, AFTER keyword.

Today whe have :
/json.htm?type=command&param=switchlight&idx=99&switchcmd=On

I need switchcmd=On FOR xxx

This is available in LUA commandArray. but not in the API. (It's a rare case where the API is less complete than LUA).

Why is it important ?
For some accurate timer, (Ex : alarm system triggered in 30 sec) I need the AFTER 30 sec keyword to trigger some switches. But I can't use LUA because "by design" LUA, doesn't trigger the eventSystem for the virtual switch. Only the use of API / GUI trigger the event.

So I'm fucked.

Re: add the FOR AFTER RANDOM command to the API

Posted: Tuesday 15 November 2016 23:02
by Egregius
How about php?
sleep(30)

But maybe first better explain why it has to be exactly after 30 seconds. Aren't there cases when you don't want to fire after 30 seconds and thus break the wait time?
If I understand correctly if you sent a ON AFTER 30 it will switch on after 30 seconds, no mather what you do in that time.
Therefore I always use a evalutation after the 30 seconds time to see if the action is still nescessary.

Re: add the FOR AFTER RANDOM command to the API

Posted: Tuesday 15 November 2016 23:18
by jmleglise
Hi egregus,

Sorry, I know you are looking for some friends on php :-) but, I use LUA and python and that's enough for me.

My point seems just an "evidence". Domoticz offers the feature to switch FOR x , AFTER x, but not by the API. I report a "shortage".

Re: add the FOR AFTER RANDOM command to the API

Posted: Wednesday 16 November 2016 10:40
by stlaha2007
Would be handy, however scenes/groups have this buildin, so to say slave switches with delayed on or off. Using this to switch on/off lights with predefined delays from 2 to 10 seconds.

Perhaps create a scene/group with that 'delayed' switch with on delay of 30 seconds and toggle or on/off that scene/group?