I would like to use a venetian blinds dummy switch to control my blinds.
What I would like to do is when is pressed Open or Close (On or Off), to let this command execute for x seconds and then go in a Stop status. And if the Stop command is pressed, to stop it immediately.
I've done such a simple script, but I don't think is the best.
Code: Select all
commandArray = {}
if (devicechanged['PersBasSalMain'] == 'On') then
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,zz,1"')
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,ww,0"')
commandArray['PersBasSalMain'] = "Stop AFTER 10"
elseif (devicechanged['PersBasSalMain'] == 'Off') then
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,ww,1"')
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,zz,0"')
commandArray['PersBasSalMain'] = "Stop AFTER 10"
elseif (devicechanged['PersBasSalMain'] == 'Stop') then
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,ww,1"')
os.execute('curl "http://192.168.xx.yy/control?cmd=GPIO,zz,1"')
end
return commandArray
Example:
I press On, then press Stop after 2 secs, then press Off. The Off command should go in a Stop status after 10 secs, but it's like it gets the timer from the previous On and it stops after few secs.
Is there a better way to do it?
Thanks