09.01.2026, 12:02
I'm using resident functions because for some reason the event-based functions aren't responding well to those events; the final code I used looks like this:
-- Leer valores KNX
local puerta = grp.getvalue('1/0/14') -- 0 = abierta, 1 = cerrada
local presencia = grp.getvalue('1/0/13') -- 0 = no hay nadie, 1 = presencia
local estado = grp.getvalue('32/1/1') -- 0..3
local alarma =grp.getvalue('32/3/12')
log (estado)
log(puerta)
log(presencia)
log(alarma)
-- DETECCIÓN DE OCUPACIÓN INDEBIDA
if estado == 0 then -- Si no está alquilada la vivienda -- -- Y --
if puerta == false or presencia == true then -- Si la puerta esta abierta O el sensor de presencia detecta presencia --
grp.write('32/1/1', 3) -- Se activa el sistema antiocupación --
alert('Alerta, Vivienda 1ºB OCUPADA')
grp.write('32/3/12', true)
end
end
-- PROBLEMA RESUELTO → VOLVER A NO ALQUILADA
if estado == 3 then
if puerta == true and presencia == false then
grp.write('32/1/1', 0)
grp.write('32/3/12', false)
end
end
I was writing the event-based scripts in the same addresses, in this case, on 32/3/12, and the scripts are not running automatically.
-- Leer valores KNX
local puerta = grp.getvalue('1/0/14') -- 0 = abierta, 1 = cerrada
local presencia = grp.getvalue('1/0/13') -- 0 = no hay nadie, 1 = presencia
local estado = grp.getvalue('32/1/1') -- 0..3
local alarma =grp.getvalue('32/3/12')
log (estado)
log(puerta)
log(presencia)
log(alarma)
-- DETECCIÓN DE OCUPACIÓN INDEBIDA
if estado == 0 then -- Si no está alquilada la vivienda -- -- Y --
if puerta == false or presencia == true then -- Si la puerta esta abierta O el sensor de presencia detecta presencia --
grp.write('32/1/1', 3) -- Se activa el sistema antiocupación --
alert('Alerta, Vivienda 1ºB OCUPADA')
grp.write('32/3/12', true)
end
end
-- PROBLEMA RESUELTO → VOLVER A NO ALQUILADA
if estado == 3 then
if puerta == true and presencia == false then
grp.write('32/1/1', 0)
grp.write('32/3/12', false)
end
end
I was writing the event-based scripts in the same addresses, in this case, on 32/3/12, and the scripts are not running automatically.