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:
- Create two properties -- a DATETIME "temperatureHighSince" and a NUMBER "temperatureHighMinutes";
- Reset temperatureHighSince to current date on each temperature change, which goes below the threshold (OnDataChange subscription on temperature);
- 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;
- 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