Get your smart electric, water and gas meter scm readings into home assistant with a RTL-SDR

That’s good! if you found a similar, but not matching ID number, you can confirm it is yours by looking at the sent data (kWh or other) and matching the same numbers on your physical meter.

I’m so glad this works with My meter.
I was looking at z-wave and other types of electrical consumption readers. All required some type of pickup wrap around the mains. And where very expensive to boot.

Many many thanks for the write up.

1 Like

Is it normal for the MQTT client to drop and restore the connection to the broker so often?

My MQTT log is a bit noisier after setting this up. Lots of entries like:

1552839925: New client connected from 192.168.0.88 as d0d2623b-d2b4-47cf-93ee-a17bb1a0a43d (c1, k60, u'huser1').
1552839925: |-- getuser(huser1) AUTHENTICATED=1 by http
1552839925: Client d0d2623b-d2b4-47cf-93ee-a17bb1a0a43d disconnected.
1552839979: New connection from 192.168.0.88 on port 1883.
1552839979: |-- mosquitto_auth_unpwd_check(huser1)
1552839979: |-- ** checking backend http
1552839979: |-- url=http://127.0.0.1:8080/login
1552839979: |-- data=username=huser1&password=PW&topic=&acc=-1&clientid=
[INFO] found huser1 on local database
1552839981: New client connected from 192.168.0.88 as 4a86f5c7-58e1-487f-a2c2-49b91532ecb4 (c1, k60, u'huser1').
1552839981: |-- getuser(huser1) AUTHENTICATED=1 by http
1552839981: Client 4a86f5c7-58e1-487f-a2c2-49b91532ecb4 disconnected.
1552840103: New connection from 192.168.0.88 on port 1883.
1552840103: |-- mosquitto_auth_unpwd_check(huser1)
1552840103: |-- ** checking backend http
1552840103: |-- url=http://127.0.0.1:8080/login
1552840103: |-- data=username=huser1&password=PW&topic=&acc=-1&clientid=
[INFO] found huser1 on local database
1552840105: New client connected from 192.168.0.88 as 4b07c03f-4d2f-4976-998e-f96aa5ac9862 (c1, k60, u'huser1').
1552840105: |-- getuser(huser1) AUTHENTICATED=1 by http
1552840105: Client 4b07c03f-4d2f-4976-998e-f96aa5ac9862 disconnected.

Would this be a bug, misconfiguration or just the nature of the beast?

Looking at the code (with my limited knowledge of code) it seems that the script opens a MQTT connection sends the payload the closes the connection. Wile using paho-mqtt

So it seems as its working as intended.

Looking a the doc’s for paho-mqtt leads me to believe there is way to have a persistent connecting, maybe. I’ll need to read a bit more.

I did not like the random MQTT client id that the script has. So after reading the paho-mqtt doc’s I figured how to change it with a couple of simple edits:
Need to add: MQTT_ID = ‘Your-ID’ . To “setting.py”
Then edit “amrscm2mqtt” around line 46 there should be:

publish.single(topic, payload=payload, qos=1, hostname=settings.MQTT_HOST, port=settings.MQTT_PORT, auth=auth)

Add “client_id=settings.MQTT_ID” to that line, As:

publish.single(topic, payload=payload, qos=1, hostname=settings.MQTT_HOST, port=settings.MQTT_PORT, auth=auth, client_id=settings.MQTT_ID)

Now I’m able to name my meter reader.

Maybe it will help.

Im aiming for the same goal, I’ve got not only my water and gas meters, but also a series of 433 MHz sensors I want to feed into HA.

Can rtlamr run on my pi3b+ running hass.io? Or do I need a second pi for this? I wasn’t sure how much hassio could do since it runs as the OS as well.

I am not sure about hass.io, as I have not played with it. However, since it sends the data through mqtt, it would definitely work that way. Also I believe (and have not tested) that since the AMR data is on the 900 MHz, you might need two dongles if you want to catch the data from your 433 MHz at the same time.

I’m trying to see if I can get it to do both, rtl_433 has a flag to alternate between multiple
Frequencies, but rtlamr decodes my meters and rtl_433 decodes my sensors. Not sure it’s worth the effort to set something up to have rtl_tcp flip between two frequencies writing to a file and then the respective other program to decode.

If I can’t run it right on the hassio system it’s probably easier to run two dongles on a separate rpi

One step closer.

I’ve got this running now on another pi, and a bash script that takes 12 min of rtlamr then 4 min of rtl433 and just keeps alternating. This gets me good interval temps and meter reads and I can probably make it just alternate every 5 mins once I’m confident of the intervals.

Both are outputting json to mqtt. Then an automation demux’s the data put into separate topics for an mqtt sensor to use.

My message for the meters is a nested json though, and the 433mhz sensors are not.

Still pondering how to adjust the automation for that.

I have rtl_tcp and rtlamr running, but it doesn’t look like I am finding any energy meters. Below is what I’m getting from rtlamr. I checked my power meter, and it is on the working list. It is a C2S0D.

Does anyone happen to know what devices these are?

{Time:2019-07-16T10:35:26.139 SCM+:{ProtocolID:0x1E EndpointType:0xAB EndpointID:  72515216 Consumption:    401695 Tamper:0x4900 PacketCRC:0x24F7}}
{Time:2019-07-16T10:35:41.363 SCM+:{ProtocolID:0x1E EndpointType:0xAB EndpointID:  72515177 Consumption:    487185 Tamper:0x6900 PacketCRC:0x5BD3}}
{Time:2019-07-16T10:35:42.685 SCM:{ID:37907505 Type:12 Tamper:{Phy:02 Enc:00} Consumption:  194142 CRC:0xD3A0}}
{Time:2019-07-16T10:35:48.806 SCM:{ID:37907321 Type:12 Tamper:{Phy:00 Enc:00} Consumption:  877982 CRC:0xDC03}}
{Time:2019-07-16T10:36:03.805 SCM:{ID:37907321 Type:12 Tamper:{Phy:00 Enc:00} Consumption:  877982 CRC:0xDC03}}
{Time:2019-07-16T10:36:18.593 SCM:{ID:38500992 Type:12 Tamper:{Phy:00 Enc:00} Consumption:  817602 CRC:0xA9A4}}
{Time:2019-07-16T10:36:41.366 SCM+:{ProtocolID:0x1E EndpointType:0xAB EndpointID:  72515177 Consumption:    487185 Tamper:0x6900 PacketCRC:0x5BD3}}
{Time:2019-07-16T10:36:45.207 SCM:{ID:37895172 Type:12 Tamper:{Phy:02 Enc:00} Consumption:  757156 CRC:0xF5A2}}
{Time:2019-07-16T10:36:51.581 SCM:{ID:38283796 Type:12 Tamper:{Phy:03 Enc:00} Consumption:  384340 CRC:0x27FA}}
{Time:2019-07-16T10:37:04.313 SCM:{ID:37907321 Type:12 Tamper:{Phy:00 Enc:00} Consumption:  877982 CRC:0xDC03}}

I am using this dongle and have the metal telescoping antenna plugged into it.

They must be some sort of meter. All have “Consumption”. So its seems to be keeping a tally on something.

Thy matching up the Consumption value with your meter, Or the ID#. The ID is usually on a barcode label on the meter (under the glass).

Thanks @Akriss.

I compared my ID# on my meter and it is a 9 digit number, and these are all 8. The consumption results don’t look close to anything that my meter is displaying on the digital display. So unfortunately, it looks like I can’t read my energy meter.

This is still a fun project though to tinker around with!

My meters id number label has two numbers before the detected number in the scan.
I didn’t notice that at first.
Could be padding numbers on your label as well?

I actually figured out that one of those ids is my gas meter. So it looks like the gas meters in the neighborhood are broadcasting, but not the electric meters. At least I’ll get some data on our gas usage!

Thanks. With your directions, I got it setup.

Right now I only found my electric meter, so I used your template to get a scm message. The posted amrscm2mqtt did not work for me, but I used your scm code to edit the original file from the repo.

Hey, I have migrated my MQTT server to include username and password authorization.

Do any of you have this working? I keep getting socket errors even after I fill in the username and password into the settings.py

I don’t know which server you are using, but I have been using Mosquitto from the beginning with username and password authorisation without problems. I had followed this guide to setup Mosquitto

I made a docker container for this capability. https://github.com/jdeath/RTLAMR2MQQT

You will need to clone it and install it manually in your addons folder. (I don’t know how to make it a hassio repository).

It takes a while to build because its compiling a few things. There are extra libraries in the docker, which I will try to pull out eventually.

6 Likes

Awesome stuff!

1 Like

Hey @david1 did you ever get this working with PG&E? If so, please let me know what SDR you used and any other tips!
Thanks

Thanks for sharing. I have been monitoring for a few hours and my meter hasn’t been showing up. I came across your post after some googling. Have you had any luck with this?