So for my temperature control in my flat I average all my sensor in each room. This works fine as long as all the sensors are online, it happens that my netatmo got stuck and then the value of that sensor get stuck at the last value OH received from it.
I am working on a notification rule to check when the last status update was for every sensor(like a cron rule every 3h or so) : i was thinking about making a group called Sensor_Timestamp and then loop through that group and check for last update time, and if one sensor has not been updated for more than 3hours then email myself to figure out whats wrong…
But the problem is that if I dont have time to fix the issue straight away I would like to omit that value from the group average, so how can I do this? Can I force update the sensor to null in my timestamp rule or is there a better way?
I recommend using the Expire binding to set that sensor’s value to UNDEF. Trigger a Rule based on when Items go to UNDEF to send you a warning. If you are using a Group:Number:AVG I think it will still work even though one of the Item is UNDEF. If not, you’ll need a Rule to filter out the UNDEF Items and calculate the average with the rest.
val goodTemps = Temps.members.filter[ t | t.state != NULL && t.state != UNDEF ]
val sum = goodTemps.map[ state as Number ].reduce[ sum, temp | sum + temp ]
val avg = sum / goodTemps.size
Yeah, I have been thinking about that, I guess its many ways to rome…
So for me I have 10 different netatmo things which have like 6 different items/channels, which means that if the things runs out of battery, loose internet, needs to accept the updated GDPR etc I will need to get a warning.
So I could do expire on every item and get 60 undef messages sent to my email,
I could just use expire at the lastupdate item, when that change to undef use a rule to send email and set all items in that group to undef.
the best option probably create a dummyItems: switch sendNotification and String failText
So when one of the 60 items fails it will keep adding debug info to failText and set sendNotifcation to OFF which then has expire timeout of lets say 10 min before it expires to ON
rule "sensor fail"
Item Group_Sensors changed to UNDEF
failText.sendCommand(failText.state + " <br> This sensor has now not been able to get an update for 3 hours, please manually check it: " +triggeringItem.name
rule "send notification"
Item sendNotification changed From OFF to ON
sendEmail("email@example.com" , failText.state)
1 and 2 are not mutually exclusive. You have two different concerns here.
Get notification that a sensor device has gone offline.
Avoid using stale data in your calculations.
I still suggest that you use Expire on all these Items and have them go to UNDEF when they do not receive an update after a reasonable amount of time (usually 2 x reporting period). This addresses 2.
Does the Thing go offline when it stops reporting in all of these cases? If so, you can use that as a trigger on a Rule to send the notification.
If not something like your 2 is documented in Design Patterns: Generic Is Alive.
It does not go Offline, link to API still is active…