For a while now I have been storing data from my utility meter into an Influx database locally. This allows me to have a look at the energy consumption in the house. Thing is, I hardly ever look at it. I am pretty tech savvy, but querying a database is just not fun. So, I made a dashboard to visualize the data using Grafana.

Quick video explaining how to import this dashboard into Grafana to visualise energy consumption

Infrastructure setup

Infrastructure/Platform setup
To get the data into a database, I have connected the P1 port from the utility meter to a USB port on an Intel NUC. The NUC is running Ubuntu Server with Home Assistant on top (HAssIO). Within HassIO there are two add-ons availabe that can be used for this: InfluxDB to store the data generated by Home Assistant, and Grafana as a way to query and visualize the data from the database. Although I am not using those add-ons myself; I have setup a separate docker-compose stack with these containers in them, amongst other things. The add-ons are definitely the easiest way to go though.

Home Assistant setup

With the InfluxDB add-on, all data generated by Home Assistant is stored into the database (filters can be applied). This means, sensor readings, state changes, etc. So, as long as the data from the smart meter is available in Home Assistant, it will be stored in InfluxDB.

DSMR component

Using the DSMR component in HA will make the data from the utility meter available. The documentation page does a good job of showing how to set that up for your setup. This is my config:

sensor:
  - platform: dsmr
    port: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AIRSXJI-if00-port0
    dsmr_version: 4

group:
  meter_readings:
    name: Meter readings
    entities:
      - sensor.power_consumption_low
      - sensor.power_consumption_normal
      - sensor.gas_consumption

Note 1: the port: section is a reference to the USB device connecting the utility meter to the computer and is (very likely) different from what’s shown here

Note 2: I have no sensors setup to show energy produced as I do not have solar panels, but the DSMR component does provide those.

Note 3: Although I have not explicitly set the sensor up, I have got an entity named sensor.hourly_gas_consumption. I guess this is part of the DSMR4 protocol. The sensor estimates the rate of gas consumption per hour.

Utility Meter component (optional)

With this set up, the data the from the utility meter is stored in the InfluxDB. I have setup a few additional sensors to show the daily total consumed energy in home assistant using the utility_meter component. Not necessary for the visualisation using Grafana, but handy to have present in Home Assistant for added awareness. I have one for peak electricity used, one for off-peak electricity used and one for gas consumption. The utility_meter component takes one of the DSMR sensors as input and keeps track of the cumulative use over a user-specified timeframe. Again, use the docs to read about setup options, but here is mine:

utility_meter:
  daily_power_used_peak:
    source: sensor.power_consumption_normal
    cycle: daily
  daily_power_used_offpeak:
    source: sensor.power_consumption_low
    cycle: daily
  daily_gas:
    source: sensor.gas_consumption
    cycle: daily

Grafana: visualise the data

So now, data on our energy consumption (gas and electricity) is continuously flowing into the database which means it can be queried and the results visualised. My dashboard uses gauges to show current (near realtime) information for electricity usage and gas usage. Lines and bar graphs are used to show historical data for the past hour as well as the past week where stacked bars show the combined total energy usage of peak and off-peak electricity usage.

If you setup the same sensor names as I have, you can directly import the JSON for the dashboard into your own setup from this Gitlab repository. (Raw file here). You will be asked to specify what database to use as a source if your database is named differently than mine.