Skip to content

A non-invasive Power Meter Device that can track both Power Consumption and Costs

License

Notifications You must be signed in to change notification settings

CasperJoergensen/esphome-power-meter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

ESPHome Power Meter

A Power Meter for use in Home Assistant, using the Pulse Meter component in ESPHome, with the added functionally of tracking costs.

I've used Home Assistant Glow for a while without problems. I decided that it would be cool to also have the ESP track costs as well. That way I could do away with Rieman Sum and Utility Meter integrations in HA. This is the result of having that initial idea and a lot of hammering on the keyboard.

The kWh price is imported as a sensor from Home Assistant, which is running the Nordpool Custom Component, but the price can also be set 'manually' with a Number component. Ideally the price should be fetched directly from NordPool using their API.

I've added a method to track the Average kWh Price and an option to use it when reporting costs. It will still track the 'real' costs and you can toggle between the two. Remember to push the Reset kWh Price Average button at the start of the billing period.

I have had some weird power spikes (faulty photodiode, it turned out), so I included a Power Problem Level number and a Power Problem Status binary sensor in the ESPHome config. You set the level and subsequently, if power consumption goes over (or equals) the level, the binary sensor will indicate that you have a problem. The history in HA of this sensor was very useful to track the problem I had, so I have left it in.

I have also included a RGB led which, instead of blinking (I do not like blinking LEDs), will indicate power consumption level in relation to the set power problem level. Turn it on, set the brightness and the color will be set automatically at each power pulse.

To test the accuracy of the Power Meter, I created a simple Arduino Sketch to simulate the blinking LED on a 'real' Power Meter. A simple LED blinking at specific intervals to simulate power consumption. You'll find it here. I also disabled the kWh Price sensor import from HA, temporarily in the code, so the price stayed fixed during testing.

Disclaimer

  • This was made just for fun, to see what you could accomplish in an ESPHome configuration, using Globals and Lambdas all over the place.
  • If this was to have any proper value, it should probably be in the form of a ESPHome Custom Component.
  • I take absolutely no responsibility for any suprisingly large electricity bills.

Device Sensors and Configuration

Sensors Configuration

Components

Wiring

LM393 Photodiode module

MODULE ESP32
D0 26
A0 NC
VCC VCC
GND GND

WS2818 LED

LED ESP32
D0 17
VCC VCC
GND GND

About

A non-invasive Power Meter Device that can track both Power Consumption and Costs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published