Using an inexpensive rtl-sdr dongle, it's possible to listen for signals from ERT compatible smart meters using rtlamr. This script runs as a daemon, launches rtl_tcp and rtlamr, and parses the output from rtlamr. If this matches your meter, it will push the data into MQTT for consumption by Home Assistant, OpenHAB, or custom scripts.
TODO: Video for Home Assistant
This fork is specifically tuned for reading SCM messages (but can easily be changed back to IDM with a few edits)
- Supports TLS (server-side) for encrypted communication
- Symbol lengths are tuned (and can be adjusted) to reduce CPU consumption
- Uses a single MQTT session running in a background thread
- Only updates MQTT when the value changes
- More robust availability handling
Example Topic:
meters/32109876/reading
Tested under Raspberry Pi OS (32-bit) (Debian Bullseye)
Install RTL-SDR package
sudo apt-get install rtl-sdr
Set permissions on rtl-sdr device (check your device info via lsusb)
/etc/udev/rules.d/rtl-sdr.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", MODE:="0666"
Prevent tv tuner drivers from using rtl-sdr device
/etc/modprobe.d/rtl-sdr.conf
blacklist dvb_usb_rtl28xxu
sudo apt-get install git
Install pip for python 3
sudo apt-get install python3-pip backoff
Install paho-mqtt and backoff packages for python3
sudo pip3 install paho-mqtt
Install Go programming language & set gopath
sudo apt-get install golang
https://github.com/golang/go/wiki/SettingGOPATH
If only running go to get rtlamr, just set environment temporarily with the following command
export GOPATH=$HOME/go
Install rtlamr https://github.com/bemasher/rtlamr
go get github.com/bemasher/rtlamr
To make things convenient, I'm copying rtlamr to /usr/local/bin
sudo cp ~/go/bin/rtlamr /usr/local/bin/rtlamr
Clone repo into opt
cd /opt
sudo git clone https://github.com/jherby2k/amridm2mqtt.git amrscm2mqtt
Copy template to settings.py
cd /opt/amrscm2mqtt
sudo cp settings_template.py settings.py
Edit file and replace with appropriate values for your configuration
sudo nano /opt/amrscm2mqtt/settings.py
Copy amrscm2mqtt service configuration into systemd config
sudo cp /opt/amrscm2mqtt/amrscm2mqtt.systemd.service /etc/systemd/system/amrscm2mqtt.service
Refresh systemd configuration
sudo systemctl daemon-reload
Start amridm2mqtt service
sudo service amrscm2mqtt start
Set amridm2mqtt to run on startup
sudo systemctl enable amrscm2mqtt.service
To use these values in Home Assistant,
mqtt:
sensor:
- name: Gas Meter
state_topic: meters/12345678/reading
availability_topic: meters/availability
unit_of_measurement: m³
device_class: gas
state_class: total
value_template: '{{ (value | int(0) * 0.0283) | round(2) }}' # Optional, converts readings in cubic feet to m³
Assuming you're using mosquitto as the server, and your meter's sends SCM messages with id 12345678, you can watch for events using the command:
mosquitto_sub -t "meters/12345678/reading"
Or if you've password protected mosquitto
mosquitto_sub -t "meters/12345678/reading" -u <user_name> -P <password>
If all else fails, you can listen to the base topic to see what's actually getting posted
mosquitto_sub -t "meters/#" -u <user_name> -P <password>