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.

Gate opener optimization
#1
Hey

I have made this script to open and close my gate, it works almost all the time Smile

I'm not a programmer at all, so maybe someone can tell me if there is a better/easier/more correct way to make it work 100% all the time.

I have a 4x knx relay where I only use 3 relays

First one (2/2/0) is to control a contactor that  supplies power to a big 3x400vAC to 24vDC transformer.

Second one (2/2/2) is to tell my actuators to close.

Third one (2/2/4) is to tell my actuators to open.

32/1/1 is just to open a widget with the controls.
32/1/4 is to show the status of the gate, open or closed

There is mechanical stops on the gate if it hits something.

Code:
close = event.getvalue()
status = grp.getvalue('32/1/4')


if close== true and
  status== false then
  grp.write('2/2/0', 'true')
  os.sleep(1.5)
  grp.write('2/2/2', 'true')
  os.sleep(12)
  grp.write('2/2/2', false)
  os.sleep(1.5)
  grp.write('2/2/0', false)
  grp.update('32/1/2', false)
  grp.update('32/1/4', true)

    elseif
 
  grp.getvalue('32/1/2')
 
  then
 
  grp.update('32/1/2', false)
 
  end

Code:
open = event.getvalue()
status = grp.getvalue('32/1/4')


if open== true and
  status== true then
  grp.write('2/2/0', 'true')
  os.sleep(1.5)
  grp.write('2/2/4', 'true')
  os.sleep(12)
  grp.write('2/2/4', false)
  os.sleep(1.5)
  grp.write('2/2/0', false)
  grp.update('32/1/3', false)
  grp.update('32/1/4', false)
 
  elseif
 
  grp.getvalue('32/1/3')
 
  then
 
  grp.update('32/1/3', false)
 
  end


[Image: rwd9zEx.png]
Reply
#2
What happens when the script is not working correctly? Maybe the start-up time for the power supply needs to be longer? The delay after the movement can be shorter.
The code looks correct, apart from 'true' in quotes. It works because non-empty string evaluates as boolean true. But if you write 'false' you will get true instead.
Reply


Forum Jump: