12.01.2024, 11:10
Hi guys,
I have been testing our colleague's solution (https://forum.logicmachine.net/showthrea...ount+pulse) to be able to turn on two different lights with the same button using a single pulse or double pulse, but I can't get it to work properly (and I don't know if there is something I haven't understood well)
I have created a resident script (sleep interval 0), where the address 16/1/1 is the press that I make on the button, the addresses 1/1/10 and 1/1/120 are the lights and the address 16/1/2 is an address that I have created to perform the count
:
And also at address 16/1/2 I have created the following event script:
The problem is that I can't get it to turn on the corresponding lights by giving it a single pulse or two, but nevertheless there are times when I do a short press, it interprets that I have done a long press and turns off the lights or when I try to do a double press , it interprets that I have done one or that I have done a long press (that is, it does different things each time). I can't find what the problem is.
I hope you can help me. Thank you so much
I have been testing our colleague's solution (https://forum.logicmachine.net/showthrea...ount+pulse) to be able to turn on two different lights with the same button using a single pulse or double pulse, but I can't get it to work properly (and I don't know if there is something I haven't understood well)
I have created a resident script (sleep interval 0), where the address 16/1/1 is the press that I make on the button, the addresses 1/1/10 and 1/1/120 are the lights and the address 16/1/2 is an address that I have created to perform the count
:
Code:
if not client then
require('genohm-scada.eibdgm')
-- knx group write handler
function groupwrite(event)
local value
value = knxdatatype.decode(event.datahex, dt.bool)
--first room
if event.dst == "16/1/1" then
switcher("16_1_1", "1/1/10", "1/1/120", "16/1/2", value)
end
end
client = eibdgm:new()
client:sethandler('groupwrite', groupwrite)
function switcher(event_adress, light1, light2, counter_object, value)
nowTIME = os.time()
counter = grp.getvalue(counter_object)
state = value
if (state == false) then
counter = counter + 1
log(counter)
lastONtime = storage.get('lastONtime' .. event_adress)
if (nowTIME - lastONtime > 1) then
log('long press ' .. event_adress)
grp.write(light1, false)
grp.write(light2, false)
grp.update(counter_object, 0)
else
grp.update(counter_object, counter)
end
else
storage.set('lastONtime' .. event_adress, nowTIME)
end
end
end
client:step()
Code:
value = tonumber(event.datahex, 16)
if value > 0 then
light1 = '1/1/10'
light2 = '1/1/120'
switcher_adress = '16/1/1'
os.sleep(1)
value = event.getvalue()
if value == 1 then
log('single press '.. switcher_adress)
grp.write(light1, not(grp.getvalue(light1)))
elseif value == 2 then
log('double ' .. switcher_adress)
grp.write(light2, not(grp.getvalue(light2)))
end
-- reset counter
if value > 0 then
grp.update(event.dst, 0)
end
end
I hope you can help me. Thank you so much