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


Messages In This Thread
RE: Meeting room with separation wall - by Trond Hoyem - 07.03.2017, 08:50

Forum Jump: