Page 1 of 1

Run script every min, but only when a switch is on.

Posted: Sunday 05 August 2018 2:01
by sion
Hi.
I have just started looking a moving my lua and blockly to dzvents.

I was just wondering something about the triggers.

If I have
On
Timer : every 1 minute
Switch : my-switch

Will this run the script every min, AND when the switch is switched?

I am hoping to only run the script WHEN the switch is on.

So something like
On: timer: every minute ( when switch ==on).

Is it possible to do it in the top trigger section?

I know it will be possible to run the script every min, and then inside the execute section have:
If switch=on then
Do stuff....
End.

But I am trying not to have too many scripts running every minute.

Thanks.

Re: Run script every min, but only when a switch is on.

Posted: Sunday 05 August 2018 2:24
by Andyf66
Not sure dzvents does what you’re looking for, but my proposed extension would help. You could have a script that only is triggered by the switch, but then fires off a 1 minute timer to re-trigger itself.

viewtopic.php?f=59&t=24022&p=185214#p185214

Re: Run script every min, but only when a switch is on.

Posted: Sunday 05 August 2018 12:15
by dannybloe
It doesn't matter if you add some functionality to the on-section because domoticz only has a timer trigger that triggers every minute. So that's what dzVents gotta work with. All the checking for state of devices is done on the Lua side (in dzVents).
Having said that... just make an every-minute timer and check inside your execute function. If you don't want to do that, create a timer function and check in there (see the doc about this). But basically it's all the same.

Re: Run script every min, but only when a switch is on.

Posted: Sunday 05 August 2018 20:10
by sion
Thanks for the clarification.
I think I’ll set a timer for every min, and then check to see if the switch is on inside the execute.

How many scripts can you have Running every min before it would start to have an impact on a rasp pi?
I’m probably worrying about nothing.

Re: Run script every min, but only when a switch is on.

Posted: Sunday 05 August 2018 20:56
by waaren
sion wrote: Sunday 05 August 2018 20:10 Thanks for the clarification.
I think I’ll set a timer for every min, and then check to see if the switch is on inside the execute.

How many scripts can you have Running every min before it would start to have an impact on a rasp pi?
I’m probably worrying about nothing.
I have > 20 and no significant impact.