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
}
I'm having trouble as the script is running too fast and I don't get that slow fade to be able to stop at the desired new level. Usually it's going form 0 to 100 and the same backwards instantly. Is there a way to slow down the script? like a delay() or sleep() without the bad behaviour of sleep or delay?
schwuppdiwupp wrote: ↑Wednesday 02 September 2020 19:23
Hi!
I'm trying to write a script to dim my light using an aqara opple switch.
I'm having trouble as the script is running too fast and I don't get that slow fade to be able to stop at the desired new level. Usually it's going form 0 to 100 and the same backwards instantly. Is there a way to slow down the script? like a delay() or sleep() without the bad behaviour of sleep or delay?
return {
on = {
devices = {
'Arbeitszimmer Flur',
'Arbeitszimmer Wohnzimmer'
}
},
execute = function(domoticz, device)
local Wand = domoticz.devices('Arbeitszimmer - Wandbeleuchtung')
local Decke = domoticz.devices('Arbeitszimmer - Decke')
domoticz.log('Device ' .. device.name .. ' was changed. State: ' .. Wand.level, domoticz.LOG_INFO)
Wand.cancelQueuedCommands()
if device.levelName == "B1" then
Wand.toggleSwitch()
elseif device.levelName == "B3" then
if Decke.state == 'Off' then
Decke.setState('On')
else
Decke.setState('Off')
end
elseif device.levelName == "B1L" then
for dimLevel = 1, 100 do
Wand.dimTo(dimLevel).afterSec(dimLevel / 10)
end
elseif device.levelName == "B2L" then
for dimLevel = 1, 100 do
Wand.dimTo(100 - dimLevel).afterSec(dimLevel/ 10)
end
end
end
}
return {
on = {
devices = {
'Arbeitszimmer Flur',
'Arbeitszimmer Wohnzimmer'
}
},
data = {
lastColor = { initial = 0 }
},
execute = function(domoticz, device)
local Wand = domoticz.devices('Arbeitszimmer - Wandbeleuchtung')
local Decke = domoticz.devices('Arbeitszimmer - Decke')
colors = { 2700, 3500, 5000, 6000, 7000 }
domoticz.log('Device ' .. device.name .. ' was changed. State: ' .. Wand.level, domoticz.LOG_INFO)
Wand.cancelQueuedCommands()
if device.levelName == "B1" then
Wand.toggleSwitch()
elseif device.levelName == "B3" then
if Decke.state == 'Off' then
Decke.setState('On')
else
Decke.setState('Off')
end
elseif device.levelName == "B1L" then
for dimLevel = Wand.level, 100 do
Wand.dimTo(dimLevel).afterSec(dimLevel / 20)
end
elseif device.levelName == "B2L" then
for dimLevel = 1, (Wand.level-1) do
Wand.dimTo(Wand.level - dimLevel).afterSec(dimLevel / 20)
end
elseif device.levelName == "B1D" then
--TODO setKelvin
Wand.setKelvin(colors[domoticz.data.lastColor + 1])
domoticz.data.lastColor = domoticz.data.lastColor + 1
elseif device.levelName == "B2D" then
--TODO setKelvin
if domoticz.data.lastColor - 1 < 0 then
domoticz.data.lastColor = 4
end
Wand.setKelvin(colors[domoticz.data.lastColor - 1])
domoticz.data.lastColor = domoticz.data.lastColor - 1
end
end
}
I'm still strugglin with adjusting my white balance. setKelvin doesn't change anything. guess I'll have to go with setColorBrightness.
Is there a way to get the color the light is set to atm?
schwuppdiwupp wrote: ↑Thursday 03 September 2020 12:52
I'm still struggling with adjusting my white balance. setKelvin doesn't change anything. guess I'll have to go with setColorBrightness.
Is there a way to get the color the light is set to atm?
Wand.setColor(,,,,,,2,255)
Wand.setColor(2,255)
and some other variations
What's the correct way to set temperature?
Thanks for your help
If the devicesubtype is RGBWW you can use the setKelvin method (levels 0..100) but because setKelvin is not a standard command, internally it use a JSON API call. Therefore the cancelQueuedCommand() will not work.