Is it possible, in ractor, to get the value (in this case CurrentTemperature) from a device at a specific time or interval?
What I’d like to be able to do is get the CurrentTemperature now, then again in a couple of hours and compare the two to see if it’s still updating.
These are the fabled Fibaro attached temperature sensors that I have mentioned times previous. They have a habit of either no longer updating the current temperature, or just vanishing.
Problem is, because I don’t check them often, I can’t often tell when they stopped, and may not have a backup that is old enough.
Got it. You could do this with a scene that runs on a time interval and some LUA code to grab the values and compare them to a stored array of previous values. The trick is deciding, in the case of a no longer updating device, when you make the decision the device is dead, as opposed to the temperature not changing. I have no idea what you’d get back if the device has vanished. I’m not sure if Reactor can do this—@rigpapa adds functionality so often that I’m probably way behind on its capabilities!
Many sensors have a “LastUpdate” variable that can be useful to check because it shows the timestamp that an update was last received from the device, whether or not the value received was different.
If this is true for those sensors, then a simple Device State condition to see if LastUpdateupdates will cause a true when the variable is written. Add a delay reset option to that condition of, say, two hours, and the condition will remain true unless and until the device stops updating for two hours, at which point, the condition will go false. Your activity to warn you, then, should be triggered on the false state.
Thanks guys. So the parent does have the LastUpdated variable. My concern is that this won’t work if unless all the sensors drop off? Typically they drop off one at a time. Last time I lost two, the other two were OK for weeks (hence the add / restore)
The other aspect with this is one of the failure modes is that (according to the logs) temperature data is still coming in. It’s clearly erroneous as it’s static for days / weeks to a 0.1C granularity.
Well, I always shoot for the simplest answer first, as it’s often the easiest to maintain. But there’s always more than one way to get the job done in Reactor.
That is a more literal implementation of your request, although a bit more complex. But if you simply want to have your chain pulled when delta-T over time goes to 0, that’ll do it.
Not at all! As I said, try what’s easy first, but if that isn’t cutting it, there’s a lot more ingenuity (and creativity if we add a little beer to the mix) we can muster up.
My Netatmo Weather station sometimes disconnects and I would like to get a warning when this happens. I think I built the condition based on your “simpler” comments further up. Is the below correct? Then when the Condition is false, send me a notification?
The only catch I can think of is that the Current Value is the Day and Time of the last update. This is supposed to update every 15 minutes.
That’s a catch, for sure. You can’t get a useful result testing a string like that as a boolean (“is TRUE”).
Here’s a general solution for Reactor 3.4 that could be used on a variety of devices:
First, create these Expression/Variables, putting in the device number, service ID, and variable name of the device state variable that is to be monitored to determine if the device is alive:
The order is important here. Make sure they are in exactly the order shown above. To be clear about what this is doing:
currval will receive the current value of the state variable
lastchanged uses an if() expression to check if the value in currval is the same as lastval; if it is, the if() returns the unchanged value of lastchanged; otherwise, it returns the current time.
age calculates the difference between the current time and lastchanged, which is how long ago, in seconds, since the value of the variable changed.
lastval is set to currval, so on the next evaluation of all these variables, it can compare the past value to the present value (currval).
From there, all you need to do is check “age” on the current ReactorSensor to see if it is greater than your timeout (in seconds). For example, if you want a warning if the device doesn’t update the variable in two hours, that’s 7200 seconds.
Reactor 3.5 will have two additional features to make this easier: a getstatetime() function to return the last-modified timestamp of a state variable, and a condition type to test a variable directly so you don’t have to use a self-referencing Device State condition to do it (the variable export also would not be needed, then). The screen shot of the status view below shows two different ways you could do the test. For the first condition, we have to compute the age and test it. Alternately, the second version of the condition shows how you can do a computation in the operand value. Here, age is not needed, we just compute the time 7200 seconds ago, and if lastchanged is less than (before) that, the condition will be true…
I think I have something wrong with the currval expression. It’s claiming an invalid operator at 4. Yet I cannot seem to locate it. Everything looks correct to me.