Hello all,
What is the code in a rule to get the following information from an influxdb database?
Value latest update
Timestamp latest update
Value previous latest update
Timestamp previous latest update
Value previous previous latest update
Timestamp previous previous latest update
I want these in a variable to do some calculations.
Extra related question : when the latest update was the same value, how is this related to the timestamp?
Thanks for your quick answer, but I’m still getting problems reading out and do some calculation.
I tried with the code from your reply, but I get some errors. Searching the internet I found some working but the Item values are many times the same, and timing also. I want the timing in milliseconds.
This code is in a rule when Itemvalue changed, so when there is an update with same value, this code is not executed. Regarding to the previousState(false) or previousState(true) question.
Regards, Hans
The database is not the problem, I’m receiving data but wrong values…
2018-11-28 15:45:34.608 [vent.ItemStateChangedEvent] - Item changed from 369.905 to 371.877
I found out that when this request is at the beginning in a rule when a value changed and is logged with influxdb, sometimes the reading is wrong and last and previous value is the same. Probably a timing issue, reading too quickly while database is still getting updated. When I request it two times the second one is always correct and the first more not. Can I add a little wait or delay in the rule, or just request two times the same and use the second one?
anyone know how to read influxdb item info like daily average or 1 to 2 hours ago? as I would like the rule to perform as if current value higher than daily average like 5-10%, than don’t execute or execute command.