Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello
I would like to create an alert (email or other) when a device is not refreshed for more than N minutes ?
I had a look in alert but it is only "equal" or "not equal" tests for properties (and when it is updated)
I probably need to create a timer and a service but I guess there is something already "packaged" for that as it is an usual need ?
(I did not find easy answers in forum and documentation)
Thanks
Solved! Go to Solution.
Hello, from what I can see from your question, I assume that you are requiring a regular update to the device (a Thing entity)
My question is, how is the Thing updated? Some random properties get a new value in a random time or all the properties get changed?
BTW, the String property only have "equal" "not equal" in its alert type, Numeric and time properties has extra type as "above" "below" "out of range"
I'm not sure if there's a build-in service for that, here is my solution:
Create a service or subscription or in Expression widget, when CurrentTime - LastUpdateTime > TimeToWait, it will send out alerts and emails
The CurrentTime value is easy to get, and here is 3 possible ways to get LastUpdateTime value:
It returns the time when the connection is turned off.
Hello, from what I can see from your question, I assume that you are requiring a regular update to the device (a Thing entity)
My question is, how is the Thing updated? Some random properties get a new value in a random time or all the properties get changed?
BTW, the String property only have "equal" "not equal" in its alert type, Numeric and time properties has extra type as "above" "below" "out of range"
I'm not sure if there's a build-in service for that, here is my solution:
Create a service or subscription or in Expression widget, when CurrentTime - LastUpdateTime > TimeToWait, it will send out alerts and emails
The CurrentTime value is easy to get, and here is 3 possible ways to get LastUpdateTime value:
It returns the time when the connection is turned off.
Thanks a lot for detailed explanation.
In my case all data are refreshed by 2 messages but if the connection is deffective I receive nothing associated to the thing (So I acnnot check when I receive a message).
I'll create a generic service to monitor all my things (they are on the same template) based on your guide and with a timer to awake it regularly to check the last updates.
But perhaps it could be a good built-in service to monitor things to be implemented in the future
regards
So I have created a timer thing and I created a subscription to it in the device template in which I'm testing the last update of the device
(I'm storing this in the device thing property)
It works very fine and very easy with simple code.
var today = new Date();
me.DeviceUpdateStatus = "OK";
if ( (today - me.DeviceLastUpdate) /1000 > 36000 ) // 10 heures
{
logger.error ( me.name + " pas de mise à jours depuis " + (today - me.DeviceLastUpdate) /1000 + "secondes")
me.DeviceUpdateStatus = "ERROR"
}
else if ( (today - me.DeviceLastUpdate) /1000 > 3600 ) // une heure
{
logger.warn ( me.name + " pas de mise à jours depuis " + (today - me.DeviceLastUpdate) /1000 + "secondes")
me.DeviceUpdateStatus = "WARNING";
}
and the mashup
following the recommendation, I could optimze the performances in the future with one thing to parse all device (using etImplentingThingsWithdata) when I'll have thousand of devices to manage
Timers and Schedulers - Best Practice
Thanks for help !
pjoly Cool, I'm glad I could help, and you can mark my reply as Correct so that this thread will be officially completed in this community, Thanks~