Hi. I need to query item current value from influxdb.
How is it done? I have manually uploaded item future values, but influx seems to consider “now()” as last value.
I think this idea of using a persistence service as a predictive service may cause some troubles
Seems right. So far as DB is concerned, the most recent record is what the state still will be “now”. Your problem seems to be that the record with the “latest” timestamp is in the future,
From the docs,
<item>.historicState(AbstractInstant)
Retrieves the State of an Item at a certain point in time
Use that method with a now datetime
I got it working. Thanks.
rule "Get CurrentPrice"
when
Item RunRule changed or
Time cron "0 0 0/1 1/1 * ? *"
then
var x = NP_Electricity_price_test.historicState(now).state as DecimalType
NP_Electricity_price_current.postUpdate(x)
end
Can you share how you did that? I have been looking at storing future electricity prices by timestamping the entries with the “valid from” time as they are pushed into the database but haven’t worked out how yet.
Looks like you have already cracked both storing and retrieving so would be good to see how.
Thanks