Energy monitoring with home assistant

Dave Ahern
6 min readDec 31, 2023

--

If you live in Ireland like me and have ever tried to predict your electrical bills you will know how absurdly difficult it can be. Energy companies here often claim they provide user friendly energy monitoring, however, once you look under the hood it becomes clear that this claim is for the most part, untrue.

The ESB (Electricity Supply Board) does provide a utility for downloading your energy usage in a CSV format, however, this is either a manual task or you will have to create scripts to automate the pulling and parsing of the data as well as processing the tariff information. On top of all this you need a smart meter enabled for the data to be collected in the first place.

Another option is to use smart plugs with energy monitoring enabled. Tapo smart plugs have this feature. This does work to an extent however, you will not be able to monitor some of the more resource intensive utilities in your house such as a heat pump which usually require a direct line to your electricity rather than a plug so accurately predicting your bills can be impossible using this method alone.

A workable solution

Admittedly, this solution involves investing a small amount of money to purchase a piece of hardware. The hardware is provided by a company called Frient and can be found on Amazon at this link. Once you have this piece of hardware, installation is straightforward as long as you have access to your energy meter. No modifications are required to the energy meter.

I was curious about how this would actually monitor anything, so I did a bit of research into energy meters. Apparently, on most meters, there is a flash of light emitted every time a unit of energy is used within the house. The Frient monitor simply observes this flash of light and can then communicate these readings with Home Assistant over Zigbee.”

The advantage of this is that because the energy meter is usually the single source of truth for all the energy usage in the house, we can monitor this one location to get an accurate reading. We also don’t have to waste much money buying multiple devices for each power outlet, or spend much time writing scripts. For me, the entire installation took about 30 minutes.

Home assistant dashboard

As long as your Home Assistant has Zigbee monitoring enabled, the device should automatically be detected. If you do not have a Zigbee-enabled Home Assistant, you will need to buy an extra device to enable this communication. I am using a SONOFF Universal Zigbee 3.0 USB.

Setting up tariffs

Each electricity company may have different tariffs for energy usage. For example, I have a smart energy meter with 3 tariffs for day, night, and peak. To create a tariff for each, you will need to head over to Settings -> Devices and Services, then click the Helpers tab. Click the ‘Create Helper’ button and select the ‘Date and Time’ option.

Let’s begin by naming your first tariff, starting with the day tariff. I chose the name ‘Tariff day.’ Select ‘Time’ as the input and click on the ‘Create’ button. Repeat this process for each of your tariffs — I personally have four tariffs.”

You can then add these to a new dashboard for easy editing of the tariff times. If you have not created a new dashboard before then head to Settings -> Dashboards, then click the add dashboard button and give it a name. Next, head to the created dashboard in the left-hand menu. Click the edit button, then click the add card button and select the entities card. Next, add each of the tariffs created in the previous section and provide the correct times.

Please note the reason I have 4 tariffs instead of 3 is because the day tariff starts at 08:00 then switches to the peak tariff at 17:00 to 19:00 then switches back to the day tariff until 23:00 which is when the night tariff commences. I could not see a way to do this with just 3 tariffs.

Setting up utility meters

With the tariffs in place we now need to assign a price point to each one, again this will vary depending on your electricity provider so make sure you have the correct information from your provider.

Head over to Settings -> Devices and services, select the helpers tab and click the create helper button. This time select the Utility Meter option

Add the following data to the form making sure to provide the correct supported tariffs.

Home Assistant needs to know which tariff to use during the day. For this we need to setup an automation that will switch to the correct tariff as the day progresses. Head over to Settings -> Automations & Scenes, then click the Automations tab. Click the Create Automation button. Once in the automation creation screen switch to the YAML editor but clicking the 3 dots in the top right and select edit in YAML. Provide the following YAML and click save.

alias: "Energy: Tariffs"
description: ""
trigger:
- platform: time
at: input_datetime.tariff_day
variables:
tariff: Tariff day
- platform: time
at: input_datetime.tariff_peak
variables:
tariff: Tariff peak
- platform: time
at: input_datetime.tariff_day_2
variables:
tariff: Tariff day - 2
- platform: time
at: input_datetime.tariff_night
variables:
tariff: Tariff night
action:
- service: select.select_option
target:
entity_id: select.energy_grid_import
data:
option: "{{ tariff }}"
mode: single

This YAML file will create the following automation.

Finally we need to configure the price of each tariff. To do this head over over to Settings -> Dashboards -> Energy. Click the add consumption button. and add a tariff and static price for each of the tariffs. For example, for the day tariff we provide the following information.

When complete we should have a list that looks like this

View the data

Once everything is setup correctly head over to Energy dashboard. I should also note that the data may take a few hours to show up so don’t be discouraged if nothing shows up immediately. Once the data starts rolling in your screen should appear like this with the grid total displaying an amount in currency as well as a nice chart showing what times of the day we were using the most energy.

Disclaimer

Please note that this method will estimate only raw energy usage. It does not account for any standing charges your provider might have nor any carbon tax fees.

Conclusion

I have this running for just over a month at the time of writing. So far everything is going well. I was also curious how accurate the readings were so I compared it to the ESB readings from our provider and I was very happy see that the numbers correlated almost exactly with the actual readings.

Thank you for taking the time to read this write up and I hope it helps you in your home automation journey.

--

--