NB: This documentation page is a work-in-progress at the moment of writing. The ESPhome section still needs to be written in a beginner-friendly way. However, experienced ESPHome users should be able to figure the configuration out themselves using [the ESPhome configuration available in the P1 logger git repo](https://git.hollander.online/energy/p1-logger/src/branch/main/esphome) and the details provided below.
1. This add-on requires a PostgreSQL database, optionally with TimescaleDB support. In this example, we'll Expaso's TimescaleDB add-on in order to store data.
After a few seconds, the TimescaleDB add-on should appear in the add-on store. Install it.
After installing TimescaleDB, go to Configuration. Click the three dots in the top-right corner and select "Edit in YAML". Then, make the following changes:
TODO: A detailed description on how to setup a P1 reader with ESPHome will follow soon.
For experienced ESPHome users, have a look at [the ESPhome configuration available in the P1 logger git repo](https://git.hollander.online/energy/p1-logger/src/branch/main/esphome).
**Add this `on_value` function to the *last*`dsmr` sensor that is defined. In this case, `power_returned_l3`.** Additionally, make sure that all `id`'s referenced in this function are defined within the sensors above this last one. Adjust the function as needed by e.g. removing L2 and L3 for single phase connections, removing gas when not applicable or renaming `id`'s when this suits your current setup better.
Having setup the PostgreSQL / TimescaleDB database and Mosquitto MQTT broker, we can now install and configure P1 Logger. Add the [add-on repository](https://git.hollander.online/energy/home-assistant-addons) using the [instructions](https://git.hollander.online/energy/home-assistant-addons) provided. Then, click "Install" to install this add-on. Go to "Configuration".
- In `tz`, enter your timezone. The default is "Europe/Amsterdam". If you are in a different location, choose your timezone from [this list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).
- Optionally, if you don't want to use TimescaleDB, disable `timescaledb`.
Check the "Log" page. If the setup is succesfull, it should contain a message stating: `"level":"INFO","msg":"Connected to MQTT broker, subscribing to topic...","topic":"p1/metrics"`.
From the Home Assistant Community Add-ons repository, install Grafana. Click "Start" to start the add-on and enable "Show in sidebar". Grafana will now appear in the sidebar. Open it.
- In the top-left corner, click the three bars (open menu) -> Connections.
- Using the search box, enter `PostgreSQL`. Click the resulting "PostgreSQL".
- In the top-right corner, click "Add new data source"
- Use the following settings
- Name: `p1_logger`
- Host URL: `77b2833f-timescaledb`
- Database name: `p1_logger`
- Username: `postgres`
- Password: `homeassistant`
- Version: `16` or the closest version to it.
- TimescaleDB: Toggle the switch to enable TimescaleDB support.
- Click "Save and Test". A "Database Connection OK" message should appear.
- In the top-right corner, click the `+` sign, "Import dashboard".
- Go to <https://git.hollander.online/energy/p1-logger/src/branch/main/grafana>
- In this folder, a number of sample dashboards is available.
Using the aforementioned steps, you should now have a working P1 Logger setup. However, it is important to keep your data safe. [Expaso recommends](https://github.com/Expaso/hassos-addons/tree/master/timescaledb#usage) changing the default postgres `homeassistant` password. I recommend following their recommendation and also installing the pgAdmin4 add-on using the [instructions](https://github.com/Expaso/hassos-addons/tree/master/pgadmin4) they provide. In case you're doing this after setting up P1 Logger, remember to also update this password in the P1 Logger config and the Grafana data source connection settings.
If you'd like to provide feedback about this project, or in case you'd like to ask questions, please refer to [this page](https://pieterhollander.nl/author/pieter-hollander/) for contact information (e-mail, Github or LinkedIn), or use the [contact form](https://pieterhollander.nl/#contact) on my website.