Trigger - based on a variable

Posted on
Mon Apr 16, 2018 12:00 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Trigger - based on a variable

Wondering what I'm missing here...

I have a trigger set up to activate a plug based on the value in a variable, but am running into a problem.

option 1
when I use the trigger option "becomes greater than", I can't seem to get the trigger to fire.

option 2
when I use the trigger option of "changes"
and set up a condition of "is greater than" the trigger fires as expected.


I guess I am wondering why the 1st option does not work and can I make it work that way, or is Option 2 just as efficient.

Thanx in advance for the clarification.

dave
Attachments
Screen Shot 2018-04-16 at 10.50.14 AM.png
Screen Shot 2018-04-16 at 10.50.14 AM.png (44.88 KiB) Viewed 3400 times
Screen Shot 2018-04-16 at 10.49.23 AM.png
Screen Shot 2018-04-16 at 10.49.23 AM.png (48.46 KiB) Viewed 3400 times

Posted on
Mon Apr 16, 2018 2:27 pm
brettlid offline
Posts: 55
Joined: Nov 28, 2017

Re: Trigger - based on a variable

Your second "option" is the way your supposed to do it.

The Trigger is something that happens whether a light is turned on, or a variable changes. The Condition is evaluated after the trigger occurs. If the trigger never occurs your Condition will never be checked.

Posted on
Mon Apr 16, 2018 4:22 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger - based on a variable

The two options actually express two different things: option 1 is a threshold crossing (goes from less than 59 to greater than 59), option 2 is any change that occurs when the resulting value is above 59.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 16, 2018 4:31 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Re: Trigger - based on a variable

Thanx Jay...

That is how I understood it.

I was hoping to get option 1 to work as this would trigger only when the threshold is reached... i.e. above 59. Option 2 triggers repeatedly as the temperature rises (or falls).

So what am I doing wrong with option 1 that it will NOT trigger.

Option 1, has a trigger, and an action
Option 2 has a trigger, a condition and an action.

d

Posted on
Mon Apr 16, 2018 4:58 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger - based on a variable

bsp9493 wrote:
Thanx Jay...

That is how I understood it.

I was hoping to get option 1 to work as this would trigger only when the threshold is reached... i.e. above 59. Option 2 triggers repeatedly as the temperature rises (or falls).

So what am I doing wrong with option 1 that it will NOT trigger.


And you're sure that when you test it you're going from below 59 to above 59? I just created an identical trigger and when switching the value from 50 to 60 it fires every time.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 16, 2018 5:28 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Re: Trigger - based on a variable

wow... that's strange... I've had it set to a test value of 59 for the last couple days, and my variable SolarTemp has gone back and forth a number of times.

I actually have both options (as noted below) set up.

Option 2, fires every 15 minutes when my variable updates and it is over the threshold of 59. Once below 59 it no longer fires (as expected)
Option 1 has NOT fired once:(

Hmmmmmmmm anything I can look for that may help figure it out?

all my other triggers work as expected (temperature, variable, device based)

I will try setting up another test trigger using a variable - will set up a variable for one of my thermostats and see if I can get that to fire.

d

Posted on
Mon Apr 16, 2018 5:48 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger - based on a variable

Just manually change the variable "SolarTemp" and watch the Event Log (also make sure that the trigger doesn't have any conditions).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 16, 2018 6:02 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Re: Trigger - based on a variable

Well, that is weird... if I manually change the variable, it works just as expected, but if I let my normal schedule run that updates the variable, it doesn't.

I'll keep an eye on it for the next few days and see what happens.

Thanx Jay!!

d

Posted on
Mon Apr 16, 2018 6:21 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger - based on a variable

bsp9493 wrote:
Well, that is weird... if I manually change the variable, it works just as expected, but if I let my normal schedule run that updates the variable, it doesn't.


How are you setting the variable? Is it a Python script? Can you show the code?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Apr 16, 2018 6:54 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Re: Trigger - based on a variable

Using a schedule, for the SolarTemp variable, I am inserting the state directly into the variable. Strange though, that the variable itself updates normally with the correct value.

Wonder if that has something to do with it - is it sticking text in there instead of a number?

d
Attachments
Screen Shot 2018-04-16 at 5.48.36 PM.png
Screen Shot 2018-04-16 at 5.48.36 PM.png (55.53 KiB) Viewed 3291 times
Screen Shot 2018-04-16 at 5.48.56 PM.png
Screen Shot 2018-04-16 at 5.48.56 PM.png (37.06 KiB) Viewed 3291 times
Screen Shot 2018-04-16 at 5.49.26 PM.png
Screen Shot 2018-04-16 at 5.49.26 PM.png (22.33 KiB) Viewed 3291 times

Posted on
Mon Apr 16, 2018 7:00 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Trigger - based on a variable

So that all begs the question - since these are all device states, why do you need them in variables?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Apr 16, 2018 7:28 pm
bsp9493 offline
Posts: 153
Joined: Nov 30, 2017
Location: Kelowna, BC

Re: Trigger - based on a variable

chem
pumps

these values all come from xml files - handled via ghost xml (see attached image 1 for example of whats available). Basically for those, the values that I use are contained within an item like "ichem" and that returns a comma separated list of values (0,,15,1540,0,0) that I am then parsing out to the individual variables.


To be honest, I never thought of that... the 4th ghost xml file (status) actual has defined values and states that I can use and "solar temp" is one of them. That would probably solve my problem if I just used it directly.

If I do that though, i lose the options to trigger via a threshold as Jay pointed out, and I end up with option 2 - triggering multiple times once the target is hit.

The two options actually express two different things: option 1 is a threshold crossing (goes from less than 59 to greater than 59), option 2 is any change that occurs when the resulting value is above 59.


See 2nd screenshot
Attachments
Screen Shot 2018-04-16 at 6.11.46 PM.png
Screen Shot 2018-04-16 at 6.11.46 PM.png (79.37 KiB) Viewed 3290 times
Screen Shot 2018-04-16 at 6.18.35 PM.png
Screen Shot 2018-04-16 at 6.18.35 PM.png (28.15 KiB) Viewed 3290 times

Posted on
Tue Apr 17, 2018 5:46 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trigger - based on a variable

bsp9493 wrote:
Wonder if that has something to do with it - is it sticking text in there instead of a number?

Variable values are always stored as strings. When doing comparisons on variable values, Indigo coerces them into numbers, so you don't have to worry about that.

When running your own code against variable values, you'll have to convert them yourself.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Apr 17, 2018 9:02 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger - based on a variable

bsp9493 wrote:
If I do that though, i lose the options to trigger via a threshold as Jay pointed out, and I end up with option 2 - triggering multiple times once the target is hit.

The two options actually express two different things: option 1 is a threshold crossing (goes from less than 59 to greater than 59), option 2 is any change that occurs when the resulting value is above 59.


See 2nd screenshot


The type of the state in the device is set to string - which is why you don't see mathematical operations on it. So, in this case, yes, you'd need to stuff it into a variable and let the server coerce it to a number. There isn't a way to change a variable value that bypasses the trigger (as far as I know) so I'm not sure how the value is changing but the trigger isn't firing.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest