You can expose a plugin on Imperihome with ISS (http://www.imperihome.com/apidoc/systemapi/)
The handler, declared with “luup.register_handler”, can catch the URL generated by ISS, like :
http://ip/port_3480/data_request?id=lr_ISS=/devices
or
http://ip/port_3480/data_request?id=lr_ISS=/devices/{deviceId}/action/{actionName}/{actionParam}
yes, it’s a malformed URL… but it works.
the LUA code to catch the path :
function handleRequestISS (lul_request, lul_parameters, lul_outputformat)
local json = require("dkjson")
local path = lul_parameters["path"] or "/devices"
local result
-- System infos
if (path == "/system") then
result = {
id = "MyPlugin-" .. tostring(luup.pk_accesspoint),
apiversion = 1
}
-- Device list
elseif (path == "/devices") then
result = { devices = {} }
-- Put what you want to expose in "devices" (see ISS API)
-- Actions
elseif string.find(path, "^/devices/[^%/]+/action/[^%/]+") then
local deviceId, actionName, actionParam = string.match(path, "^/devices/([^%/]+)/action/([^%/]+)/*([^%/]*)$")
-- actionName depends of the type of the device declared
if (actionName == "something") then
-- Do something
result = {
success = true,
errormsg = ""
}
else
result = {
success = false,
errormsg = "problem"
}
end
elseif (path == "/rooms") then
result = {
rooms = {
{ id = "1", name = "Room 1" }
}
}
else
result = {
success = false,
errormsg = "Path '" .. tostring(path) .. "' is not handled"
}
end
return tostring(json.encode(result)), "application/json"
end
luup.register_handler("handleRequestISS", "ISS")