I would like to add a things’ location to the measurememts sent to influxdb. Is this achievable in any way?
No. Persistence only saves the states of the Item and the timestamp, nothing more.
It is possible to send additional data to InfluxDB if you do it outside of persistence. I’ve done that. Persistence sends the State of the Item and the timestamp. But you can use the http action to send whatever you want directly to InfluxDB. Sometimes this makes sense for a group of measurements that all happen at the same time or when you want to add some other information.
Note, however, that you can’t get it back from the database via persistence if you do it this way. In my case I’m looking at the data in Grafana - I don’t need it in OH. If you have to get back to OH, you’ll need to write your own http actions to do the queries you want.
Can you provide a sample on how to do this?
It’s been a long time since I looked at this which is old DSL code, but here’s an example. Also this is using Influx 1.8, not the newer versions. Anyway, maybe this can help. Note that you set the database and retention policy in the command.
val String INFLUXDB_WRITE = "http://192.168.86.212:8086/write?db=openhab_db&rp=autogen"
sendHttpPostRequest(INFLUXDB_WRITE, "application/json", "KWHOffPeak value=" + KWHOffPeak.state.toString, 3000) //
sendHttpPostRequest(INFLUXDB_WRITE, "application/json", "Energy,type=OffPeak kWH=" + KWHOffPeak.state.toString, 3000) //