Multiple overlapping dzvent events  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
galinette
Posts: 68
Joined: Monday 11 December 2017 22:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Multiple overlapping dzvent events

Post by galinette »

Hi,

I have two scripts, one running every hour, one running every 5 minutes. I need to merge them in a single one as they both increment/decrement a user variable.

Is it possible to make an event running on two timer conditions : 'every hour' and 'every 5 minutes' ?

Then, when running every hour, will it run twice, once for each trigger? Or will it run only once? In that case, what will be the value of item.trigger?

Thanks
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Multiple overlapping dzvent events

Post by boum »

Hi,
The script will be executed only once. In item.trigger, you will get the first rule that was evaluated to true. So you should put the 'every hour' first in the list of timer triggers.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Multiple overlapping dzvent events

Post by poudenes »

How about to create a Uservariable and use that variable for both scripts. You cant combine them. So 2 scripts 1 per hour 1 every 5 minutes

p.s. did you read my PM about Milight Plugin :D :)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Multiple overlapping dzvent events

Post by waaren »

poudenes wrote: Friday 05 July 2019 14:24 How about to create a Uservariable and use that variable for both scripts. You cant combine them. So 2 scripts 1 per hour 1 every 5 minutes
If the scripts are executed close to each other best to use a global_data variable.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Multiple overlapping dzvent events

Post by poudenes »

waaren wrote: Friday 05 July 2019 14:34
poudenes wrote: Friday 05 July 2019 14:24 How about to create a Uservariable and use that variable for both scripts. You cant combine them. So 2 scripts 1 per hour 1 every 5 minutes
If the scripts are executed close to each other best to use a global_data variable.
For my knowledge: because its faster a global_data variable? or other reasons?
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Multiple overlapping dzvent events

Post by waaren »

poudenes wrote: Friday 05 July 2019 14:39 For my knowledge: because its faster a global_data variable? or other reasons?
Other reason.

Because dzVents use one domoticz object with all devices, scenes, cameras, uservariables, etc. for multiple scripts to speedup overall processing it can happen that scripts executed with the same event-trigger (in this case every 5 minutes and every hour are triggered by the same time event once per hour; the other 11 times per hour the 5 minute script is triggered there is no issue) they use the same begin state.
example:

uservar a =70
hour script increase a with 100
5-minute script increase a with 50

assume hour script is processed first. ==> Increase uservar a (is 70 in domoticz object) increased with 100 ==> a = 170
5 minute script is processed when hour script has finished.Uservar a (also 70 because same domoticz object) increased with 50 ==> a = 120

So you expect a to be 70 + 100 + 50 = 220 after the execution of these two scripts but you get a = 120
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Multiple overlapping dzvent events  [Solved]

Post by poudenes »

Clear!!
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest