cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

The custom alert implementation

harshadbhandure
5-Regular Member

The custom alert implementation

Hello!

I want to watch over a particular property, for example, the temperature within the timeframe.

If the temperature is above some threshold for 15 min then an alert should be triggered.

The value can fluctuate above the threshold, it should be monitored and if it continues above the threshold for 15 min then the new alert should get triggered.

 

How can I implement it in an ideal way?

ACCEPTED SOLUTION

Accepted Solutions

Hello @harshadbhandure,

 

It depends on a number of factors -- how precise do you want to be with your alerts, how frequently you receive data from devices, how many devices do you have, etc.

 

Probably not an ideal way, but that's how I would have done it by default:

  1. Create two properties -- a DATETIME "temperatureHighSince" and a NUMBER "temperatureHighMinutes";
  2. Reset temperatureHighSince to current date on each temperature change, which goes below the threshold (OnDataChange subscription on temperature);
  3. Create a timer which runs every minute, goes through the list of all your asset things and updates temperatureHighMinutes property by calculating the difference between the current date/time and temperatureHighSince;
  4. Define alerts as thresholds on temperatureHighMinutes property;

This will give you reasonable precision, performance and will be easy to implement. Depending on how critical this "overheating" situation is you may want to make either (or both) of those properties non-persistent, just to improve performance.

 

Alternatively you can rely on the OnDataChange event instead of the timer (save on the query), or create a timer for each asset thing (increase real-timeness), or implement your own alerting logic (skip on the temperatureHighSince property), etc.

 

Regards,
Constantine

View solution in original post

2 REPLIES 2

Hello @harshadbhandure,

 

It depends on a number of factors -- how precise do you want to be with your alerts, how frequently you receive data from devices, how many devices do you have, etc.

 

Probably not an ideal way, but that's how I would have done it by default:

  1. Create two properties -- a DATETIME "temperatureHighSince" and a NUMBER "temperatureHighMinutes";
  2. Reset temperatureHighSince to current date on each temperature change, which goes below the threshold (OnDataChange subscription on temperature);
  3. Create a timer which runs every minute, goes through the list of all your asset things and updates temperatureHighMinutes property by calculating the difference between the current date/time and temperatureHighSince;
  4. Define alerts as thresholds on temperatureHighMinutes property;

This will give you reasonable precision, performance and will be easy to implement. Depending on how critical this "overheating" situation is you may want to make either (or both) of those properties non-persistent, just to improve performance.

 

Alternatively you can rely on the OnDataChange event instead of the timer (save on the query), or create a timer for each asset thing (increase real-timeness), or implement your own alerting logic (skip on the temperatureHighSince property), etc.

 

Regards,
Constantine

Hi @Constantine 

Thank you so much for the detailed explanation.

Announcements


Top Tags