Hi @ew-ewim, you are correct, I’ve no history in HA itself. At that time I didn’t know anything about input_numbers
So I used InfluxDB 2.0 for that. All HA values that I want to grep, are sent to the influxDB.
InfluxDB is an efficient system to store time series data : https://www.influxdata.com/
And I did the quarterhour query inside InfluxDB.
The HA configuration to send the data from HA to InfluxDB:
# move long living data to the influxDB
influxdb:
api_version: 2
ssl: false
host: localhost
port: 8086
token: YourToken
organization: YourOrganization
bucket: homeassistant
tags:
source: HA
tags_attributes:
- friendly_name
precision: ms
default_measurement: units
exclude:
entity_globs:
- sensor.nmbs_*
- sensor.recycleapp*
- sensor.br*
entities:
- sensor.last_boot
- sensor.date
- sensor.time
- sensor.time_utc
- sensor.worldclock_sensor
- sensor.dayoftheweek
- sensor.date_long
- sensor.date_time
- sensor.internet_time
- sensor.moon
- sensor.moon_phases
- sensor.nmbs
- sensor.hacs
- sensor.distance_sensor_1_1
- sensor.distance_sensor_2_1
domains:
- persistent_notification
- person
include:
entities:
- weather.home
domains:
- sensor
- binary_sensor
I’m using InfluxDB also for the graphical output. Others are using Grafana. Grafana should give more possibilities for the graphics, but I didn’t test it yet.
This is mine InfluxDB configuration/query:
maxAverageQuarterHourData = from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] == "Gemiddeld piekvermogen per kwartier")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["_measurement"] == "kW")
|> aggregateWindow(every: 15m, fn: max, createEmpty: false)
|> yield(name: "maxAverageQuarterHour")
maxMonthData = maxAverageQuarterHourData
|> aggregateWindow(every: 1mo, fn: max, createEmpty: false)
|> yield(name: "maxMonth")
maxMonthData
|> aggregateWindow(every: 1y, fn: mean, createEmpty: false)
|> yield(name: "averageYear")
Because I’m also logging in InfluxDB the raw value of the consumption power, I can also directly calculate or query this raw value of the power
averageQuarterHourData = from(bucket: "homeassistant")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] == "Grid afname")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["_measurement"] == "W")
|> aggregateWindow(every: 15m, fn: mean, createEmpty: false)
|> yield(name: "averageQuarterHour")
maxMonthData = averageQuarterHourData
|> aggregateWindow(every: 1mo, fn: max, createEmpty: false)
|> yield(name: "maxMonth")
maxMonthData
|> aggregateWindow(every: 1y, fn: mean, createEmpty: false)
|> yield(name: "averageYear")
The two graph results are quasi equal to each other.
There are differences that I cannot always explain, but probably it is due to a reboot of my NAS (I’m running HA in a virtual environment), a reboot of HA itself after the installation of a new version, sometimes the connection between HA and InfluxDB is broken (InfluxDB is running in another virtual system), etc…
I’ve now running the 3 solutions next to each other fore one month and for November I can say that the peak is identical for the three.