Can this be simplified?
Posted: Tuesday 28 August 2018 20:51
I have the following script I'm hoping to simplify. I'm defining a table of devices at the start.. then using a standard dzvents device script. Is there any way to not have to repeat the devices in the device section of the script (so to read them from devicesToCheck object).
Thanks.
Thanks.
Code: Select all
local devicesToCheck = {
{ ['name'] = 'Conservatory Motion Sensor', ['true_prob'] = 0.7,['false_prob'] = 0.7 },
{ ['name'] = 'Kitchen Motion Sensor', ['true_prob'] = 0.7,['false_prob'] = 0.7 },
{ ['name'] = 'Bedroom Motion Sensor', ['true_prob'] = 0.7,['false_prob'] = 0.7 },
{ ['name'] = 'Living Room Motion Sensor (Main)', ['true_prob'] = 0.7,['false_prob'] = 0.7 }
}
local prior = 0.5
return {
on = {
devices = {
'Conservatory Motion Sensor',
'Kitchen Motion Sensor',
'Bedroom Motion Sensor',
'Living Room Motion Sensor (Main)'
}
},
execute = function(domoticz, device)
print('stuff here')
end
}