Page 1 of 1

Venetian Blinds script

Posted: Sunday 10 April 2016 15:11
by woody4165
Hi all

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
It seems that the timer (Stop AFTER 10) remain active also if I press the manual stop.
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

Re: Venetian Blinds script

Posted: Monday 11 April 2016 21:12
by georgesattali
Hello,
yes I think that "Stop AFTER 10" have got priority on manual stop.
I think you have to add a virtual device "PersBasSalMainStop10" and a "device" script for it.

The instruction commandArray['PersBasSalMain'] = "Stop AFTER 10" becomes commandArray['PersBasSalMainStop10'] = "Stop AFTER 10"
and a new "device" script : when commandArray['PersBasSalMainStop10'] becomes off, turn off your GPIOs.

In that way PersBasSalMain can be stopped any time and should act on yours blinds, whereas after 10s, virtual PersBasSalMainStop10 will also put them down.

I don't know the syntax you use with curl ; "...control?cmd=GPIO...", is that correct ?

Bye, GD

Re: Venetian Blinds script

Posted: Tuesday 07 June 2016 11:03
by pollefinario
What are you using for controlling the blinds? Servo? Stepper motor?