I have a square IKEA Tradfri dimmer, which, when added to Domoticz is added as Selector switch with 5 options: 1 On, 2 Off, 3 Up, 4 Down, 5 Stop.
In Zigbee2MQTT I see the actions:
1. On: press the 1
2. Off: press the 0
3. Up: Hold the 1
4. Down: Hold the 0
5. Stop: State if the dimmer when you release 1 or 0 after holding it.
Then I have a different dimmer lightswitch Dimmer that I want to control with the IKEA dimmer.
On and Off is not a problem, that works:
Code: Select all
return {
on = {
devices = {
1257,
}
},
execute = function(domoticz, dimmer)
local dimmer = domoticz.devices(1257)
local lightswitch = domoticz.devices(1268)
if (dimmer.state == 'On') then
lightswitch.switchOn()
elseif (dimmer.state == 'Off') then
lightswitch.switchOff()
elseif (dimmer.state == 'Up') then
elseif (dimmer.state == 'Down') then
else
domoticz.log(lightswitch.state)
end
end
}
But I cant figure out what to add.
I was thinking to do this, but it errors. The idea was that when you release the dimmer, it will initiate the script again and go into state == Stop
Code: Select all
lightswitch.dimTo(40)
lightswitch.dimTo(60).aftersec(2)
lightswitch.dimTo(80).aftersec(4)
lightswitch.ldimTo(100).aftersec(6)
Code: Select all
Error: dzVents: Error: (3.0.2) .../scripts/dzVents/generated_scripts/Dinnertabledimmer.lua:18: attempt to call a nil value (field 'aftersec')
Anyone an idea how to use a timer for dimmer and up it step by step by holding the button longer?