Changing Dimmer level with Selector switch
Posted: Monday 25 May 2020 17:38
Hi all,
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:
What I want is when I hold the button it puts the dimmer up with lets say 20% and if you hold if for more than 2 sec, another 20%. When you release it, it goes to Stop and it should keep the current state (for now I added just as log in there.)
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
error message:
The above was actually not the goal. The goal is to find the current/last level and add a percentage to it and repeat that after a few seconds, but I got lost in trying to find out how.
Anyone an idea how to use a timer for dimmer and up it step by step by holding the button longer?
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?