Time of use electrical power usage calculations


I’m using Grafana with InfluxDb on homeassistant and I’ve managed to create some great visualisations so far.

The one I’m struggling with at the moment is to compute my power usage per time of use (I pay for electricity at different rates depending on the hour of the day).
I have power usage as kW consumed/exported, and I know how to query for the integral per hours:

SELECT integral("value", 1h) FROM "kW" WHERE ("entity_id" = 'powerwall_site_now') AND $timeFilter GROUP BY time(1h) fill(null)

which basically gives me power usage for each hour slot. But I’m not sure then how to filter and sum up in 4 slots:

  • from 00h to 15h
  • from 15h to 16h
  • from 16h to 21h
  • from 21h to 24h

Any pointers? Thanks a lot!

@choumarin this is quite a common use case - and probably one of the most commonly requested Influx features - but it’s unfortunately not possible using InfluxQL. It’s possible with Flux, though. See https://github.com/influxdata/influxdb/issues/6723 - also for more info on the Flux approach.

1 Like

Thanks a lot, I’m going to try to InfluxDb as a Flux datasource then :slight_smile:

This topic was automatically closed after 365 days. New replies are no longer allowed.