Long loop run for water pump ! - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Long loop run for water pump ! (/showthread.php?tid=3821) |
Long loop run for water pump ! - phongvucba - 22.01.2022 Hi everybody ! Hope everyone can help me! I have a problem that I don't know how to do, the owner asked me to program the water pump to run in a loop. Specifically, run for 1 hour, rest for 30 minutes, then run again for 1 hour, then rest for 30 minutes. And so on until they press the stop command. Has anyone done this before? I would really appreciate your help. Thank you very much ! RE: Long loop run for water pump ! - Erwin van der Zwart - 22.01.2022 What you can do is create a boolean start/stop object and add this script to it: Code: script.set('Pump Interval', event.getvalue()) Code: pump_address = '1/1/1' Erwin RE: Long loop run for water pump ! - phongvucba - 24.01.2022 Thank so much ! I will try it ! ) RE: Long loop run for water pump ! - admin - 24.01.2022 It makes sense to turn the pump off when the script is disabled. Otherwise it can be left on when the resident script is disabled. Event script: Code: pump_address = '1/1/1' RE: Long loop run for water pump ! - Erwin van der Zwart - 24.01.2022 Good catch (: RE: Long loop run for water pump ! - phongvucba - 28.01.2022 Hello ! I have a little trouble in this loop ! I already did that loop! Thanks everyone I have the following problem and have the following objects: -4 valve address is 1/1/1 ; 1/1/2 ; 1/1/3 ;1/1/4 - Pump address is 2/1/1 I want to program 1 of the other 4 valves to be ON then the pump must be ON. And if pump is ON, all 4 valves are ON. Pump is OFF, all 4 valves are OFF In the 2/1/1 address pump I'm writing: ----------------------------------- value = event.getvalue() if value==true then grp.write('1/1/1',true) grp.write('1/1/2',true) grp.write('1/1/3',true) grp.write('1/1/4',true) else grp.write('1/1/1',false) grp.write('1/1/2',false) grp.write('1/1/3',false) grp.write('1/1/4',false) end --------------------------------- In each valve I write, for example valve number 1 1/1/1: value = event.getvalue() if value==true then grp.write('2/1/1',true) end --------------------------------- I am having an endless loop, and there is no way to solve the above problem. RE: Long loop run for water pump ! - admin - 28.01.2022 Replace grp.write with grp.checkwrite. First script can be made shorter like this: Code: value = event.getvalue() RE: Long loop run for water pump ! - phongvucba - 30.01.2022 I tried and it didn't work.! For example, all 4 of my values are OFF(1/1/1;1/1/2;1/1/3;1/1/4). When I 1/1/1=ON then 2/1/1=ON, so all my values are also =ON (and I don't want the rest to be ON) (Only 1 valve value is OFF, here it pulls all 4 valves, that's not correct) RE: Long loop run for water pump ! - admin - 31.01.2022 In this case you can add checks that the event script was not triggered by another event script. Code: if event.sender ~= 'se' then Code: value = event.getvalue() |