This object is in archive! 

Can you explain the rule order ?

domoteek shared this question 11 years ago
Need Answer

Can you explain me how works the rule order ?


For example, if I had two contradictory rules like :


rule 1 light must be ON between 19-22

rule 2 light must be OFF If i'm away


So if I'm away between 19-22, wich one will be priority ?

Replies (9)

photo
1

Don't create Rules that is contradictory!

Thats not a good idea, I think ;-)

Becouse you can't be sure of the result will be, today and in future...


If you must have logic like that, add everything in ONE rule and do the priority yourself.

If you as a trigger to the rule triggers on any for all involved devices you then can implement the whole logic in one rule instead of two or more.


WHEN dev1=any OR dev2=any OR dev3=any THEN

Then here you add yor logic


Then you can check the times inside rule

photo
1

So the rule order have no sense ?


So why can we re order the rule ?

photo
1

Each rule makes a part of the main script. Script is run upon any event, checking is there some rule which should be triggered by that event. There are many options to control the script! By default, all the rules has a "STOP" built in and the end. So if you create two simple rules with the same "trigger events" only the first one will execute. Soon we will add the option to remove this stop and afterwards, so in this case, the rules order will be important (as the last one will be more important). This is an already built in feature but we didn't publish it as it seems like more advanced for the average user.

photo
2

What???

Do you mean that if I have two rules:

Rule 1 - when device1=open then do action A

Rule 2 - when device1=open then do action B


then when device1 changes from close to open, only Action A will be done???


As a software engineer and as a ordinary user of this system I think this is wrong!

The most logicaly must be to execute ALL Rules that has a trigger that has been triggered???


Why not?


I am very sure about that most (or all) user will think that if you have a rule to trigger on something, it will do that even if thay add an other rule later to do something else on the same trigger...


So please remove that STOP in the main script!!!!


Is that stop added becouse performance issues, or how do you think?

photo
1

And about importance of the rule order.

If you have the stop, then rule order is important.

If you don't have the stop then the rule is not so important.


Can you explain what you mean that the last one is most important?

(Normaly if two Rules has the same trigger you don't do actions on the same device)


So I think it is the other way around ;-)

If you don't have stop, rule order not so important!

If you have the stop (as you say it is now) then there must be possible to move the Rules in the list, change the order.


If you remove the stop, not so important (But nice) to ba able to change order.


Ex:

If I have I working system with Rules, it must be possible to just add a new rule with a trigger, without have to trought the whole list of Rules and check for the same trigger.

Maybe I just want to add a temprary to send a email when frontdoor opens.

Then I don't want to have to change inside some other Rules that also triggers on frontdoor open!


This is important!!! Think over it and I hope you remove the stop.

Add the stop as a puzzle-piece that can be used in Rules if you want to stop the rest of trigger checking. That could be usful sometimes to "cancel" triggers.

photo
1

Sebastian: My two comments above was a reaction of what you wrote!


But now when I test, is is not working as you say, is is working as it should! ;-)


if I have two rules

Rule 1 - WHEN door=open THEN action lamp1, ON

Rule 2 - WHEN door=open THEN action lamp2, ON


Then if I open the door BOTH rules is triggered, just as it should be!


So sorry my comments above, but I say THAT was a reaction on what S wrote...

ZipaBox is (as what I can see now) working just as it should! :-)

photo
1

one more thing!

I had missed that you can drag-drop and change the Rules Order.

My misstake, and that drag-drop reorder is good!


Can you also do so that if I drag-drop a Rule out to the "Design Area" it is opened for editing! :-)

photo
1

My mistake. This was a big dilemma and recently we removed STOP from the rules. Order of the rules is important as the script is running the rules according to it. However, you can easily re-order the rules by just drag and drop them within a list as I said. We will also like to add feature to drag and drop them in the WORKBENCH for editing but there are some GUI problems, so we postponed this issue. Regarding the rules orderd, please note that sometimes, there can be multiple thready so if you put WAIT in some rule, the next rules will execute first and after a "WAIT" period the first one will execute. This is the scenario in which the first rule will execute after the second one.


Sorry for the wrong info in previous post.

photo
1

No problem, just good it was cleared out.


Regarding WAIT in Rules how is it implemented?


I did ask for some days ago, without any answer...

http://community.zipato.com/responses/a-solution-how-to-do-a-periodic-trigger-each-15-minutes


Will a Rule that do waits for hours to implement a TIMER-trigger ( se my qustion above) have any negative issues on the ZipaBox system?


Or is that a good way to implement a TIMER-trigger until the Scheduler have the functionality?


I think that your software have a main message-loop that when there is a new event goes trought the list of all rules and check if any one of them shall be triggered on that Event.

I also remember that there is not any visible changes of status, or variables, during that loop (ie. all data is frozen during the loop)

But will a triggered Rule spawn a new thread, to execute it? or how is it implemented?

(I think that a Wait will not hang the event-loop?)

Leave a Comment
 
Attach a file