psvanstrom / esphome-p1reader

ESPHome custom component for reading P1 data from electricity meters.
MIT License
251 stars 106 forks source link

Investigate failsafe for incrementing sensors #38

Open endor-force opened 2 years ago

endor-force commented 2 years ago

Yesterday i discovered a peak of ~3500kwh during one hour. It turns out that the sensor value received or parsed in to home assistant was 0 and then the following state was ~3500kwh from the cumulative active import sensor. This caused the strange error of the usage data in electricity sensor in home assistant. Needed to clean up and fix values in states and statistics table in home assistant to correct the problem.

Check if failsafe can be added i.e. do not send sensor value if it is null or 0 to avoid this error.

newlund commented 3 months ago

I also have this problem. To avoid this I have now added a filter section to the sensor I use to track total energy consumption.

sensors:
  - name: "Cumulative Active Import"
    unit_of_measurement: kWh
    accuracy_decimals: 2
    state_class: "total_increasing"
    device_class: "energy"
    filters:
    - filter_out: 0.00

Don't know if it will work but worth a try... Make sure correct number of decimals are specified. I have data with two decimals so I filter out 0.00