Reporting average value once evey 10 minutes

I’m measuring a solar system through esp32. It makes about 20000 counts to catch transients and reports to hassio every 5 seconds. Entities are: battery load, solar load, battery voltage and solar voltage.
Since that’s 4 values logging every 5 seconds, the database grows fast over days.

I’d like something like an average 10 minute value for each entity, reporting ONCE every 10 minutes. These values would be logged in history, while original entities would be excluded from history recorder.

I searched something like that in forums but the amount of data cracked my non programmer brain :smiley:
I made a statistics sensor for battery load entity, it averages through last 10min, but still reports every 5 seconds…

there is an “statistics” sensor built-in or “average” custom integration.

ESP32 using ESP-Home?

In that case you can use a filter

nah, it’s a direct string to serial port. then it’s chopped in 4 values
like this:

  - platform: serial
    serial_port: /dev/ttyUSB0
    baudrate: 9600

    - name: Battery Voltage
      unique_id: bv
      unit_of_measurement: "V"
      state: "{{ states('sensor.serial_sensor').split(',')[0] | float(default=0) }}"
    - name: Battery Load
      unique_id: ba
      unit_of_measurement: "A"
      state: "{{ states('sensor.serial_sensor').split(',')[2] | float(default=0) }}"
    - name: Solar Voltage
      unique_id: sv
      unit_of_measurement: "V"
      state: "{{ states('sensor.serial_sensor').split(',')[1] | float(default=0) }}"
    - name: Solar Load
      unique_id: sa
      unit_of_measurement: "A"
      state: "{{ states('sensor.serial_sensor').split(',')[3] | float(default=0) }}"

I kinda managed like this:

- platform: filter
    name: Battery load avg
    entity_id: sensor.battery_load
      - filter: time_simple_moving_average
        window_size: "00:05"
      - filter: throttle
        window_size: 120

It measures average of last 5 min and gives a value once avery 10min.
If it measures average of last 10min, the output is to lazy.
It’s good for now :slight_smile: