Rule for "becomes"

Tips and Techniques for using MLServer's Automation Rules
Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Rule for "becomes"

Postby Art Dustman » Mon Sep 22, 2014 6:05 pm

Maybe I just overlooked it...
Is there a method to evaluate when something becomes something?
ex: Whenever variable "myvariable" becomes "6"; then .......

*Note that in order to "become" 6 in this example, I must not have been 6 previously before the change.


Currently I can look for a change in status, and equality to 6, but I believe in the instance as above, this would be a false trigger. There are legitimate reasons to look for a change, and always fire on equality to some variable.

I simply want to fire a rule the moment I become 6, then then no more unless I change and am not originating for 6.

Make sense?

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Rule for "becomes"

Postby CinemarDave » Mon Sep 22, 2014 7:43 pm

Automation rules will only fire when a variable changes value. So if you have a rule that says

Whenever Hiram equals 6
Then SetVariable|foo~Hey I'm six


Then from MLServer you did
Macro|SetVariable|Hiram~0!SetVariable|Hiram~6!SetVariable|Hiram~6!SetVariable|Hiram~6!SetVariable|Hiram~6

The rule would only fire once.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Mon Sep 22, 2014 8:10 pm

hmm. Then I can't explain this: (or am I caught in my own conundrum that off is now 0 and anything other an 1 is "off") ? but if so, why repeatedly?

9/21/2014 12:01:32 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:01:32 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:01:32 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:01:32 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:01:32 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:07:32 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:07:32 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:07:32 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:07:32 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:07:32 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:10:30 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:10:30 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:10:30 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:10:30 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:10:30 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:10:47 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:10:47 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:10:47 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:10:47 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:10:47 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:13:32 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:13:32 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:13:32 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:13:32 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:13:32 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:19:47 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:19:47 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:19:47 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:19:47 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:19:47 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:26:02 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:26:02 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:26:02 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:26:02 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:26:02 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:29:02 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:29:02 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:29:02 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:29:02 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:29:02 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:35:17 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:35:17 AM Push [0] SetVariable|Humidity2_animate~
9/21/2014 12:35:17 AM Pop [0] SetVariable|Humidity2_animate~
9/21/2014 12:35:17 AM MLProcess Primary [1] (1) [SetVariable|Humidity2_animate~] from []
9/21/2014 12:35:17 AM MLProcess Primary [1] Exiting MLProcess
9/21/2014 12:38:17 AM Automation Event Event Triggered for Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~
9/21/2014 12:38:17 AM Push [0] SetVariable|Humidity2_animate~

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Rule for "becomes"

Postby CinemarDave » Tue Sep 23, 2014 11:41 am

Were you manually toggling light #69 causing the status to change? {{lighting_69_status}} has to be changing in order for those rules to fire.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Tue Sep 23, 2014 1:30 pm

I wasn't. I would have to look through the Vera logs to see if something else was turning it on. I brought this up because MLserver went comatose and needed a a restart. This was at the same time of these logs. I'll dig more and post later tonight.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Tue Sep 23, 2014 6:28 pm

Vera release candidate was the cause.

The good folks at MCV decided to make sure ALL rules in the previous UI are just now enabled by default. Guess thats why the humidifier was running with me sweating my A$$ off the other night, and the holiday light outlets were doing holiday things, and other events that I specifically DISABLED. It was a long day today... Venting complete.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Wed Oct 22, 2014 9:04 pm

After further review... I still think the rules engine is firing inappropriately; or at least to what we discussed. I don't see any "on" events, but I keep seeing the automation rules engine evaluating "off" for one of the vera devices.

As a test, I added a new device and setup a rule brand new, that does like the previous posts - looking for a value to be less than 35 (which you said is really becomes)
There was no false evaluations for 4 days.
The moment the device changed value once, the server evaluated <35 continuously over several hours.

It seems as if I have to condition that with :
1. changes value
2. AND is less than 35; which really is better suited as a single entry of "becomes" which is different than "is"

Because this will bring the server to it's knees: Event Triggered for Whenever lighting_121_watts is less than 35

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Rule for "becomes"

Postby sonypoolplr » Thu Oct 23, 2014 6:45 am

I am not an expert on the rules, but the latest example that you listed as "<35" would have the rule firing whenever that variable is below 35. If you want it to fire once then use "becomes". This should keep it from firing only when the value equals 35 once, until it changes to say 34 and then back to 35. If you are using it to say turn on a device, I think you could even try putting another line in like "and device xyz is on" then that would be another check to keep the rule from firing over and over again.

Hope this helps.

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Rule for "becomes"

Postby CinemarDave » Thu Oct 23, 2014 11:12 am

The rule tied to the variable will be evaluated every time a SetVariable is issued to this variable. If the rule is If the variable is less than 35 then do something then it will indeed do something every time the variable is set and its value is less than 35. If it is a one time trigger then you'll need some additional logic that tracks the fact that you know it is less than 35.

Whenever {{XYZ}} changes value
If ({{XYZ}} < 35) and ({{XYZ_Flag}} <> 1) then
SetVariable|XYZ_Flag~1
Do some other interesting commands
else
If ({{XYZ}} >= 35) then
SetVariable|XYZ_Flag~0
end if
end if

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Thu Oct 23, 2014 2:06 pm

That makes perfect sense... going back to where this started though

Whenever lighting_69_status equals Off
Then SetVariable|Humidity2_animate~

Will fire every single time when the variable changes from Off to Off ----> FWIW in my opinion begs for a one-time function such as "becomes"

So, that leaves me scratching me head from one of your original posts:

CinemarDave wrote:Automation rules will only fire when a variable changes value. So if you have a rule that says

Whenever Hiram equals 6
Then SetVariable|foo~Hey I'm six


Then from MLServer you did
Macro|SetVariable|Hiram~0!SetVariable|Hiram~6!SetVariable|Hiram~6!SetVariable|Hiram~6!SetVariable|Hiram~6

The rule would only fire once.

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Rule for "becomes"

Postby sonypoolplr » Thu Oct 23, 2014 2:52 pm

I just called up MLServer rules and there already is a condition "becomes". Have you tried this?

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Thu Oct 23, 2014 3:18 pm

I don't have a becomes, nor have I ever seen one. What version are you running?

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Rule for "becomes"

Postby sonypoolplr » Thu Oct 23, 2014 3:51 pm

The version I have is 4.0.5405.24302

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Rule for "becomes"

Postby CinemarDave » Thu Oct 23, 2014 4:06 pm

Also, need to clarify. A server variable has to change value first in order to become eligible for rule evaluation.

If {{XYZ}} == 23 then

SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25
SetVariable|XYZ~25

Would only result in the automation rule being fired once. The first time it changed from 23 to 25.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: Rule for "becomes"

Postby Art Dustman » Thu Oct 23, 2014 4:43 pm

Ok. So if an Internal process changes variable, it won't evaluate repeatedly. I verified that.

What happens when a driver (VERA for example) posts back to the db as "Off" unsolicited or during a poll? -- BINGO!

Tested hitting off repeatedly on a Vera switch and the rule fires every time. #-o


Return to “Automation Rules”

Who is online

Users browsing this forum: No registered users and 1 guest