Skip to content

Commit

Permalink
Add filters for reducing amount of data output (#95)
Browse files Browse the repository at this point in the history
* Add filters for reducing amount of data output

This change adds commented-out samples of how to use filters to reduce the amount of data that are written to the HA recorder database by default.

Depending on the `pulse_rate` variable, the type of house/apartment and the heating system in use, this may or may not be a problem in practice. For example, with the default in the file, `1000`, a power consumption of 3600 W means that the sensors produce 2 HA state changes per second (which means 7200 state changes per hour). With the commented-out filters enabled, only 396 state changes will be produced per hour.

* Add documentation to README.md

* Reference README.md from home_assistant_glow.yaml

* Change kWh sensor granularity to 0.01

* Use `on_raw_value` instead of `on_value`

* Filter out NaN from Power Consumption sensor

* Fix typos in URLs, update `pulse_rate` -> `pulse rate`

* Remote blank line

---------

Co-authored-by: Klaas Schoute <[email protected]>
  • Loading branch information
slovdahl and klaasnicolaas authored May 14, 2023
1 parent 49c8cad commit b2a3f9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ A number of users have reported receiving the recommended diode board from vario

The large triangular part of the diode, should be soldered to the positive side of the board not the negative. If yours is orientated as above, you should desolder the photodiode invert it and resolder so the larger triangular part of the diode is connected to positive.

### Reduce the amount of data the sensors produce

Depending on the configured `pulse rate`, the type of house/apartment and the heating system in use, the sensors that are exposed to Home Assistant may produce a lot of data. For example, with the default `pulse rate` 1000, a power consumption of 3600 W means that the sensors produce 2 HA state changes per second (which means 7200 state changes per hour). If you don't need that kind of granularity, you can use [ESPHome sensor filters](https://esphome.io/components/sensor/index.html#sensor-filters) to reduce the rate of updates written to Home Assistant. With the commented-out filters in the [home_assistant_glow.yaml][file] enabled, only 396 state changes will be produced per hour.

### My Daily Energy won't reset

Issue: [#140][issue_140]
Expand Down
22 changes: 18 additions & 4 deletions home_assistant_glow.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# Home Assistant Glow
#
# Read your electricity meter by means of the pulse LED on your
# Read your electricity meter by means of the pulse LED on your
# meter, useful if you do not have a serial port (P1).
# © Klaas Schoute
#
Expand Down Expand Up @@ -176,17 +176,24 @@ sensor:
accuracy_decimals: 0
pin: ${pulse_pin}
# internal_filter: 100ms
on_value:
on_raw_value:
then:
- light.turn_on:
id: led_red
- delay: 0.5s
- delay: 0.2s
- light.turn_off:
id: led_red
filters:
# multiply value = (60 / imp value) * 1000
# - multiply: 60
- lambda: return x * ((60.0 / id(select_pulse_rate).state) * 1000.0);

# Update the sensor with an average every 10th second. See
# https://github.com/klaasnicolaas/home-assistant-glow/#reduce-the-amount-of-data-the-sensors-produce
# for more information.
#- throttle_average: 10s
#- filter_out: NaN

total:
name: '${friendly_name} - Total Energy'
id: sensor_total_energy
Expand All @@ -199,7 +206,14 @@ sensor:
# multiply value = 1 / imp value
# - multiply: 0.001
- lambda: return x * (1.0 / id(select_pulse_rate).state);
# Total day useage

# Update the sensor once per 0.1 kWh consumed, or every 5th minute, whichever happens sooner.
# See https://github.com/klaasnicolaas/home-assistant-glow/#reduce-the-amount-of-data-the-sensors-produce
# for more information.
#- delta: 0.01
#- heartbeat: 300s

# Total day usage
- platform: total_daily_energy
name: '${friendly_name} - Daily Energy'
id: sensor_total_daily_energy
Expand Down

0 comments on commit b2a3f9a

Please sign in to comment.