Page 1 of 1
How to stop an action
Posted: Wednesday 31 May 2017 19:36
by lupo2a
I have 9 roller shutter controls with timers associated.
I set up a lua script(device) where I want to stop the action coming from the timer of the device. (I.e. if the timer opens the shutter at 70:00 but some variables.are true or it's Holliday the action should not be done). I can do that setting up the timer on a virtual switch and than drive the roller.shutter according to the different test.
This works but this approach requires a lot of virtual switches. Is there the option within the lua script to "stop" the action? And within the script (lua of type device) is it possible to test if the device has changed because the user clicked on the switch or if it is the timer associated with the switch that initiated the event?
Inviato dal mio PLK-L01 utilizzando Tapatalk
Re: How to stop an action
Posted: Wednesday 31 May 2017 20:29
by lawcorn
I've got the same kind of setup...
I've done a scene "open - morning" for my roller shutter and a plannification at 7:00 for it.
Then with a virtual switch, I turn the scene "active" or "inactive" (which disable the planning !)
For your second question, set and test a user variable in your script

Re: How to stop an action
Posted: Tuesday 13 June 2017 12:50
by zicht
lupo2a wrote:I have 9 roller shutter controls with timers associated.
I set up a lua script(device) where I want to stop the action coming from the timer of the device. (I.e. if the timer opens the shutter at 70:00 but some variables.are true or it's Holliday the action should not be done). I can do that setting up the timer on a virtual switch and than drive the roller.shutter according to the different test.
This works but this approach requires a lot of virtual switches. Is there the option within the lua script to "stop" the action? And within the script (lua of type device) is it possible to test if the device has changed because the user clicked on the switch or if it is the timer associated with the switch that initiated the event?
Inviato dal mio PLK-L01 utilizzando Tapatalk
First part of you question can be done with only one virtual switch : i suppose for all shutters with only one timer function, assuming you want to open them all at the same time, if not you will max need the amount of switches for the amount of different things you want to check with (like 5 undipended timers). As far as i can see no way around this. Maybe with dzEvent thats being developped in current Beta
Second part is answered above with a user var being also set by the timer.
You can detect user input only if domoticz captures the signal being send :For instance RFY signals from the original sompfy remote is not captured so domoticz will never know.
Re: How to stop an action
Posted: Tuesday 13 June 2017 15:13
by lupo2a
What I get is that
- I'm not able to detect if the script has been run by the timer associated with the virtual switch or by an user who, via the web interface, activated the virtual switch. It would be an interesting functionality to be developed
- In order to "stop" the action I have to
- real device: send the command to the changed device with the previous value
- virtual device: use variables in order to do a test and do not send the command to the real device. In order to have the virtual device has the right state, change the virtual device accordingly
Re: How to stop an action
Posted: Tuesday 13 June 2017 19:13
by zicht
lupo2a wrote:What I get is that
- I'm not able to detect if the script has been run by the timer associated with the virtual switch or by an user who, via the web interface, activated the virtual switch. It would be an interesting functionality to be developed
- In order to "stop" the action I have to
- real device: send the command to the changed device with the previous value
- virtual device: use variables in order to do a test and do not send the command to the real device. In order to have the virtual device has the right state, change the virtual device accordingly
So create one dummie as the general timer....make in lua a small routine that if that one changes it triggers the physical actions you timer is know as the dummy device, all others are manual activated ... If you want to stop you can do so, you can even build predonditions that must be met before the dummy activates anything. The Stop once initiated can be done also eighter by the physical switch, in domoticz sensors or in lua. Depending on how flexible you want to make this.
I get the impression you are looking for some code suggestions ? The below needs correction to you needs, hope it gets you inspired...
Code: Select all
if otherdevices['Dummie'} == 'On' and somethingelse == 'value' and ..... then
commandarray['pysical device1'] = "On'
commandarray['pysical device2'] = "On'
commandarray['pysical device3'] = "On'
commandarray['pysical device4'] = "On'
commandarray['pysical device5'] = "On'
commandarray['pysical device6'] = "On'
commandarray['pysical device7'] = "On'
elseif otherdevices['Dummie'} == 'Off' and somethingelse == 'value' and ..... then
commandarray['pysical device1'] = "Off'
commandarray['pysical device2'] = "Off'
commandarray['pysical device3'] = "Off'
commandarray['pysical device4'] = "Off'
commandarray['pysical device5'] = "Off'
commandarray['pysical device6'] = "Off'
commandarray['pysical device7'] = "Off'
end
On the Gui you create the timer for the dummie --> One timer for all in this case.
If the timer is allready running you can create a push on dummie switch
Code: Select all
if devicechanged['stop switch']='On' then
commandarray['pysical device1'] = "Stop'
commandarray['pysical device2'] = "Stop'
commandarray['pysical device3'] = "Stop'
commandarray['pysical device4'] = "Stop'
commandarray['pysical device5'] = "Stop'
commandarray['pysical device6'] = "Stop'
commandarray['pysical device7'] = "Stop'
end
You can even make the times fixed in lua :
Code: Select all
Zononder = timeofday['SunsetInMinutes'] - 90
timenow = os.date("*t")
minutesnow = timenow.min + timenow.hour * 60
if (minutesnow = Zononder) and more conditions then
commandarray['pysical device1'] = "Off'
commandarray['pysical device2'] = "Off'
commandarray['pysical device3'] = "Off'
commandarray['pysical device4'] = "Off'
commandarray['pysical device5'] = "Off'
commandarray['pysical device6'] = "Off'
commandarray['pysical device7'] = "Off'
end
there are so many possibilities, you need to look what fits best for you. What you want is absolute possible...