-
-
Notifications
You must be signed in to change notification settings - Fork 26
Examples to use LUA script for switch
You have two way to make LUA scripts.
- make a file called "script_device_That_You_Want.lua in "/home/pi/domoticz/scripts/lua"
- go to "Setting" / "More options" / "Event" / "LUA"
I m using scene, because you can easily set light value, color or temporisation.
Switch management in this plugin have something special, you can't use the native fonction in domoticz for them (activation devices), because this plugin trigger device event for useless information, like battery level. So instead of using trigger event, you need to use button detected
-- Some LUA exemples
commandArray = {}
-- Switch 1
if (devicechanged['deCONZ - Switch 1']) then
print("Switch 1")
local b = devicechanged['deCONZ - Switch 1']
if b == 'B1' then
if (otherdevices['deCONZ - Coridor']== 'On') then
commandArray['deCONZ - Cordidor'] = 'Off'
else
commandArray['Scene:Light Cordidor'] = 'On'
end
end
end
return commandArray
deCONZ - Switch 1 : switch name.
deCONZ - Coridor : Bulb name or group name.
Scene:Light Cordidor : scene to set light on with good setting.
To see wich one button to use (B1,B2,B3,...), just enable log "Debug info Only".
Another exemple to gradually dim your lights with 1 button press (with kepping the button pressed, long press). This exemple is not finished, it's just to show a method but remember you can too use phoson that have lot of options.
--Ikea remote
if (devicechanged['deCONZ - TRÅDFRI remote control'] == 'L +') then
a = otherdevices_svalues['deCONZ - chambre']
a = tonumber(a) + 5
commandArray['deCONZ - chambre'] = 'Set Level: '..a
end
-- bulb
if (devicechanged['deCONZ - chambre']) then
if (otherdevices['deCONZ - TRÅDFRI remote control'] == 'L +') then
a = otherdevices_svalues['deCONZ - chambre']
a = tonumber(a) + 5
commandArray['deCONZ - chambre'] = 'Set Level: '..a
end
end