I'm trying to write a script to dim my light using an aqara opple switch.
Code: Select all
return {
on = {
devices = {
'Arbeitszimmer Flur',
'Arbeitszimmer Wohnzimmer'
}
},
execute = function(domoticz, device)
local Wand = domoticz.devices('Arbeitszimmer - Wandbeleuchtung')
local Decke = domoticz.devices('Arbeitszimmer - Decke')
local dimLevelWand = 1
local dimLevelDecke = 0
domoticz.log('Device ' .. device.name .. ' was changed. State: ' .. Wand.state, domoticz.LOG_INFO)
if device.state == "B1" then
Wand.toggleSwitch()
end
if device.state == "B3" then
if Decke.state == 'Off' then
Decke.setState('On')
else
Decke.setState('Off')
end
end
if device.state == "B1L" then
repeat
dimLevelWand = dimLevelWand + 0.01
--domoticz.log('Set ' .. Wand.name .. ' to dimLevel '.. dimLevelWand, domoticz.LOG_INFO)
Wand.dimTo(dimLevelWand)
until dimLevelWand >= 100
elseif device.state == "B1RL" then
end
if device.state == "B2L" then
repeat
dimLevelWand = dimLevelWand - 0.01
--domoticz.log('Set ' .. Wand.name .. ' to dimLevel '.. dimLevelWand .. '%, after ' .. delay .. ' seconds', domoticz.LOG_INFO)
Wand.dimTo(dimLevelWand)
until dimLevelWand <= 0
elseif device.state == "B2RL" then
end
end
}Any help would be appreciated!