Skip to content

Commit

Permalink
Update ESPHome firmware customization documentation (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas authored Mar 23, 2024
1 parent c60cbfa commit 452d591
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 46 deletions.
21 changes: 4 additions & 17 deletions components/pulse_meter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ number:
button:
# Reset the total energy entity
- platform: template
name: "Reset - Total Energy"
id: button_reset_total
name: "Reset - Total Energy"
on_press:
- pulse_meter.set_total_pulses:
id: sensor_energy_pulse_meter
Expand All @@ -46,15 +46,14 @@ button:
sensor:
# Pulse meter
- platform: pulse_meter
name: '${friendly_name} - Power Consumption'
id: sensor_energy_pulse_meter
name: '${friendly_name} - Power Consumption'
unit_of_measurement: W
state_class: measurement
device_class: power
icon: mdi:flash-outline
accuracy_decimals: 0
pin: ${pulse_pin}
# internal_filter: 100ms
on_raw_value:
then:
- light.turn_on:
Expand All @@ -67,15 +66,9 @@ sensor:
# - 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
name: '${friendly_name} - Total Energy'
unit_of_measurement: kWh
icon: mdi:circle-slice-3
state_class: total_increasing
Expand All @@ -86,16 +79,10 @@ sensor:
# - multiply: 0.001
- lambda: return x * (1.0 / id(select_pulse_rate).state);

# 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
name: '${friendly_name} - Daily Energy'
power_id: sensor_energy_pulse_meter
unit_of_measurement: kWh
icon: mdi:circle-slice-3
Expand Down
30 changes: 28 additions & 2 deletions docs/docs/advanced/firmware_customization.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: firmware_customization
title: Customizing the Firmware
title: Customizing the firmware
description: How to adopt and customize the firmware for your own needs.
---

Expand Down Expand Up @@ -36,4 +36,30 @@ three components, all of which are included in the base config:
- `pulse_meter.yaml`: Entities related to the pulse meter
- `status_led.yaml`: Entities related to the status LED

You can see the source for all the components [here](https://github.com/klaasnicolaas/home-assistant-glow/tree/main/components).
All of these components can be found on the [GitHub repository](https://github.com/klaasnicolaas/home-assistant-glow/tree/main/components).

## Make customizations

After adopting the device, you can make customizations to the firmware by editing the YAML
files. You can do this by clicking the **EDIT** button in the ESPHome dashboard. This will open
the YAML editor, where you can make changes to the configuration.

<p align="left">
<img src={require('@site/static/img/customization/edit-device.png').default} />
</p>

When you open the YAML editor you will see a minimal configuration of your Home Assistant Glow,
if you want to make adjustments to, e.g., the [pulse_meter] component then the best way
is to use an [!extend].

```yaml title="your_glow_config.yaml"
sensor:
- id: !extend sensor_energy_pulse_meter
internal_filter: 100ms
```
With the above example you will add an [internal_filter], which can be useful if high power values are measured.
[internal_filter]: https://esphome.io/components/sensor/pulse_counter.html?highlight=internal_filter
[pulse_meter]: https://esphome.io/components/sensor/pulse_counter.html
[!extend]: https://esphome.io/guides/configuration-types.html#extend
35 changes: 13 additions & 22 deletions docs/docs/faq/faq_nr2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,30 @@ description: How to reduce the amount of sensor data

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** of `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][filters] to reduce the rate of updates written to Home Assistant. With the commented-out filters in the [pulse_meter.yaml][file] enabled, only 396 state changes will be produced per hour. You can read more about making YAML adjustments on the [customizing the Firmware](/docs/advanced/firmware_customization.mdx) page.
If you don't need that kind of granularity, you can use [ESPHome sensor filters][filters] to reduce the rate of updates written to Home Assistant. This can be done by adding the following YAML code at the bottom of your Home Assistant Glow configuration file:

### Pulse meter - power sensor

```yaml title="components/pulse_meter.yaml"
```yaml title="your_glow_config.yaml"
sensor:
- platform: pulse_meter
# ...
- id: !extend sensor_energy_pulse_meter
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
- throttle_average: 10s
- filter_out: NaN
```
### Pulse meter - total energy sensor
```yaml title="components/pulse_meter.yaml"
sensor:
- platform: total_daily_energy
# ...
- id: !extend sensor_total_daily_energy
filters:
# multiply value = 1 / imp value
# - multiply: 0.001
- lambda: return x * (1.0 / id(select_pulse_rate).state);

# Update the sensor once per 0.1 kWh consumed, or every 5th minute, whichever happens sooner.
- delta: 0.01
- heartbeat: 300s
```
After applying the filters, only 396 state changes will be produced per hour. You can read more about making YAML adjustments on the [customizing the firmware](/docs/advanced/firmware_customization.mdx) page.
## Related topics
- [ESPHome sensor filters][filters]
- [ESPHome pulse meter](https://esphome.io/components/sensor/pulse_meter.html)
- [ESPHome total daily energy sensor](https://esphome.io/components/sensor/total_daily_energy.html)
- [Customizing the firmware](/docs/advanced/firmware_customization.mdx)
[filters]: https://esphome.io/components/sensor/index.html#sensor-filters
[file]: https://github.com/klaasnicolaas/home-assistant-glow/blob/main/components/pulse_meter.yaml#L73
14 changes: 9 additions & 5 deletions docs/docs/faq/faq_nr7.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ description: Sudden increase in consumption after a period of zero readings

Linked issue: [#274][issue_274]

If you have a solar system, and the consumption remains zero for some time and then gets a value from the sensor, you may see an abrupt increase in the total daily energy sensor value that doesn't match the actual consumption.
If you have a solar system, and the consumption remains zero for some time and then gets a value from the sensor, you may see an abrupt increase in the total daily energy sensor value that doesn't match the actual consumption.

## What to do?

In your ESP config file, use the `left` [calculation method][method] instead of the default (`right`):
Try to use the `left` [calculation method][method] instead of the default (`right`). You can do this by editing your ESPHome device and add the following configuration at the bottom of your YAML file:

```yaml title="components/pulse_meter.yaml"
```yaml title="your_glow_config.yaml"
sensor:
- platform: total_daily_energy
# ...
- id: !extend sensor_total_daily_energy
method: left
```
## Related topics
- [ESPHome total daily energy sensor][method]
- [Customizing the firmware](/docs/advanced/firmware_customization.mdx)
[method]: https://esphome.io/components/sensor/total_daily_energy.html
[issue_274]: https://github.com/klaasnicolaas/home-assistant-glow/issues/274
Binary file added docs/static/img/customization/edit-device.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 452d591

Please sign in to comment.