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.

scripitng
#1
Hello guys need your help with a event based script 
I have made a event based on group address of the movement of a motion sensor 
My client want to when  movement is trigger to turn on the lights of the corridor 1 by 1 with 1 sec delay deference 
here is the script that i made but doesnt work and i dont get  any error logs 

--event base  off the movement the motion detecor
if event.getvalue(1)
  then
--light 1 without time delay when its on
value = 1
grp.write(0/3/6, value)

  --light 2 with time delay 1 sec when its on
value = 1
os.sleep(1)
grp.write(0/3/7, value)
    --light 3 with time delay 2 sec when its on
value = 1
os.sleep(2)
grp.write(0/3/8, value)
  --light 4 with time delay 3 sec when its on
value = 1
os.sleep(3)
grp.write(0/3/9, value)
 
  --light 5 with time delay 4 sec when its on
value = 1
os.sleep(4)
grp.write(0/3/6, value)
 
 
  else

  --light 1 with time delay 4 when its off
value = 0
os.sleep(4)
grp.write(0/3/6, value)
 
    --light 2 with time delay 3 sec when its off
value = 0
os.sleep(3)
grp.write(0/3/7, value)
 
    --light 3 with time delay 2 sec when its on
value = 0
os.sleep(2)
grp.write(0/3/8, value)
 
    --light 4 with time delay 1 sec when its off
value = 0
os.sleep(1)
grp.write(0/3/9, value)
 
  --light 2 without time delay  when its off
value = 0
grp.write(0/3/10, value)

end
Reply
#2
You are missing quotes around group addresses. It should look like this:
Code:
grp.write('0/3/6', value)

Other issues:
- Use os.sleep(1) for all delays
- In OFF branch you need to put group addresses in reverse order (from '0/3/10' to '0/3/6')
- Last address in ON branch is incorrect (should be '0/3/10' instead of '0/3/6')
Reply
#3
(8 hours ago)admin Wrote: You are missing quotes around group addresses. It should look like this:
Code:
grp.write('0/3/6', value)

Other issues:
- Use os.sleep(1) for all delays
- In OFF branch you need to put group addresses in reverse order (from '0/3/10' to '0/3/6')
- Last address in ON branch is incorrect (should be '0/3/10' instead of '0/3/6')
Thank you Very much
Reply
#4
Hi Volttech,

you must also use true and false instead of a 1 or 0,
If you use scenes then it is fine.
Reply
#5
You can use 1/0 when writing to objects. But you can't compare booleans against 1/0.
Reply


Forum Jump: