Logic Machine Forum
did i create a loop - 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: did i create a loop (/showthread.php?tid=3956)



did i create a loop - Dré - 24.03.2022

I have a question,
it looks like i create a loop.
Now i will understand if my thoughts about this are correct, and what is the best way to solve this?


I have 1 script, that's start run by a tag 'Play_Knocks'.
Is it true, this script run in a loop, because i ask a read on the same groupadress who has the tag who start this script?
I think I can't use 'value = event.getvalue()' because, i have two different logics who can start the sounds


Code:
PIR_salvage = grp.read('14/0/58')            --this got the tag 'Play_Knocks'
Door_salvage = grp.read('14/0/57')

garden_door  = grp.read('14/0/42')
PIR_livingroom = grp.read('14/0/28')            --this got the tag 'Play_Knocks'

sound_released  = grp.read('32/1/21')


if     PIR_salvage == true
        and Door_salvage == true
        and sound_released == true
        then grp.write('32/1/22', true)    --'Play Sound Knock on Wiser'
        
elseif
        PIR_livingroom == true
        and garden_door == true
        and sound_released == true
        then grp.write('32/1/22', true)    --'Play Sound Knock on Wiser'
        
        end



RE: did i create a loop - admin - 24.03.2022

Does 32/1/22 have the same tag which is executing the script?


RE: did i create a loop - Dré - 24.03.2022

No only
PIR_salvage = grp.read('14/0/58') --this got the tag 'Play_Knocks'
PIR_livingroom = grp.read('14/0/28') --this got the tag 'Play_Knocks'

has the same tag


RE: did i create a loop - admin - 24.03.2022

Replace grp.read with grp.getvalue


RE: did i create a loop - Dré - 24.03.2022

(24.03.2022, 15:16)admin Wrote: Replace grp.read with grp.getvalue

Yes this was the solution.

does grp.read trigger the script again because it had the tag on this groupadress too?


RE: did i create a loop - admin - 25.03.2022

grp.read can trigger the script if "Execute on group read" is enabled.


RE: did i create a loop - Dré - 25.03.2022

Thanks, i dont know where to find this option, i looked for it, but didnt see it, but probably it is enabled


RE: did i create a loop - admin - 25.03.2022

In script properties:
   


RE: did i create a loop - Dré - 26.03.2022

Oké, i see i take a look and it was off, like your picture show.

but the problem solved when i did do this.

(24.03.2022, 15:16)admin Wrote: Replace grp.read with grp.getvalue



RE: did i create a loop - admin - 26.03.2022

Then another device replied to the read request which then executed the script again and so on.


RE: did i create a loop - Dré - 26.03.2022

I see now i understand my problem, thanks for explaining