Skip to content

allangood/rtlamr2mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTLAMR2MQTT

Docker Pulls GitHub license GitHub stars GitHub contributors GitHub issues

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Platforms:

AMD64 AARCH64

RTLAMR2MQTT is a small Python program to read your utility meter such as water, gas and energy using an inexpensive USB RTL-SDR device and send these readings to a MQTT broker to be integrated with Home Assistant or NodeRed.

Current features

  • Custom parameters for rtl_tcp and rtlamr (custom_parameters config option)
  • It can run rtl_tcp locally or use an external instance running somewhere else (custom_parameters config option)
  • MQTT TLS support (tls_enabled config option)
  • Reset USB port before open it (device_id config option)
  • Format reading number. Some meters reports a flat number that should be formatted with decimals (format config option)
  • Sleep after successful reading to avoid heating the CPU too much (sleep_for config option)
  • Support multiple meters with one instance
  • Run as an Addon for Home Assistant with Supervisor support and MQTT auto configuration
  • Full sensor customization: name, state_class, device_class, icon and unit_of_measurement

Planned features

  • Function to find your meter ID based on your meter reading

Changes

Caution

Major code rewrite
After a long break without working on this project, I am back with a major rewrite.
The old code was too hard to maintain.
Your old entities should be cleaned manually from your MQTT broker

Caution

This new version does not have the LISTEN MODE!!!
It is planned, but not implemented yet.

Readme starts here

What do I need?

1) You need a smart meter First and most important, you must have a "smart" water/gas/energy meter. You can find a list of compatible meters here

2) You need an USB RTL-SDR device I am using this one: NooElec NESDR Mini USB

3) You need a MQTT broker (Like Mosquitto )

4) Home Assistant is optional, but highly recommended, because it is awesome!

How it looks like?

image

image

How to run and configure?

Home Assistant Add-On:

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Open your Home Assistant instance and show the dashboard of a Supervisor add-on.

Manually:

  • Navigate to your Add-Ons (Configuration > Add-ons, Backups, & Supervisor)
  • Click the Add-On Store button
  • Navigate to Repositories (3 dots in the top-right corner > Repositories)
  • Add this repository (https://github.com/allangood/rtlamr2mqtt) and click 'Add'
  • You should now see the 'rtlamr' Add-On at the bottom of your Add-On Store. Click to install and configure.

Docker or Docker-Compose

If you are not running the add-on, you must write the rtlamr2mqtt.yaml configuration file.

Run with docker

If you want to run with docker alone, run this command:

docker run --name rtlamr2mqtt \
  -v /opt/rtlamr2mqtt/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml \
  --device /dev/bus/usb:/dev/bus/usb \
  --restart unless-stopped \
  allangood/rtlamr2mqtt

Run with docker-compose

If you use docker-compose (recommended), add this to your compose file:

version: "3"
services:
  rtlamr:
    container_name: rtlamr2mqtt
    image: allangood/rtlamr2mqtt
    restart: unless-stopped
    devices:
      - /dev/bus/usb
    volumes:
      - /opt/rtlamr2mqtt/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml:ro

Home Assistant utility meter configuration (sample):

To add your meters to Home Assistant, add a section like this:

utility_meter:
  hourly_water:
    source: sensor.<meter_name>
    cycle: hourly
  daily_water:
    source: sensor.<meter_name>
    cycle: daily
  monthly_water:
    source: sensor.<meter_name>
    cycle: monthly

Multiple RTL devices

If you have multiple RTL devices, you will need to specify the USB device you want to use

Using lsusb to find USB Device ID BUS:Device:

$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T <<< I want to use this device
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T

USB Device => 005:002

I don't know my meters ID, what can I do?

This is a planned feature...

Thanks to

A big thank you to all kind contributions!

Credits to:

RTLAMR - https://github.com/bemasher/rtlamr

RTL_TCP - https://osmocom.org/projects/rtl-sdr/wiki/Rtl-sdr

Icon by: Sound icons created by Plastic Donut - Flaticon