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.

Meeting room with separation wall
#1
Hi

I am trying to make a script for two meeting rooms with a separation wall. When the wall is open the two rooms should work as one, but when the wall is closed, each room should work seperately.

I have managed to create a script that sends the commands from the push button in room 1 to the eqvivalent GA's in room 2, but when I create the same for room 2 both scripts will run in infinite loops as they trigger each other.

the code I have used so far is:

ga = event.dst
value = event.getvalue()

Magnet = {'1/1/37'} -- Input indicates if wall is open or not
Input = {'1/1/33', '1/1/35'} -- Input addresses from room 1. 
Output = {'1/1/34', '1/1/36'} -- Adresses in room 2.

-- When pushin buttons in room 1
for id, addr in ipairs(Input) do
  if ga == addr and Magnet == true then
    grp.write(Output[id], value)
    end
end
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#2
You should prepare this in such way:

- event-based script for every pushbutton with such script:
Code:
value = event.getvalue()
magnet = grp.getvalue('Magnet sensor') -- when magnet disconnected room is divided

if magnet then
grp.write('Light 1 on/off', value)
else
grp.write('Light 1a on/off', value)
end
Reply
#3
I believe I made it work.

I need one script for each room and tag the GA in the room with the same tag, wich in turn triggers the script:

ga = event.dst
value = event.getvalue()

Magnet = grp.getvalue('1/1/37') -- Input from contact on the wall
Input = {'1/1/33', '1/1/35'} -- Input addresses from room 1. Lis can be as long as desired. Address [id] MUST comply with [id] in 'Output'!
Output = {'1/1/34', '1/1/36'} -- Adresses in room 2. List can be as long as desired. Address [id] MUST comply with [id] in 'Input'!
Script_room_2 = ('Meeting_2') -- Name of script for the other meeting room.

-- When pushing buttons in room 1

if Magnet == true then
for id, addr in ipairs(Input) do
if (ga == addr) then
script.disable(Script_room_2)
grp.write(Output[id], value)
os.sleep(1)
script.enable(Script_room_2)
end
end
end

As I am rather a newbee in LUA, I would appriciate some inputs as to wether there is a more elegant way of doing this. It works now, and the beauty is that I can add several addresses in each script all with different DPT if need be.

(07.03.2017, 08:38)buuuudzik Wrote: How do one paste the code in this way in the forum?
My pasted codes look just like normal text...
Code:
value = event.getvalue()
magnet = grp.getvalue('Magnet sensor') -- when magnet disconnected room is divided

if magnet then
grp.write('Light 1 on/off', value)
else
grp.write('Light 1a on/off', value)
end
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#4
You can also use event.sender value to check who triggered the event. It will be "bus" for outside telegrams and "us" for user interface. This way you can ignore cases when your script is executed by another script.
Reply
#5
Hi
Just a question about the design. Doesn't your push button or actuator support logical functions? Because what do you need are just 2x AND logic gates. I think the problem can be solved on KNX level. I would prefer this solution because of reliability and better bus load distribution.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#6
(07.03.2017, 09:17)admin Wrote: You can also use event.sender value to check who triggered the event. It will be "bus" for outside telegrams and "us" for user interface. This way you can ignore cases when your script is executed by another script.

OK, thanks, will test that. Then it should be possible to do all with one script instead of two...

(07.03.2017, 17:50)Thomas Wrote: Hi
Just a question about the design. Doesn't your push button or actuator support logical functions? Because what do you need are just 2x AND logic gates. I think the problem can be solved on KNX level. I would prefer this solution because of reliability and better bus load distribution.

AND-gates would work if there were only 1-bit values, but I will need to distribute also 4-bit and 1-byte. The devices in the meeting rooms do not support this themselves in my case.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#7
(07.03.2017, 09:17)admin Wrote: You can also use event.sender value to check who triggered the event. It will be "bus" for outside telegrams and "us" for user interface. This way you can ignore cases when your script is executed by another script.

That worked very well, and was a lot more elegant as I only need one script pr set of meeting rooms. I can now add as many different addresses and DPT as needed to control two meetin rooms in this way;

Code:
----------------------PARAMETERS-------------------------------------------------------------
ga = event.dst
value = event.getvalue()
Magnet = grp.getvalue('1/1/37') -- Input from magnetinc switch on the wall
Meeting1 = {'1/1/33', '1/1/35'} -- Addresses in room 1. List can be as long as desired. Address [id] MUST comply with [id] in 'Meeting2'!
Meeting2 = {'1/1/34', '1/1/36'} -- Adresses in room 2. List can be as long as desired. Address [id] MUST comply with [id] in 'Meeting1'!

-----------------------NO CHANGES BELOW THIS LINE------------------------------------------

if event.sender == 'bus' then
 if Magnet == true then
   
   -- When pushing buttons in room 1
        for id, addr in ipairs(Meeting1) do
     if (ga == addr) then
       grp.write(Meeting2[id], value)
     end
        end
 -- When pushing buttons in room 2
        for id, addr in ipairs(Meeting2) do
     if (ga == addr) then
       grp.write(Meeting1[id], value)
     end
        end  
    end
end
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply


Forum Jump: