![]() |
|
Conference room with 2 partition walls - Printable Version +- LogicMachine 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: Conference room with 2 partition walls (/showthread.php?tid=3362) |
Conference room with 2 partition walls - AndersH - 11.05.2021 I have a conference room with 2 separation walls, one wall someone solved in the forum here but 2 walls ? I took this from the FB Editor in my Wiser for KNX: require('custom.fbeditor20.Control') Switch_room_1 = grp.getvalue('32/1/1') Switch_room_2 = grp.getvalue('32/1/2') Switch_room_3 = grp.getvalue('32/1/3') Partition_wall_1 = grp.getvalue('32/1/7') Partition_wall_2 = grp.getvalue('32/1/8') room1, room2, room3 = fbe_partition_wall_control(Switch_room_1, Switch_room_2, Switch_room_3, Partition_wall_1, Partition_wall_2, 'fb__Test_Vikv__gg__fbe_partition_wall_control__id') if room1 ~= nil then grp.write('32/1/4', room1) end if room2 ~= nil then grp.write('32/1/5', room2) end if room3 ~= nil then grp.write('32/1/6', room3) end It looks like it´s working with 1bit protocol, but how can it be changed to work with 4bit dim or 1byte protocol, and if i simulate that both walls are open it seems that if i use switch 1 for on, i can´t use switch 2 or 3 for off... How could i make this work ? //A RE: Conference room with 2 partition walls - admin - 11.05.2021 There used to be a universal script but I can't find it. Here's a working solution for any data type. Tag all input objects with the same tag and add an event script to it. Change group addresses as needed. You might need to remove two "not" statements before grp.getvalue depending on how open/closed status works. Right now it assumed that true means that the wall is closed. Code: inputs = { '32/1/1', '32/1/2', '32/1/3' }
status = { '32/1/7', '32/1/8' }
outputs = { '32/1/4', '32/1/5', '32/1/6' }
for i, addr in ipairs(inputs) do
if addr == event.dst then
index = i
end
end
value = event.getvalue()
writes = {}
writes[ index ] = true
open12 = not grp.getvalue(status[ 1 ])
open23 = not grp.getvalue(status[ 2 ])
if index == 1 then
if open12 then
writes[ 2 ] = true
writes[ 3 ] = open23
end
elseif index == 2 then
writes[ 1 ] = open12
writes[ 3 ] = open23
elseif index == 3 then
if open23 then
writes[ 2 ] = true
writes[ 1 ] = open12
end
end
for i, addr in ipairs(outputs) do
if writes[ i ] then
grp.write(addr, value)
end
endRE: Conference room with 2 partition walls - AndersH - 11.05.2021 Works Very Well.... ![]() Thank You very much for the help...
RE: Conference room with 2 partition walls - mitja.perko - 04.04.2022 Hello, how could one adapt this code to work with 5 partitions? Greetings Mitja RE: Conference room with 2 partition walls - admin - 05.04.2022 Here's a universal solution that should work for any number of partition walls. Modify group addresses in the inputs, sensors and outputs tables as needed. All input objects should have a common tag to which this event script is attached. Code: inputs = {
'33/1/1',
'33/1/2',
'33/1/3',
'33/1/4',
'33/1/5',
}
sensors = {
'33/2/1',
'33/2/2',
'33/2/3',
'33/2/4',
}
outputs = {
'33/3/1',
'33/3/2',
'33/3/3',
'33/3/4',
'33/3/5',
}
value = event.getvalue()
for i, addr in ipairs(inputs) do
if addr == event.dst then
index = i
end
end
grp.write(outputs[ index ], value)
for i = index, #sensors do
if grp.getvalue(sensors[ i ]) then
break
end
grp.write(outputs[ i + 1 ], value)
end
for i = index - 1, 1, -1 do
if grp.getvalue(sensors[ i ]) then
break
end
grp.write(outputs[ i ], value)
end |