# InfluxDb downsampled data

**URL:** <https://community.openhab.org/t/influxdb-downsampled-data/169305>\
**Category:** Persistence Services\
**Tags:** influxdb\
**Created:** [May 16, 2026, 12:26pm UTC](https://community.openhab.org/t/influxdb-downsampled-data/169305 "2026-05-16T12:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dash](https://community.openhab.org/user_avatar/community.openhab.org/dash/32/45742_2.png) [@Dash](https://community.openhab.org/u/Dash)\
**Post date:** [May 16, 2026, 12:26pm UTC](https://community.openhab.org/t/influxdb-downsampled-data/169305/1 "2026-05-16T12:26:50Z")

</div>

I’m considering the move to InfluxDb (v1) from RR4J. I currently make use of charts, in the main UI and sitemaps, and analytics. I want to retain the RR4J functionality of downsampling historical data, but ideally I want to gain more control over this (e.g. temperature data I don’t need to retain granular information very long, where other measurements I have a desire to keep as-is).

As I understand it, this can be easily achieved with InfluxDb 1 through the use of retention policies and continuous queries to manage downsampling of measures.

What I can’t work out though is how openHAB is able to access historical data. Is there a naming convention or other concept that enables openHAB to access downsampled data points?

---

<div class="post-metadata">

**Author:** ![nw378](https://community.openhab.org/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@nw378](https://community.openhab.org/u/nw378)\
**Post date:** [May 16, 2026, 1:52pm UTC](https://community.openhab.org/t/influxdb-downsampled-data/169305/2 "2026-05-16T13:52:28Z")

</div>

Maybe Influx V2 is something for you then. There, you can set the retention period and create downsampling rules.

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/c/6/c6e141aa9bd76bb88e3f37edd11bc602a363b2f6.jpeg)

```auto
import "timezone"
import "date"

option task = {name: "Einspeisung", every: 1d}

option location = timezone.location(name: "Europe/Berlin")

from(bucket: "openHAB")
    |> range(start: date.add(d: -1d, to: today()), stop: date.truncate(t: today(), unit: 1d))
    |> filter(fn: (r) => r["_measurement"] == "Einspeisung_kWh")
    |> filter(fn: (r) => r._field == "value")
    |> aggregateWindow(every: 1d, fn: last, createEmpty: false)
    |> to(bucket: "openHAB_history")

```

In this case, the downsampled data in the second bucket cannot be accessed directly from openHAB. But with a scipt:

```auto
#!/bin/bash

curl -s -X POST “http://192.168.178.26:8087/api/v2/query?org=my_organisation” 
-H “Authorization: Token 7topsecrettoken==” 
-H “Content-Type: application/vnd.flux” 
–data ’
from(bucket:“openHAB_history”)
|> range(start: -365d)
|> filter(fn:(r)=>
r[“item”] == “Gaszaehlerstand” or
r[“item”] == “Stromzaehler_kWh” or
)
|> filter(fn:(r)=> r[“_field”] == “value”)
|> difference(nonNegative: true)
|> sum()
|> group(columns: [“item”])
|> keep(columns: [“item”,“_value”])
’

```
