-- Переменные ID Устройств
local t = os.date('*t')
local SwStep1 = 179 -- ID Виртуального Выключателя 1
local SwStep2 = 178 -- ID Виртуального Выключателя 2
local SwStep3 = 163 -- ID Виртуального Выключателя 2
local SwRGB = 58 -- ID Виртуального Выключателя
local R = 114 -- красный, RGB
local G = 115 -- зеленый, RGB
local B = 116 -- синий, RGB
-- Переменные сервисных идентификаторов
local SidSPow = "urn:upnp-org:serviceId:SwitchPower1" -- Сервисный ID Выключателя
local SidVSPow = "urn:upnp-org:serviceId:VSwitch1" -- Сервисный ID Виртуального Выключателя
-- Перемененные статусов устройств
local StatSwStep1 = luup.variable_get( SidVSPow, "Status", SwStep1)
local StatSwStep2 = luup.variable_get( SidVSPow, "Status", SwStep2)
local StatSwStep3 = luup.variable_get( SidVSPow, "Status", SwStep3)
local StatSwRGB = luup.variable_get( SidSPow, "Status", SwRGB)
if (StatSwStep1 == "0") and (StatSwStep2 == "0") and (StatSwStep3 == "0") or (StatSwRGB == "0") then
luup.call_action (SidSPow, "SetTarget", {["newTargetValue"] = 1}, SwRGB)
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 1}, SwStep1)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "40"}, R)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, G)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"},
else
if (StatSwStep1 == "1") and (StatSwStep2 == "0") and (StatSwStep3 == "0") and (StatSwRGB == "1") then
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 1}, SwStep2)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, R)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "40"}, G)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"},
else
if (StatSwStep1 == "1") and (StatSwStep2 == "1") and (StatSwStep3 == "0") and (StatSwRGB == "1") then
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 1}, SwStep3)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, R)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, G)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "40"},
else
if (StatSwStep1 == "1") and (StatSwStep2 == "1") and (StatSwStep3 == "1") and (StatSwRGB == "1") then
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 0}, SwStep1)
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 0}, SwStep2)
luup.call_action (SidVSPow, "SetTarget", {["newTargetValue"] = 0}, SwStep3)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "20"}, R)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "20"}, G)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "20"},
end
end
end
end