Finally solved my issue myself. Here it is and its working. Maybe not the best script but it work:
Code: Select all
local Version = '18.03.11'
local SwitchKayLearn = 90
local SwitchHall = 92
local SwitchDressoir = 100
local SwitchBalcony = 101
local SwitchKitchenSink = 102
local SwitchKitchen = 104
local SwitchWindows = 105
local SwitchWall = 106
local SwitchBedroom = 107
local SwitchBathroom = 109
local BulbWallRight = 12
local BulbWallLeft = 13
local BulbWindowsLeft = 14
local BulbWindowRight = 15
local BulbMasterBedroom = 22
local BulbDressoir = 23
local BulbBalcony = 24
local BulbHall = 25
local BulbBathroomSink = 28
local BulbShower = 29
local BulbKitchen = 30
local BulbKitchenSink = 31
local function RGB(domoticz,idx)
domoticz.devices(idx).setRGB(255,255,255)
status = 'aangezet'
end
local function Kelvin(domoticz,idx)
domoticz.devices(idx).dimTo(100)
domoticz.devices(idx).setKelvin(4000)
status = 'aangezet'
end
local function TurnOff(domoticz,idx)
domoticz.devices(idx).dimTo(5)
domoticz.devices(idx).switchOff().afterSec(1)
status = 'uitgezet'
end
return {
active = true,
on = {
devices = {'Switch*'},
},
logging = {marker = 'SWITCHES ' ..Version..'..............'},
execute = function(domoticz, device)
--
status = ''
if (device.idx == SwitchWindows and device.active) then -- WINDOWS SWITCH ON
RGB(domoticz,BulbWindowsLeft)
RGB(domoticz,BulbWindowRight)
elseif (device.idx == SwitchWindows and not device.active) then -- WINDOWS SWITCH OFF
TurnOff(domoticz,BulbWindowsLeft)
TurnOff(domoticz,BulbWindowRight)
elseif (device.idx == SwitchWall and device.active) then -- WALL SWITCH ON
RGB(domoticz,BulbWallLeft)
RGB(domoticz,BulbWallRight)
elseif (device.idx == SwitchWall and not device.active) then -- WALL SWITCH OFF
TurnOff(domoticz,BulbWallLeft)
TurnOff(domoticz,BulbWallRight)
elseif (device.idx == SwitchBedroom and device.active) then -- MASTERBEDROOM SWITCH ON
Kelvin(domoticz,BulbMasterBedroom)
elseif (device.idx == SwitchBedroom and not device.active) then -- MASTERBEDROOM SWITCH OFF
TurnOff(domoticz,BulbMasterBedroom)
elseif (device.idx == SwitchHall and device.active) then -- HALL SWITCH ON
RGB(domoticz,BulbHall)
elseif (device.idx == SwitchHall and not device.active) then -- HALL SWITCH OFF
TurnOff(domoticz,BulbHall)
elseif (device.idx == SwitchDressoir and device.active) then -- DRESSOIR SWITCH ON
Kelvin(domoticz,BulbDressoir)
elseif (device.idx == SwitchDressoir and not device.active) then -- DRESSOIR SWITCH OFF
TurnOff(domoticz,BulbDressoir)
elseif (device.idx == SwitchBathroom and device.active) then -- BATHROOM SWITCH ON
Kelvin(domoticz,BulbBathroomSink)
Kelvin(domoticz,BulbShower)
elseif (device.idx == SwitchBathroom and not device.active) then -- BATHROOM SWITCH OFF
TurnOff(domoticz,BulbBathroomSink)
TurnOff(domoticz,BulbShower)
elseif (device.idx == SwitchBalcony and device.active) then -- BALCONY SWITCH ON
Kelvin(domoticz,BulbBalcony)
elseif (device.idx == SwitchBalcony and not device.active) then -- BALCONY SWITCH OFF
TurnOff(domoticz,BulbBalcony)
elseif (device.idx == SwitchKitchenSink and device.active) then -- KITCHEN SINK SWITCH ON
Kelvin(domoticz,BulbKitchenSink)
elseif (device.idx == SwitchKitchenSink and not device.active) then -- KITCHEN SINK SWITCH OFF
TurnOff(domoticz,BulbKitchenSink)
elseif (device.idx == SwitchKitchen and device.active) then -- KITCHEN SWITCH ON
Kelvin(domoticz,BulbKitchen)
elseif (device.idx == SwitchKitchen and not device.active) then -- KITCHEN SWITCH OFF
TurnOff(domoticz,BulbKitchen)
elseif (device.idx == SwitchKayLearn and device.active) then -- KITCHEN SWITCH ON
status = 'aangezet'
elseif (device.idx == SwitchKayLearn and not device.active) then -- KITCHEN SWITCH OFF
status =' uitgezet'
end
domoticz.log('------------------------==<[ ' ..device.name.. ' is ' ..status..'. ]>==-----------------------------', domoticz.LOG_FORCE)
end
}