Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions luup files/L_RGBController1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,104 @@ RGBDeviceTypes["RGBWdimmers"] = {
end
}

-- MySensor RGB(W)
RGBDeviceTypes["MYS-RGBW"] = {
getParameters = function (lul_device)
return {
name = "MySensors RGBW",
settings = {
{ variable = "ArduinoId", name = "Arduino plugin Id", type = "string" },
{ variable = "RadioId", name = "RGB Node altid", type = "string" }
}
}
end,

getColorChannelNames = function (lul_device)
return {"red", "green", "blue", "warmWhite"}
end,

getAnimationProgramNames = function()
return {
"Rainbow slow",
"Rainbow medium",
"Rainbow fast",
"Random slow colors",
"Random medium colors",
"Random fast colors",
"RGB fade slow colors",
"RGB fade medium colors",
"RGB fade fast colors",
"Multicolor fade slow colors",
"Multicolor fade medium colors",
"Multicolor fade fast colors",
"Current color flash slow colors",
"Current color flash medium colors",
"Current color flash fast colors",
}
end,

init = function (lul_device)
debug("MYS-RGBW.init", "Init for device #" .. tostring(lul_device))
pluginParams.rgbArduinoId = tonumber(getVariableOrInit(lul_device, SID.RGB_CONTROLLER, "ArduinoId", ""))
pluginParams.rgbRadioId = getVariableOrInit(lul_device, SID.RGB_CONTROLLER, "RadioId", "")
return true
end,

setStatus = function (lul_device, newTargetValue)
debug("MYS.setStatus", "Set status '" .. tostring(newTargetValue) .. "' for device #" .. tostring(lul_device))
if (tostring(newTargetValue) == "1") then
debug("MYS.setStatus", "Switches on ")
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "LIGHT", value = "1", radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)
luup.variable_set(SID.SWITCH, "Status", "1", lul_device)
else
debug("MYS.setStatus", "Switches off")
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "LIGHT", value = "0", radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)
luup.variable_set(SID.SWITCH, "Status", "0", lul_device)
end

end,

setColor = function (lul_device, color)
colorString = tostring(color)
debug("MYS.setColor", "Set RGBW color #" .. colorString .. " for device #" .. tostring(lul_device))
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "RGBW", value = colorString, radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)
end,

startAnimationProgram = function (lul_device, programId, programName)
if ((programName ~= nil) and (programName ~= "")) then
--debug("MYS.startAnimationProgram", "Start animation program '" .. programName .. "'")
mode = 0
if string.match(programName, "Random") then
mode = 0x01
end
if string.match(programName, "RGB fade") then
mode = 0x02
end
if string.match(programName, "Multicolor fade") then
mode = 0x03
end
if string.match(programName, "Current color flash") then
mode = 0x04
end
if string.match(programName, "slow") then
mode = 0x10 + mode
end
if string.match(programName, "medium") then
mode = 0x20 + mode
end
if string.match(programName, "fast") then
mode = 0x30 + mode
end
debug("MYS.startAnimationProgram", "Start animation program '" .. programName .. "' " .. tostring(mode))
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "VAR_1", value = tostring(mode), radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)
else
debug("MYS.startAnimationProgram", "Stop animation program")
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {variableId = "VAR_1", value = "00", radioId = pluginParams.rgbRadioId}, pluginParams.rgbArduinoId)
setColorTarget(lul_device, "")
end
end
}

-------------------------------------------
-- Color transition management
-------------------------------------------
Expand Down