Skip to main content

Monitoring whole home energy usage

How it started

For over 2 years now I've been using a few Tapo P110M energy monitors from TP-Link in my office/ homelab. I first started using them as a way to remotely turn my PC on as I hadn't yet learnt about wake on lan. I had my PC bios set to turn on when ever power came back on. They also let me see if my PC was actually running or not when I was away from home and wanted to useremote RDP.in.

Eventually when I got my servers for my homelab I used the P110M's as a way to make sure I want overloading the power strip attached to the wall socket. As well as a way to measure how much the servers were costing me in electricity. And for a whole this worked fine I could track energy usage for my servers and my PC and make sure things where running when I was away from home.

But I wanted a way to track my whole houses usage not just specific devises. Since I'm in a rental I cant just call an electrician to make modifications to the meter box so iI had to find a "non intrusiveintrusive" way about it.

After doing some quick research online I found that most smart meters have an led that pulses at the rate that electricity is being consumed. And sure enough so did my meter. After talking to some coworkers and doing some more research I decidedecided to use an ESP32 and somea kindLDR ofthat lightI detector and link itlinked to home assistant which I was already running.

I ended up combining the scrips and ideas from both of these projects:

https://esphome.io/cookbook/power_meter/

https://tristam.ie/2023/858/

And forFor hardware I used an ESP32-S3 and an Arduino LDR module both from Jaycar.

IMG_12111.HEICIMG_12101.HEICThe ESPHome code used for this project:

sensor:
  - platform: pulse_counter
    pin: GPIO4

    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    unit_of_measurement: 'kW'
    device_class: power #This is important
    name: 'Current Grid Consumption'
    filters:
      - multiply: 0.06  # (60s/1000 pulses per kWh)

Meter with hardwareMeter Box

Since this was a bit of a proof of concept I ended up being a bit lazy with how to power it but I full intend to find a better solution eventually,eventually. orI ended up using a USB over Ethernet adapters and a long Ethernet cable just to send power to the ESP in the meter box.

Power 2Power 1


Finding the cost

Once the hardware was set up the next part was getting home assistant to use this new data It was collecting. Initially this was difficult as I didn't really under stand how HA energy metering system worked. But after setting up a system that kinda didn't work I eventually found the correct way to do it.

At first I created an automation that set a number helper to the cost depending on the time of day and assigned that number as the cost in the Electricity grid section. But for some reason the cost never changed and stayed at leastzero. before

we

The haveproper way to replaceset outit gas.up was to create a utility meter helper and name tariffs i.e peak, off peak and shoulder. Then use automation to set the tariff meter to the different tariffs depending on the time of day. Then in the electricity grid section you add all the tariffs separately including the current grid consumption. That way the cost and usage of each tariff is separated and you just assign the cost per KWh in the grid connections section. 


image.png

The original system I set up that changed the tariff cost depending on the time off day I ended up keeping as it lets me see the current cost per KWh and a time line of when the tariffs are.

image.png

image.png