Measuring your home's electricity consumption with Home Assistant
In this document we will see the necessary steps to be able to measure the electricity consumption of our homes, at the second level and with historical consumption graphs. All this from Home Assistant and ESPHome! ¡Easy, simple, and, for the whole family!
Of course,, thanks to a board with an ESP32 or ESP8266 microcontroller and a PZEM energy meter-004T V3 we will be able to know in a moment the electrical consumption of a neutral cable (blue), usually the General of the house, The fat guy. the more comfortable it will be, as always install the ESPHome firmware on the board and this is how we manage it from Home Assistant, Native and centralized.
After installing ESPHome firmware, I leave you the configuration that we should add to be able to read the current, Voltage, Energy, The power, Frequency and power factor… We must take into account that we will power the PZEM device-004T V3 with a 5v cable + the corresponding GND cable from the board, in addition to correctly connecting the serial port, the Rx and Tx.
And I leave you what would be the configuration that we should add to the board in ESPHome:
Uart: rx_pin: GPIO3 tx_pin: GPIO1 baud_rate: 9600 Modbus: sensor: - Platform: Pzemac Current: Name: "PZEM-004T V3 Current" Voltage: Name: "PZEM-004T V3 Voltage" energy: Name: "PZEM-004T V3 Energy" Power: Name: "PZEM-004T V3 Power" frequency: Name: "PZEM-004T V3 Frequency" power_factor: Name: "PZEM-004T V3 Power Factor" update_interval: 1s
After saving your changes to the board, in Home Assistant we will already get the entities that we have just created! so we can add them and see them in an Entities card that will show us little more than the 'current' data. But as always we can make other cards, for example to analyze consumption.
To see real-time electricity consumption, with soft drink 1 second, The last 5 minutes:
type: Custom:Apexcharts-Card Header: show: true title: Home Consumption - 5Min show_states: True Series: - entity: sensor.pzem_004t_v3_power name: PVPC type: Area Opacity: 0.7 colour: graph_span Network: 5Min update_interval: 1s
If we want, We can utility_meter create entities that will measure our consumption by the hour, daily, monthly, annual… and then see it in graphs if we are interested. To do this,, in our 'configuration.yaml'’ We should add something like:
utility_meter: ... energy_consumo_hogar_horario: Name: "Electricity - Home Consumption - Timetable" Source: sensor.energy_pzem_004t_v3_hogar cycle: hourly energy_consumo_hogar_diario: Name: "Electricity - Home Consumption - Daily" Source: sensor.energy_pzem_004t_v3_hogar cycle: daily energy_consumo_hogar_mensual: Name: "Electricity - Home Consumption - Monthly" Source: sensor.energy_pzem_004t_v3_hogar cycle: monthly energy_consumo_hogar_anual: Name: "Electricity - Home Consumption - Annual" Source: sensor.energy_pzem_004t_v3_hogar cycle: yearly ...
And after saving and reloading the Home Assistant settings we could, for example, create this bar graph, the last 24h, we added it as a new card in our GUI:
type: Custom:Apexcharts-Card Header: show: true title: Electricity consumption - Last 24h show_states: false series: - entity: sensor.electricidad_consumo_hogar_horario name: kWh type: column opacity: 0.7 colour: group_by Network: Duration: 1h func: Max Yaxis: - min: 0 graph_span: 24h update_interval: 5min
And if we want a card to see the evolution of the last year:
type: Custom:Apexcharts-Card Header: show: true title: Electricity consumption - Final year show_states: True Series: - entity: sensor.electricidad_consumo_hogar_mensual name: kWh type: column opacity: 0.7 colour: group_by Network: Duration: 30d func: Max graph_span: 365d update_interval: 5min
So as we can see, it is apparently simple to obtain the electricity consumption of the home, as well as cheap, we will obtain reliable data with which we can work or call automations, to warn us of high consumption, etc… We can also use it in the Energy panel, or calculate the cost in euros of the next invoice…
As usual, A hug, I hope you are interested in certain posts and thank those of you who move these contents through social networks, to take care of yourself!