I have acquired new shades and got them delivered with standard motors, one up and one down.
I have interfaced them with two standard 2-way NO/NC relays which work fine. (like Sonoff 4ch-Pro)
I have used Zigbee push-buttons configured as selectors : single push= open or close (toggle) ; double push= stop where it is.
I would like to insert a short pause of e.g. 200 ms on a single push in order to avoid brutal direction changes.
E.g. stop, sleep 200 ms, change direction, start
Devices:
98 is my selector push-button
74 is the relay that brings power or not
75 is the relay that drives one motor or the other one, so that they are never both powered-on at the same time.
Here is the script that does not work:
Code: Select all
function sleep(n)
os.execute("sleep " .. tonumber(n/10))
end
return {
on = { devices = { 98 }}, -- idx of button
execute = function(dz, item )
dz.log("state of " .. item.name .. " is " .. item.state)
if item.state == "1 Click" then
dz.devices(74).switchOff() -- idx of power switch
sleep(5)
dz.devices(75).toggleSwitch() -- idx of up/down switch
dz.devices(74).switchOn() -- idx of power switch
elseif item.state == "2 Click" then
dz.devices(74).switchOff() -- idx of power switch
end
end
}
What am I doing wrong ?
Thank you for your replies

Frédéric