Hi everyone,
The devices I usually work with send real-time data, but occasionally they may send sampled data from past moments, either due to communication failures or because we group data from different moments and send them all together.
The data format I send over MQTT includes the timestamp in milliseconds, for example: {“data0”: 11.3, “ts”: 1695715200000}. I send this message to a “JSON Object” attribute (configured as “Rule Event”) and process it using a Groovy Rule similar to the following rule: https://github.com/Raqbit/openremote/blob/radio-protocol/test/src/main/resources/org/openremote/test/rules/TestRule.groovy. Then, I store the information for the “data0” attribute with its corresponding timestamp as follows:
AttributeEvent att_event = new AttributeEvent(state.id, "data0", 11.3, 1695715200000)
assets.dispatch(att_event)
Therefore, on certain occasions, I send older data than the last received for a particular attribute. For example, the last data for the “data0” attribute has a timestamp of 1695715200000 (20230926T100000), and I send data with a timestamp from an hour before, which is 1695711600000 (20230926T090000).
In this case, the system does not store these older data and raises the exception “org.openremote.manager.asset.AssetProcessingException: EVENT_OUTDATED (last asset state time: Tue Sep 26 10:00:00 CEST 2023/1695715200000, event time: Tue Sep 26 09:00:00 CEST 2023/1695711600000).”
Is there a way to disable this exception without modifying the “openremote/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java” file? The code that raises the exception is:
// Check the last update timestamp of the attribute, ignoring any event that is older than last update
long finalEventTime = eventTime;
oldAttribute.getTimestamp().filter(t -> t >= 0 && finalEventTime < t).ifPresent(
lastStateTime -> {
throw new AssetProcessingException(
EVENT_OUTDATED,
"last asset state time: " + new Date(lastStateTime) + "/" + lastStateTime
+ ", event time: " + new Date(finalEventTime) + "/" + finalEventTime);
}
);
I need this functionality and would prefer not to modify the main project.
Thanks in advance.