Page 1 of 1

On-off sequence based on dummy switch status

Posted: Sunday 19 June 2022 16:41
by vanenkelen
Hi,

My first post here. I've been reading a lot and also been testing and experimenting a lot, but I couldn't find a way to solve my 'issue'. Therefore I took the step to post it here and ask for help. I'm afraid I'll have to move to one of the scripting subforums, but I hope someone knows how to solve this with a Blockly. My scripting skills are very poor.

What do I want to achieve:
Start: I turn a dummy switch on
Result: Domoticz switches a real powerswitch on for 1 minute, off for 10 minutes, on for 1 minute, off for 10 minutes, etc. etc. for as long as the dummy switch is turned on
End: I turn the dummy switch off, then the real powerswicht is turned off and the sequence is stopped.

Is this possible with blockly? And if not, which scripting language is best suited for a scripting noob?

NB: If I missed something in preparation for a first post or rules wrt a first post, I'm sorry and please guide me the way :idea:

Re: On-off sequence based on dummy switch status

Posted: Wednesday 29 June 2022 10:32
by Dave21w
Hi, give this a try, obviously adjusting the timing values to suite your needs. The reason you need 2 off times is because both timers will start at the same time so the first one is effectively your ON time and the second is your OFF time, remember your second off time value has to be both added together so given your post you need 60 in the first one and 660 in the second one, this will give you 1min on and 10mins off. The last 2 lines just mean if you switch it off again during the first minute it will go off straight away.

Hope the above makes sense
Timer Test.jpg
Timer Test.jpg (34.69 KiB) Viewed 3123 times
Regards
Dave

Re: On-off sequence based on dummy switch status

Posted: Friday 01 July 2022 21:32
by vanenkelen
It works, thanks! Only I'm not sure why... haha. I've read your post three times and am still trying to understand the logic, but it does exactly what I want. And indeed 60-660 in seconds gives me my 1 minute on and 10 minutes off.

Again, thanks!

While hitting the submit button something clicks in my head. So if I try to explain. The first timed off command (5 seconds in your example) sets the timed physical switch off. The second second off-command (10 seconds in your example) triggers the first rule of the blockly again?

That is interesting behaviour to reuse in other scripts!

Re: On-off sequence based on dummy switch status

Posted: Saturday 02 July 2022 17:05
by Dave21w
Your welcome and your description is certainly accurate as to what happens, its not quite how I would describe it but if you understand it better using those rules then that's good news, I came up with that blocky years ago as I needed to cycle a mains socket on and off every 15 minutes. Like you my scripting knowledge could be written on the back of a postage stamp :lol:

Regards
Dave