Changes operator

I’m trying to migrate a following PLEG logic to Reactor:

cNetatmo pTempOutside; sHourly > 5:00:00

sHourly being a schedule that is on every (exact) hour and off a minute past. I’m trying to detect if Netatmo is not sending an updated temperature reading within 5 hours after which I’m using an alternate source for temperature.

I figure that I could use changes operator (from any to any) with perhaps ”condition is sustained for” but how exactly?

You are oh so close! You have the first part right: have your device state condition use the “changes” operator with no terminal values (leave the “from” and “to” fields blank) because it doesn’t matter what the values are, just that it changes.

The option you want is “delay reset”, not “sustained for”. Add a “delay reset” option of 18,000 seconds (5 hours). This will hold the true state for five hours after the last trigger by the “changes” operator. If it doesn’t trigger and the timer expires, the condition will go false. So the condition will go false when there has been no change in five hours.

Need that inverted? If you put that condition in a group set to “NOT AND”, the group will go true when the condition goes false–the group will go true when there has been no change in five hours.

1 Like

Thanks Patrick!

1 Like

FYI, I just noticed that I used “updates” instead of “changes” in my screen shot, but it doesn’t matter which you use in this case. They will have the same effect.

Plot thickens… :smiley: In a continuation to my previous question, I’m trying to mirror the following PLEG functionality:

(cNetatmo ? pVirtualtemp : pTempOutside) > 5

“cNetatmo” condition is now correctly duplicated on the Reactor side, but the rest of the formula is not. And the construction above means that if “cNetatmo” is true, value of pVirtualtemp is used, and if false, pTempOutside is used (and then compared against a fixed value of 5 degrees).

I went through wiki documentation for expressions, but couldn’t solve this on my own. Specifically I didn’t find out how to reference a group state (like “Netatmo test”) in expressions? So something like:

if ("Netatmo test") then
  return VirtualTemp
else
  return TempOutside
end

You can use getstate() to get the state of a group from the current or another ReactorSensor. It will give you a “0” (false) or “1” (true).

The if() function operates like the Excel function of the same name: if( conditional-expression, true-expression, false-expression)

If the conditional-expression is true, then the true-expression is evaluated and its result returned; otherwise, the false-expression is evaluated.