You need to create a group objects that controls your door lock (the group name is 'open' in this example), then add the id (the variable open_lock is for this purposes), then each time you will scan the device it will opens the door. In the same style you can add more different id for different group objects. (After changes do not forget to disable/enable the resident script)
Code:
require('ow')
function findDifferences(list, prev_list)
local new_ids = {}
local removed_ids = {}
-- Check for new IDs
if list then
for id, _ in pairs(list) do
if not prev_list or not prev_list[id] then
table.insert(new_ids, id)
end
end
end
-- Check for removed IDs
if prev_list then
for id, _ in pairs(prev_list) do
if not list[id] then
table.insert(removed_ids, id)
end
end
end
return new_ids, removed_ids
end
local temperat_sens = "28.DBCA83050000"
local open_lock = "01.CE6371690000" -- your id to open door lock
list = ow.list()
local new_ids, removed_ids = findDifferences(list, prev_list)
if #new_ids > 0 then
log("New IDs:")
for _, id in ipairs(new_ids) do
log(id, list[id])
if list[id] == temperat_sens then
grp.write('temperat', true)
elseif list[id] == open_lock then
grp.write('open', true) -- your object that controls door lock
end
end
end
if #removed_ids > 0 then
log("Removed IDs:")
for _, id in ipairs(removed_ids) do
log(id, prev_list[id])
end
end
prev_list = list