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.

Set / reset circuit with timer
#1
Hi
Im looking for a simple script.

Input 1 - KNX 0/2/5
Input 2 - KNX 0/2/6
Input 3 - KNX 0/2/7 (same as output)
Output - KNX 0/2/7 (same as input 3)

If input 1 sends 1 to the bus it will set the output to 1 and start a timer for 2 hours. After the timer ends the output is set to 0. A new input will restart the timer.
If input 2 sends 1 to the bus it will stop the timer.
If input 3 sends 0 to the bus it will stop the timer.

Can someone point me in the right direction?
Reply
#2
For the timer you need a scheduled script that runs every minute. It check if the object is in ON state and sends off if the object has not been updated in 2 hour time.
Code:
obj = grp.find('0/2/7')
now = os.time() -- current timestamp in seconds
delta = now - obj.updatetime -- last object update relative time

if obj.value and delta > (2 * 60 * 60) then
  obj:write(false)
end

You will need two event scripts.

0/2/5 (turn 0/2/7 ON when ON is received):
Code:
value = event.getvalue()
if value then
  grp.write('0/2/7', true)
end

0/2/6 (turn 0/2/7 OFF when ON is received):
Code:
value = event.getvalue()
if value then
  grp.write('0/2/7', false)
end
Reply
#3
Thank you for the reply! This script is for my garden gate.
I've been playing with this and the code provided is that this is supposed to integrate with an existing KNX installation where 0/2/6 is a telegram that "locks" the gate in an unlocked state, and 0/2/7 is a telegram that removes this lock and returns the operation to normal.
0/2/5 is a spare trigger that first sends a 1, then a 0 when operated - currently not doing anything.

So what I' m trying to do is use this spare trigger to make a 2 hour unlocked gate function if that makes sense? I need to be able to reset the timer and bring the gate back to normal operation or to permanent unlock during the timer period.
Reply
#4
For irrigation you may want to use this
https://forum.logicmachine.net/showthrea...61#pid8161
------------------------------
Ctrl+F5
Reply
#5
If I adjust the first code, will this work?
Code:
obj1 = grp.find('0/2/6') -- "lock"
obj2 = grp.find('0/2/7') -- "normal"
obj3 = grp.find('0/2/5') -- "2 hour lock"

now = os.time() -- current timestamp in seconds
delta1 = now - obj1.updatetime -- last object update relative time
delta2 = now - obj2.updatetime -- last object update relative time
delta3 = now - obj3.updatetime -- last object update relative time

if (delta1 > delta3) and (obj2.value and delta2 > (2 * 60 * 60))  then
  obj2:write(false)
end
Reply
#6
Your code does not check 0/2/6 and 0/2/5 values, only their update time. Some extra if's are needed there. You need to correctly define the logic of operation then it will be easy to write a script for that.
Reply
#7
(12.08.2020, 09:33)admin Wrote: For the timer you need a scheduled script that runs every minute. It check if the object is in ON state and sends off if the object has not been updated in 2 hour time.
Code:
obj = grp.find('0/2/7')
now = os.time() -- current timestamp in seconds
delta = now - obj.updatetime -- last object update relative time

if obj.value and delta > (2 * 60 * 60) then
  obj:write(false)
end

Sorry TS
Thank you this is exactly what i was looking for.
I will use this for occupancy detector, light go on by movement, and go to 20% dimming by no movement for 10 minutes.
But when burgely alarm is on (nobody is in the boulding) light need to turn off.
My question, is it possible to disable a 'scheduled script' by a knx object or do i have to implement it in the script?


Or is it better to open a new topic?
Reply
#8
It's easier to implement this in the script like this:
Code:
lock = grp.getvalue('1/2/3')
if lock then
  return
end
But in this case I see no problem because this script turns off the light. And if the light is already turned off before that then nothing happens.
Reply
#9
Well almost, at day, the light need to go to 20% after no movement of 10 minutes.
When everybody is gone, and alarm turns on, all lights need to turn off.

But when it isnt posible i have to do it with a extra line in the script.
I have multiple of this, in the same project, so i have to copy past it for 40 times.
Reply


Forum Jump: