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
#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


Messages In This Thread
RE: Meeting room with separation wall - by Trond Hoyem - 21.03.2017, 12:38

Forum Jump: