The persistence for InfluxDB does impose some limitations: you can’t use the tags and the multiple values and different retention policies in InfluxDB. For example, you could have a measurement “Temperature” and the tags “Inside” and “Outside”. Or maybe you want some measurements saved forever and others for much less time. You can use continuous queries to down sample, but it doesn’t cover every case. Also, you can have a measurement “SensorValues” with values such as Temperature and Humidity all within that measurement. Fortunately there is quite an easy workaround with the HTTP post request. I’ve put a sample below for anyone who is interested. If you’ve used the authentication above, you’ll need to add it to the http val. And of course modify it to your liking.
The InfluxDB write documentation is here
I use a timer to not bog down the rules when the post request is running.
val String INFLUXDB_WRITE = "http://192.168.86.212:8086/write?db=openhab_db&rp=autogen"
var Timer influxWriteTimer = null
rule "End Peak"
when
Time cron "0 0 20 ? * MON-FRI *"
then
if (influxWriteTimer === null) {
influxWriteTimer = createTimer(now, [|
sendHttpPostRequest(INFLUXDB_WRITE, "application/json", "KWHPeak value=" + KWHPeak.state.toString, 3000) //
influxWriteTimer = null
])
} else {
logWarn("eagle", "Influx write timer is still running, not creating another")
}
en