How to stop an action

Moderator: leecollings

Post Reply
lupo2a
Posts: 32
Joined: Thursday 29 September 2016 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to stop an action

Post 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
Raspberry PI 4
Domoticz: V2023.2
- Aeotec Gen5 EU
- Neo CoolCam Door Detector and plug
- FIBARO FGWPE Wall Plug
- 6 FIBARO System FGRM222 Roller Shutter Controller 2
- Kodi SamnsungTV Yamaha plugin
- pluginn manager
- Netatmo
lawcorn
Posts: 1
Joined: Tuesday 16 May 2017 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to stop an action

Post 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 :)
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: How to stop an action

Post 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.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
lupo2a
Posts: 32
Joined: Thursday 29 September 2016 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to stop an action

Post 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
Raspberry PI 4
Domoticz: V2023.2
- Aeotec Gen5 EU
- Neo CoolCam Door Detector and plug
- FIBARO FGWPE Wall Plug
- 6 FIBARO System FGRM222 Roller Shutter Controller 2
- Kodi SamnsungTV Yamaha plugin
- pluginn manager
- Netatmo
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: How to stop an action

Post 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...
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest