This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

did i create a loop
#1
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
Reply
#2
Does 32/1/22 have the same tag which is executing the script?
Reply
#3
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
Reply
#4
Replace grp.read with grp.getvalue
Reply
#5
(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?
Reply
#6
grp.read can trigger the script if "Execute on group read" is enabled.
Reply
#7
Thanks, i dont know where to find this option, i looked for it, but didnt see it, but probably it is enabled
Reply
#8
In script properties:
   
Reply
#9
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
Reply
#10
Then another device replied to the read request which then executed the script again and so on.
Reply
#11
I see now i understand my problem, thanks for explaining
Reply


Forum Jump: