Definitely a scope problem, as @akbooer has said. You need to expose the module function (
myplugin_init) into the global scope. You also need to similarly expose any callback functions used in
call_timer and similar calls.
Another approach is something like this:
function myplugin_init( dev )
myPlugin = require "MyPlugin1"
gTimerCallback = myPlugin.timerCallback
return myPlugin.myplugin_init( dev )
A couple of things to note: first, I’m not using colon
: as a qualifier for the functions here, I’m using dot. Colon is for objects, and loaded modules are just tables, not objects. Second, I’m making a global called
gTimerCallback that is a reference to the module’s function of the same name, which allows me to
luup.call_delay( "gTimerCallback", 5 ). Personally I don’t normally use Hungarian notation, but I did it here to make it more clear what’s going on. Finally, don’t forget that your module startup function can return boolean success (it actually can return three values – see the docs).
You should also be aware that if you put your module file in <files>, Luup will run it, not as a module, it will just load it and compile it. But the way you are using it (as a module using
require), that’s no benefit, it just makes busy work. I would just remove the <files> tag entirely.