Hii sir ,
I have created resident script in which when a light ON in particular area it sends command to another object which tells me that a light is ON in this area the problem is that when i Active this script then logic machine become a slow or hang.and script sleep interval time is 0 second.
Can you suggest me solution for this query.
here is script --
-- Define the function that will run every 5 seconds
function checkValues()
-- Get the values from the grp (assuming grp.getvalue() returns the values for these keys)
value = grp.getvalue('0/6/2')
value2 = grp.getvalue('0/6/10')
value3 = grp.getvalue('0/5/6')
value4 = grp.getvalue('0/6/8')
value5 = grp.getvalue('2/5/22') -- value5 is checked for >= 1
value18 = grp.getvalue('2/5/27') -- value18 is checked for >= 1
value19 = grp.getvalue('0/6/44') -- value19 is checked for >= 1
value20 = grp.getvalue('0/6/25') -- value20 is checked for >= 1
value21 = grp.getvalue('0/6/58') -- value21 is checked for >= 1
value22 = grp.getvalue('0/6/30') -- value22 is checked for >= 1
-- Adjust the conditions for clarity (use parentheses to ensure proper evaluation order)
if (value or value2 or value3 or value4 or value5 >= 1 or
value18 >= 1 or value19 >= 1 or value20 >= 1 or
value21 >= 1 or value22 >= 1) then
grp.write('0/6/65', true) -- Write true if any condition is met
else
grp.write('0/6/65', false) -- Write false otherwise
end
end
-- Set the script to run every 5 seconds
while true do
checkValues() -- Call the function to check values
os.execute("sleep 5") -- Sleep for 5 seconds before checking again
end
I have created resident script in which when a light ON in particular area it sends command to another object which tells me that a light is ON in this area the problem is that when i Active this script then logic machine become a slow or hang.and script sleep interval time is 0 second.
Can you suggest me solution for this query.
here is script --
-- Define the function that will run every 5 seconds
function checkValues()
-- Get the values from the grp (assuming grp.getvalue() returns the values for these keys)
value = grp.getvalue('0/6/2')
value2 = grp.getvalue('0/6/10')
value3 = grp.getvalue('0/5/6')
value4 = grp.getvalue('0/6/8')
value5 = grp.getvalue('2/5/22') -- value5 is checked for >= 1
value18 = grp.getvalue('2/5/27') -- value18 is checked for >= 1
value19 = grp.getvalue('0/6/44') -- value19 is checked for >= 1
value20 = grp.getvalue('0/6/25') -- value20 is checked for >= 1
value21 = grp.getvalue('0/6/58') -- value21 is checked for >= 1
value22 = grp.getvalue('0/6/30') -- value22 is checked for >= 1
-- Adjust the conditions for clarity (use parentheses to ensure proper evaluation order)
if (value or value2 or value3 or value4 or value5 >= 1 or
value18 >= 1 or value19 >= 1 or value20 >= 1 or
value21 >= 1 or value22 >= 1) then
grp.write('0/6/65', true) -- Write true if any condition is met
else
grp.write('0/6/65', false) -- Write false otherwise
end
end
-- Set the script to run every 5 seconds
while true do
checkValues() -- Call the function to check values
os.execute("sleep 5") -- Sleep for 5 seconds before checking again
end