REST API persist Item state for specific date

With this API command curl.exe -X PUT --header “Content-Type: text/plain” --header “Accept: application/json” "http://192.168.158.170:8080/rest/items/SmartMeter_Einspeiser/state " -d 8.7 -v I can pass a value to an item in the OPEN HAB environment without any problems.
I read in some forum entries that it is possible to enter a date with the API variant. Background: This value comes from the provider via email days later and I don’t want to falsify the historical days and view´s in the open hab environent.

What is the syntax for the API variant, how I can send the specific date with this value ?

e.g. curl.exe -X PUT --header “Content-Type: text/plain” --header “Accept: application/json” “http://192.168.158.170:8080/rest/items/SmartMeter_Einspeiser/state” -d 8.7 -date “09.06.2024 23:59:00” -v

Thanks for help
Markus

You can always have a look at the API explorer in the developer tools of Main UI to check what the REST API is able to do:

thanks for Info, I use the default persistence service rrjd4 with this configuration
configurations:
cronStrategies:

  • name: everyMinute
    cronExpression: 0 * * ? * *
  • name: everyHour
    cronExpression: 0 0 * * * ?
  • name: everyDay
    cronExpression: 0 0 0 * * ?
    defaultStrategies:
  • everyChange
    thresholdFilters:
    timeFilters:
    equalsFilters:
    includeFilters:

Now i have excute this Comannd

and got this Info → Persistence service not modifiable: rrd4j

Where can i change this behavior for this rrd4j persistence service ?

This behaviour is not changeable, it’s a limitation of RRD4J.
You might have a look on InfluxDB as an alternative, but you need to setup a InfluxDB sever yourself.

ok, now i have InfluxDB installed, and get this first Info
image
Fine
Now i try to insert an value


and got that the time is not a valid format

Is the time not correct ?

hm, what´s wrong

I din’t think the T part needs quotes.

1 Like

Changing old data for rrd4j via openHAB is not possible. The reason is simply the way data is stored in rrd4j. This persistence uses “archives” to store data for different timeranges (for example: the last day, the last 7 days, the last xx days…). Each data request is fetched from that archive that covers the whole requested timeframe.
In other words for a specific timepoint there migth be data in more then one archive. ( data for now-4 hours would be in the archive of the last day, the last seven days…).
Changing such a datapoint correctly later is rather “complicated”.I had posted a way to change indivdual datapoints “by hand” in a rather old post. However setting all affected archives correctly that way remains “complicated”.
Old post

now i have create a openhab persistent config with influxdb, no problems
now I have imported ~400 values with this command → JJJJ MM TT with different values
curl -X PUT “http://192.168.158.170:8080/rest/persistence/items/SmartMeter_Einspeiser?serviceId=influxdb&time=2024-05-24T12:59:00.000Z&state=8.125” -H “accept: /” -H "Authorization: Bearer curl -X PUT “http://192.168.158.170:8080/rest/persistence/items/SmartMeter_Einspeiser?serviceId=influxdb&time=JJJJ-MM-DDTHH:MM:SS.000Z&state=8.125” -H “accept: /” -H “Authorization: Bearer eyJraWQiOm51bGwsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJvcGVuaGFiIiwiYXVkIjoi… -v”
I got this command with the api explorer, but where does this authorization chain come from?

All likes good in grafana

Suddenly this authentication is different again? Can’t it always stay the same or can i use a user and password for this authorization ?

i got with curl this error

  • Request completely sent off

< HTTP/1.1 401 Unauthorized

< Content-Type: application/json

< Date: Sat, 15 Jun 2024 11:24:03 GMT

< Transfer-Encoding: chunked

< Server: Jetty(9.4.52.v20230823)

<

{ [63 bytes data]

Best regards

The token used by the API explorer is a short living token, Main UI is able to refresh this token when you are logged in.

To get a API token that doesn’t change, go to the profile page and create an API token from there, also see openHAB REST API | openHAB.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.