Meeting room with separation wall - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Meeting room with separation wall (/showthread.php?tid=658) |
Meeting room with separation wall - Trond Hoyem - 07.03.2017 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 RE: Meeting room with separation wall - buuuudzik - 07.03.2017 You should prepare this in such way: - event-based script for every pushbutton with such script: Code: value = event.getvalue() RE: Meeting room with separation wall - Trond Hoyem - 07.03.2017 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? RE: Meeting room with separation wall - admin - 07.03.2017 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. RE: Meeting room with separation wall - Thomas - 07.03.2017 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. RE: Meeting room with separation wall - Trond Hoyem - 15.03.2017 (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 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. RE: Meeting room with separation wall - Trond Hoyem - 21.03.2017 (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------------------------------------------------------------- |