Page 1 of 1
delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 18 October 2023 19:21
by bitzy
i need to pause or sleep or delay somehow a script for 120 seconds. someone can help me telling me how to do it?
i need a switch to turn on , a variable to get value 'true', then i need the script to wait for 120 seconds for the physical action to take place, then the var to take the 'false' value. i 'm not getting how pause/sleep works in domoticz !!!
something like this:
Code: Select all
moveRl.switchOn().forSec(120)
valveResetInProgress.set('true')
dz.log('Waiting for 120 seconds before setting valve position...', dz.LOG_INFO)
sleep(120)
valveResetInProgress.set('false')
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 18 October 2023 20:41
by solarboy
You could try
Code: Select all
valveResetInProgress.set('true')
valveResetInProgress.set('false').afterSec(120)
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Thursday 19 October 2023 1:18
by HvdW
Try to avoid using sleep()
Run your script every 2 minutes.
https://www.domoticz.com/wiki/Events
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Saturday 21 October 2023 19:24
by bitzy
none of this is helpful. this is the full picture: i have a script that run every 2 minute (or 1 min, or 3, 10 ..) to control an actuator witch move a mixing valve to keep a constant temperature when a pump switch is on and a auto-manual selector is in auto state. when i turn off one of those 2, the regulating temperature script is stopped and the actuator move the valve all the way in max-down position (this way i do a synchronization between the physical valve position and the variable that keep the position of the valve in domoticz and protect the underfloor circuits of a temperature spike if the pump is starting at a temperature of 80 - 90 degree and the valve is in the open position). in those 120 seconds when the valve is moving down, if the regulating script is turned back on and start to move the valve, the reset of the valve is stopped and the physical position is way off from the position that domoticz know the valve have (max-down (-60). so, i need a way to make domoticz know that the valve is moving and to not start any other command on the valve's actuator while this is in motion from the reset command.
viewtopic.php?t=40261 here are the full script that control the actuator and the script that reset the valve.
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Saturday 21 October 2023 23:04
by hoeby
What you can do is make a dz.openUrl with a callback function.
This dz.OpenUrl is then fired after X seconds. In your case the 120 seconds.
With the callback you can retrigger your script to do the thing it then has to do.
As far as i known. There is now real delay option in dzvents. Because a delay will pause all process of your system, what you don't want. This is kind of a work around, to retrigger the script after the seconds your programmed
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Saturday 21 October 2023 23:08
by hoeby
Info about this option in dzvents wiki
https://www.domoticz.com/wiki/DzVents:_ ... d_handling
Do the dz.openUrl with a afterSec() added, that will work as a delay
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Tuesday 24 October 2023 23:34
by solarboy
Exactly and perhaps add the delayed switch as a "device trigger"
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 01 November 2023 11:56
by willemd
Did you solve your issue? I had a similar requirement and this is how I would translate my solution to your case:
1) You need to have either a device or a persistent variable to hold your red flag, so if this device or variable is true then no further action is allowed.
2) You set the red flag when you start the valve-reset action.
3) At the same time you run the command: domoticz.emitEvent('ResetRedFlag').afterMin(2)
4) You add 'ResetRedFlag' as a customEvents trigger to your script
4) Each time the script is started, it checks whether it was launched by one of the previous triggers or by the customEvent trigger.
5) If it was triggered by one of the previously existing triggers, it checks for the red flag and if the red flag was set, it stops, otherwise it continues.
6) If it was triggered by the customEvent, then it resets the red flag.
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 03 April 2024 20:48
by neveride
And where can I find a manual for the blockly commands? I see a "set after" block. I execute my script at e.g. 20:00 and I see in the logs that it was triggered. I set my ligts "On" after 60 seconds and then in the second action I set my lights "Off" after 120 seconds. I would expect my lights to turn on at 20:01 for one minute. But nothing happens.
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 03 April 2024 21:10
by waltervl
Here is the wiki
https://www.domoticz.com/wiki/Blockly
And here is the forum about blockly
https://www.domoticz.com/forum/viewforum.php?f=62
Please make a new topic in that forum if you have specific questions about Blockly (search the subforum first!)
Re: delay, pause, sleep script for xx seconds. how to?
Posted: Wednesday 03 April 2024 21:19
by neveride
OK, just to respond to my issue, because I solved it. Do not use diacritical signs in your devices' names (in Polish e.g. ę, ą, ć, ó, ż, ź, ć). Blockly will fail. I changed my device name to English and everything works as it should. Not sure it is mentioned somewhere, but I haven't stumbled upon it, so it cost me some nerves.
@waltervl: obviously I visited
https://www.domoticz.com/wiki/Blockly, but I did not find information about how set after works...One can only assume that it's logical.