I came to the conclusion that 99% of the code is identical apart from the parameters, so I've attempted to optimise the duplication away. What I'm trying to do is make the top level device event script a single call to a helper function, that returns the entire event block. I've tried both this:
Code: Select all
return {
domoticz.helpers.motionDetectedsFunction(domoticz, 9, 22, 120, "Kitchen")
}
Code: Select all
return domoticz.helpers.motionDetectedFunction(domoticz, 9, 22, 120, "Kitchen")
Code: Select all
...icz/scripts/dzVents/generated_scripts/Kitchen Motion.lua:4: attempt to index field 'helpers' (a nil value).
The shared code looks something like this, but the error above appears to indicate that it fails long before my shared code is called.
Code: Select all
motionDetectedFunction = function(domoticz, dayStartHour, dayEndHour, duration, sceneRoot)
return {
on = {
devices = {
sceneRoot .. ' Motion'
}
},
execute = function(domoticz, item)
domoticz.helpers.motionActionFunction(domoticz, dayStartHour, dayEndHour, duration, sceneRoot)
end
}
end,
Any pointers to what I'm doing wrong, or if its even possible?