Importing rf based Power Cost Monitors (Blueline Power Cost Monitor) Into Home Assistant Energy using RTL_433, SDR, and MQTT

This guide aggregates guides from a bunch of different places on how to connect rf based energy monitors such as the BLI-28000 from Blueline. Keep in mind this does the same thing as Home Assistant Glow but makes use of the old power cost monitors that were given out by certain utilities. They’re still available for purchase on eBay too and have nice weather proof containers.

Start: You will need:

  1. Working HASS install on something with at least 1 USB port
  2. Power cost monitor or similar (the black and decker one is also supported as it is functionally identical)
  3. rf receiver supported by RTL_433, try to get one that has an antenna or has decent sensitivity. You can find this by searching for RTL SDR and look for the one that has a specific Realtek chip, more info on the RTL_433 site

Part 1: Configure RTL_433 to decode your power cost monitor
Setup RTL_433 depending on your system, on windows you will need zadig and the RTL_433 binaries available from the GitHub here : https://github.com/merbanan/rtl_433/releases
Use Zadig to install the winusb drivers (VERY IMPORTANT: MAKE SURE YOU INSTALL THE DRIVERS FOR THE CORRECT DEVICE, if you choose the wrong device zadig will replace the driver for that and it will likely stop working)
On windows you will also need Visual C++ etc. if you get some dll errors
Run the static binary with command -R 176:auto
Push the reset button on the power cost monitor, you should see a bunch of messages with an id number on your screen.
Note the id number, and run the binary again with command -R 176:[your id number]
You should now see a bunch of messages with the gap: value. This is the number of milliseconds it for the meter to use up it’s kh value. For example, with a kh value of 1, you would use this formula to calculate the current power consumption in kilowatts: 3600/gap
From this point out do not reset the monitor as it will also reset the ID. If you intend to use the standalone unit you should have it reset together at this step

Part 2: Setup RTL on HASS with MQTT
You can take your pick of add-on, personally I just used the MQTT add-on in the supervisor and RTL_433 to MQTT add-on here: https://github.com/pbkhrv/rtl_433-hass-addons/tree/main/rtl_433
Install both, if you need a hand at this step, go to each ones respective guides. Of note, do not configure the integration for the MQTT add-on until you are sure the config file is done. I don’t know why but it refuses to work for me unless you add the user and password other than homeassistant and addon before configuring the integration.
Create an RTL_433 conf file, you can see examples on the GitHub and instructions on the RTL_433 to MQTT add-on page. MOst importantly make sure the protocol is enabled with protocol 176:[your id number] and output is configured to mqtt with the correct user and password. You can also specify a topic to publish to with the device parameter
Start the MQTT add-on, then the RTL_433 add-on. Check the logs for both and make sure MQTT add-on shows that RTL_433 has connected without socket errors, and the RTL_433 add-on ends with the line connection established. If this is not the case you need to troubleshoot the network connection. Make sure the IPs, ports, and usernames are correct.
Use an app like MQTT explorer to make sure you are getting output from RTL_433, you are looking for the topic with RTL433 or whatever you set it to, the under that you want the “gap”

Configure the integration For MQTT under HASS. Then make sure it is connected properly you should see in the log For MQTT that it’s connected under user homeassistant

Part 3: Pulling everything into HASS
First setup a sensor for the current power consumption in kilowatts:

- platform: mqtt
  name: "Current Power Consumption" # pick whatever name you want
  unique_id: "powerccostmon1" # this must be unique
  state_topic: "rtl_433/BluelinePower/gap" #this is the topic you saw with MQTT explorer for the gap value
  unit_of_measurement: 'kW'
  value_template: "{{ '%.2f'%(3600 / (value | float)) | float }}" # if your meter's kH value is not 1, change the 3600 to whatever 3600*Kh is equal to. 
  device_class: energy
  state_class: measurement

Next ensure that your sensor is working in homeassistant, check entities and make sure it’s reporting values.

Home assistant energy requires the total kWh as an entity as far as I’m aware. So to get this use the Riemann integration sensor:

- platform: integration
  name: "Total Home Energy"
  source: sensor.current_power_consumption
  round: 3
  unit: kWh

this will give you the total power consumption in kWh.

In order for the sensor to show up in energy you need to add the following attributes to the sensor: (Note see the Andrew Jones comment below before adding this part)

sensor.total_home_energy:
  last_reset: "2020-01-01T00:00:00+00:00"
  device_class: energy
  state_class: measurement

to do so, you can use customize by adding the following to configuration.yaml:

homeasisstant:
  customize: !include customize.yaml

and in customize.yaml:

  sensor.total_home_energy:
    last_reset: "2020-01-01T00:00:00+00:00"
    device_class: energy
    state_class: measurement

Now go to your energy dashboard, add consumption, and total home energy should show as an option, simply add it and wait, that’s it!

Credit to all of the following wonderful guides and discussions:

If I made any errors please feel free to update. I’m also working on figuring out how to make an entity to track the peak time costs and whether the energy dashboard will actually update properly as it still seems to be showing zero, any tips please message!

Just before anyone else thinks that this is necessary. It is not. Sensors using the integration platform, absolutely show up just fine on my Energy dashboard - with ONLY this as the config:

  - platform: integration
    source: sensor.house_electric
    name: House Electric KWh
    unit_prefix: k
    round: 2

EDIT:
For peak and off-peak use you want to use the utility meter: Here’s mine as an example:

house_daily_electric:
  cycle: daily
  source: sensor.house_electric_kwh
  tariffs:
    - day

And if you look at the docs, and particularly at the examples near the bottom of the page - they show how to do peak and off-peak along with the automation required to switch between peak and off-peak measuring.

Awesome thanks! Updated to reference the above.

Also sorry for the noob question: I know I can track total cost with utility meter including peaks but I’d like to use the energy dashboard by having an entity that has the current price in c/kWh. I’m trying to figure out the code, haha it’s been a while

Instead of adding your total consumption to the energy dashboard, you add the utility_meter entries instead, each entry you add to “Grid Consumption” let’s you give it a unit cost (eg per kWh) the dashboard should then give you an accurate price. See: Frequently Asked Questions about home energy management - Home Assistant