10.05.2023, 08:49
client:loop(1) will exit after 1 second, you need this to keep the loop running:
At the moment your code is very inefficient. Writing to any group address will cause the script to go through a big array checking each entry if it matches. Use group addresses as table keys to quickly check if it belongs to a certain group or not:
Use grp.getvalue() to get the initial object value and cache them into a table, then update the values that you get from the event. For binary values change the event value decoding and all other checks to use true/false instead of numbers:
Code:
while true do
client:loop(1)
end
At the moment your code is very inefficient. Writing to any group address will cause the script to go through a big array checking each entry if it matches. Use group addresses as table keys to quickly check if it belongs to a certain group or not:
Code:
local group_ids = {}
-- fill group address -> group id mapping table on init
...
local address = event.dst
local group_id = group_ids[ address ]
if group_id then
-- perform some actions here
end
Use grp.getvalue() to get the initial object value and cache them into a table, then update the values that you get from the event. For binary values change the event value decoding and all other checks to use true/false instead of numbers:
Code:
local value = tonumber(event.datahex, 16) ~= 0 -- 0 is false, all other values are true