Alert rule on series of timestamps

Trying to create an alert, when one of 5 temperature-sensors are not responding any more.
For this i use Infinity-Datasource and i grab the timestamps of the last update of all 5 objects in iobroker.


Picture shows the result: One single value per sensor, so i have a series of 5 values.

Now i want to compare to actual time… the only way to get the time was to use a MySQL datasource and to ask for unix_timestamp.
grafik
Picture shows the result: One single value with actual time.

Now i create a math expresion to compare the 5 sensorvalues against actual time and define a threshold.


This picture shows that all 5 values of the sensors show no alert, everything seems to be ok.

But when saving and waiting for some reaction, it turns into an error message:

Where is my problem?
I assume it is the mismatch that i have 5 values in $D and only one in $A ???

Any way out of that?

Hi,

if you’re using Infinity Plugin datasource, is your data coming from an rest API? If it returns JSON and you could use Backend parser, you could get current time from JSONata (using $now()) and subtract the returned timestamps from $now. That way you would do everything in one datasource.

I was searching for a list of functions in jsonata yesterday but did not find any… so thanks for information.
But how to use it?

If i put only “ts” in that Rows/Root window, then i see 5 ts-values below.
If i add the $now() i get a errormessage:

[sse.dataQueryError] failed to execute query [A]: error while performing the infinity query. error converting json data to frame: error evaluating JSONata expression left side of the “-” operator must evaluate to a number, position:7, arguments:

Am i doing something wrong ???

ah… got it… i do not need $now() i need $millis()…

Hmmm…
still issue with generating the correct output:

“$millis() - ts” works if the URL delivers one ts-value.
The result of the URL is with one value:
[{“id”:“mqtt.0.arduino.esp-c9cdb7.283C7734000000F4”,“val”:38.69,“ts”:1739451235918,“ack”:true}]

When selecting more values, for all 5 sensors, the result is:
[{“id”:“mqtt.0.arduino.esp-c9cdb7.283C7734000000F4”,“val”:39.06,“ts”:1739444929078,“ack”:true},{“id”:“mqtt.0.arduino.esp-c9cdb7.28A2EE370000009A”,“val”:33.44,“ts”:1739444929087,“ack”:true},{“id”:“mqtt.0.arduino.esp-c9cdb7.28FF64182188D2EF”,“val”:37,“ts”:1739444929129,“ack”:true},{“id”:“mqtt.0.arduino.esp-c9cdb7.28FF6418218C247D”,“val”:28.38,“ts”:1739444929129,“ack”:true},{“id”:“mqtt.0.arduino.esp-c9cdb7.28FF641821B04985”,“val”:36.12,“ts”:1739444929129,“ack”:true}]

and then the
“$millis() - ts”
does not work any more, it creates the errormessage
[sse.dataQueryError] failed to execute query [A]: error while performing the infinity query. error converting json data to frame: error evaluating JSONata expression right side of the “-” operator must evaluate to a number, position:0, arguments:

I have similar effect when using https://try.jsonata.org/… so i assume i need to modify syntax but can’t find the solution so far…