I am trying to load a lua module but fails…all files uploaded
In “I_SensorMqtt1.xml” I have the following code but it fails at
u = require(“utility”)
Do you have any hints what’s wrong?
[code]<?xml version="1.0"?>
local p
local u
local m
function startup(lul_device)
luup.log("SensorMqtt plugin: loading library L_SensorMqtt ...")
if (package.path:find ("/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua", 1, true) == nil) then
package.path = package.path .. ";/etc/cmh-ludl/?.lua;/etc/cmh-lu/?.lua"
end
package.loaded.L_SensorMqtt = nil
p = require("L_SensorMqtt")
if (package.loaded.L_SensorMqtt == nil)
then
luup.log("SensorMqtt plugin: plugin is not installed correctly. Library L_SensorMqtt cannot be loaded.", 1)
luup.task("Plugin not correctly installed", 2, "SensorMqtt plugin", -1)
return false
end
luup.log("SensorMqtt plugin: library L_SensorMqtt loaded")
luup.log("SensorMqtt plugin: loading library utility ...")
package.loaded.utility = nil
u = require("utility")
if (package.loaded.utility == nil)
then
luup.log("SensorMqtt plugin: plugin is not installed correctly. Library utility cannot be loaded.", 1)
luup.task("utility not correctly installed", 2, "SensorMqtt plugin", -1)
return false
end
luup.log("SensorMqtt plugin: library utility loaded")
package.loaded.mqtt_library = nil
m = require("mqtt_library")
if (package.loaded.mqtt_library == nil)
then
luup.log("SensorMqtt plugin: plugin is not installed correctly. Library mqtt_library cannot be loaded.", 1)
luup.task("mqtt_library not correctly installed", 2, "SensorMqtt plugin", -1)
return false
end
luup.log("SensorMqtt plugin: library mqtt_library loaded")
return p.startup(lul_device)
end
</functions>
<startup>startup</startup>
[/code]