local p
function startup(lul_device)
luup.log("Arduino plugin: loading library L_Arduino ...")
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_Arduino = nil
p = require("L_Arduino")
if (package.loaded.L_Arduino == nil)
then
luup.log("Arduino plugin: plugin is not installed correctly. Library L_Arduino cannot be loaded.", 1)
luup.task("Plugin not correctly installed", 2, "Arduino plugin", -1)
return false
end
luup.log("Arduino plugin: library L_Arduino loaded")
return p.startup(lul_device)
end
if (p ~= nil) then p.processIncoming(lul_data) end
startup
urn:upnp-org:serviceId:SwitchPower1
SetTarget
if (p ~= nil) then p.switchPower(lul_device, lul_settings.newTargetValue) end
return 4,0
urn:micasaverde-com:serviceId:HaDevice1
ToggleState
local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", lul_device)
if(status=="0") then
p.switchPower(lul_device, 1)
return 4,0
else
p.switchPower(lul_device, 0)
return 4,0
end
urn:upnp-org:serviceId:Dimming1
SetLoadLevelTarget
if (p ~= nil) then
p.setDimmerLevel(lul_device, lul_settings.newLoadlevelTarget)
if(lul_settings.newLoadlevelTarget ~= "0")then
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",1,lul_device)
else
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",0,lul_device)
end
end
return 4,0
urn:micasaverde-com:serviceId:DoorLock1
SetTarget
if (p ~= nil) then p.setLockStatus(lul_device, lul_settings.newTargetValue) end
return 4,0
urn:upnp-org:serviceId:TemperatureSetpoint1
SetCurrentSetpoint
if (p ~= nil) then p.SetpointHeat(lul_device, lul_settings.NewCurrentSetpoint) end
return 4,0
urn:upnp-org:serviceId:TemperatureSetpoint1_Heat
SetCurrentSetpoint
if (p ~= nil) then p.SetpointHeat(lul_device, lul_settings.NewCurrentSetpoint) end
return 4,0
urn:upnp-org:serviceId:TemperatureSetpoint1_Cool
SetCurrentSetpoint
if (p ~= nil) then p.SetpointCool(lul_device, lul_settings.NewCurrentSetpoint) end
return 4,0
urn:upnp-org:serviceId:HVAC_UserOperatingMode1
SetModeTarget
if (p ~= nil) then p.SetOperatingMode(lul_device, lul_settings.NewModeTarget) end
return 4,0
urn:upnp-org:serviceId:HVAC_FanOperatingMode1
SetMode
if (p ~= nil) then p.SetFanMode(lul_device, lul_settings.NewMode) end
return 4,0
urn:upnp-org:serviceId:HVAC_UserOperatingMode1
SetEnergyModeTarget
if (p ~= nil) then p.SetEnergyMode(lul_device, lul_settings.NewModeTarget) end
return 4,0
urn:upnp-org:serviceId:WindowCovering1
Up
if (p ~= nil) then p.windowCovering(lul_device, "UP") end
return 4,0
urn:upnp-org:serviceId:WindowCovering1
Down
if (p ~= nil) then p.windowCovering(lul_device, "DOWN") end
return 4,0
urn:upnp-org:serviceId:WindowCovering1
Stop
if (p ~= nil) then p.windowCovering(lul_device, "STOP") end
return 4,0
urn:micasaverde-com:serviceId:SecuritySensor1
SetArmed
if (p ~= nil) then p.setArmed(lul_device, lul_settings.newArmedValue) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduino1
SendCommand
if (p ~= nil) then p.sendCommand(lul_settings.radioId, lul_settings.variableId, lul_settings.value) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduinonode1
SendNodeCommand
if (p ~= nil) then p.sendNodeCommand(lul_device, lul_settings.variableId, lul_settings.value) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduinonode1
ClearChildren
if (p ~= nil) then p.clearChildren(lul_device) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduino1
SetUnit
if (p ~= nil) then p.setUnit(lul_settings.unit) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduino1
StartInclusion
if (p ~= nil) then p.startInclusion(lul_device) end
return 4,0
urn:upnp-arduino-cc:serviceId:arduino1
StopInclusion
if (p ~= nil) then p.stopInclusion(lul_device) end
return 4,0
urn:schemas-arduino-cc:serviceId:ArduinoIr1
SendIrCode
if (p ~= nil) then p.sendIrCommand(lul_device, lul_settings.Index) end
return 4,0
urn:schemas-arduino-cc:serviceId:ArduinoIr1
RecordIrCode
luup.log("Record IR code #" .. lul_settings.Index .. " with name: " .. lul_settings.CodeName)
if (p ~= nil) then p.recordIrCode(lul_device, lul_settings.Index, lul_settings.CodeName) end
return 4,0
urn:upnp-org:serviceId:LcdText1
SetLcdText
if (p ~= nil) then p.SetLcdText(lul_device, lul_settings.NewLcdText) end
return 4,0