Group energy demand by daytime and nighttime (sunrise/sunset-based)

Hi guys,

I struggle with my data formatting as described below. It’s about summarising energy demand during day- and nighttime (see “What”).

  • What Grafana version and what operating system are you using?
    Grafana v9.3.2, runs on a RPi 4 in combination w/ InfluxDB v1.8.10

  • What are you trying to achieve?
    Basically, I track continuously (10s raster) the energy consumption to derive the best-fitting battery size (based on the data) that covers my energy consumption during the night.
    Therefore, I would like to group my time series by two different intervals, representing day- and nighttime. In theory, I want to “group by” intervals (1) from sunrise to sunset and (2) from sunset to sunrise dynamically.
    A more “static” approach would be fine as well e.g., fixed intervals (1) from 8am to 5pm and (2) 5pm to 8am.

  • How are you trying to achieve it?
    See config below.

  • Can you copy/paste the configuration(s) that you are having problems with?

    SELECT difference(last("Energy_Demand")) FROM "smartMeter" WHERE $timeFilter GROUP BY time(12h,5h)
    

This configuration works only, in case I use 12h/12h intervals (I also know how to shift them).
Any idea, how it works with 15h/9h interval from (1) 8am to 5pm and (2) 5pm to 8am?