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.
- Custom parameters for
rtl_tcp
andrtlamr
(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
andunit_of_measurement
- Function to find your meter ID based on your meter reading
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.
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!
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.
If you are not running the add-on, you must write the rtlamr2mqtt.yaml configuration file.
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
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
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
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
This is a planned feature...
A big thank you to all kind contributions!
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