Add preliminary ESPHome setup steps.

This commit is contained in:
Pieter Hollander 2024-07-26 20:52:47 +02:00
parent 41afb4bcff
commit ee6e870a5f
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -83,7 +83,42 @@ Save the configuration, go to the "Info" tab and start TimescaleDB.
### ESPHome setup
TODO
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).
Line 225 contains the following code snippet:
```yml
on_value:
- mqtt.publish_json:
topic: p1/metrics
payload: |-
root["t"] = id(dsmr_timestamp).state;
root["dt1"] = id(energy_delivered_tariff1).state * 1000;
root["dt2"] = id(energy_delivered_tariff2).state * 1000;
root["rt1"] = id(energy_returned_tariff1).state * 1000;
root["rt2"] = id(energy_returned_tariff2).state * 1000;
root["d"] = id(power_delivered).state * 1000;
root["r"] = id(power_returned).state * 1000;
root["f"] = id(electricity_failures).state;
root["fl"] = id(electricity_long_failures).state;
root["g"] = id(gas_delivered).state * 1000;
root["v1"] = id(voltage_l1).state;
root["v2"] = id(voltage_l2).state;
root["v3"] = id(voltage_l3).state;
root["c1"] = id(current_l1).state;
root["c2"] = id(current_l2).state;
root["c3"] = id(current_l3).state;
root["d1"] = id(power_delivered_l1).state * 1000;
root["d2"] = id(power_delivered_l2).state * 1000;
root["d3"] = id(power_delivered_l3).state * 1000;
root["r1"] = id(power_returned_l1).state * 1000;
root["r2"] = id(power_returned_l2).state * 1000;
root["r3"] = id(power_returned_l3).state * 1000;
```
**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.
### Setting up P1 Logger