Home Assistant Add-On: AMR2MQTT

Home Assistant Add-on: AMR2MQTT

GitHub Release Project Stage License

Supports aarch64 Architecture Supports amd64 Architecture Supports armhf Architecture Supports armv7 Architecture Supports i386 Architecture

Runs rtlamr to read meter data and send to MQTT broker.

Open your Home Assistant instance and show the add add-on repository dialogwith a specific repository URL pre-filled. Open your Home Assistant instance and show the dashboard of a Supervisor add-on.

About

Allows you to use an rtl-sdr dongle to listen for signals from ERT compatible smart meters using rtlamr. This runs as a daemon by launching rtl-tcp and rtlamr, parsing the output and pushing it into MQTT so Home Assistant can consume it.

There’s too many acronyms, explain yourself

Most meters for gas, electric and water broadcast the consumption information they collect. This is why generally the gas/electric/water company doesn’t come onto your property anymore to physically take readings. They just drive by and collect the information as it is being broadcast or have other ways of aggregating the broadcasted consumption info.

Often you can collect this information too using an rtl-sdr dongle and software like this addon that knows how to to turn the broadcasted consumption info into something you can use in other applications. Well actually software like bemasher’s wonderful rtlamr application. This addon is really a thin shell on that which pushes the readings you are interested in over to your MQTT broker in a way HA understands. This way you can use your gas/electric/water consumption information in your dashboards and automations within HA.

Sounds great! What do I do?

First you’ll need an rtl-sdr dongle. If you’re interested, I have a NooElec NESDR Nano 2+ although others work fine.

However note that this add-on does not work with all meters. Some potential problems include:

  • Meter does not broadcast consumption information, it just displays it
  • Broadcasts by your meter are encrypted and cannot be used
  • Meter only broadcasts once a month when the utility company pings it

So before beginning, check this list of compatible meters and see if your meter is on there. It will have the manufacturer and model number printed on it somewhere.

This list isn’t exhaustive so if you don’t find your meter it may still work if you’re willing to take a gamble and order a dongle anyway. But just bear in mind this solution is not universal and YMMV.

That’s the major requirement. After that you will need an MQTT broker set up which both this addon and HA are talking to and there’s a few steps to help you find your particular meter(s) from all the ones around you broadcasting. Take a look at this addon’s docs for instructions there if you need help.

This addon’s name sounds familiar…

This began as a port of ragingcomputer’s amridm2mqtt to a Home Assistant add-on in order to make it easier to use in HAOS and supervised setups which you may have seen some discussion about around here. There are a number of other modifications as well such as support for other formats like scm and a wider variety of MQTT configurations. Big thanks to ragingcomputer for their work.

About 75% through the project I stumbled across rtlamr2mqtt. My own fault for not getting all the way through the amridm2mqtt forum post since I realized later it was linked in there. This was obviously a bit of a bummer since it made my work redundant but I decided to continue on anyway so I could learn about rtlamr and add features on my schedule. Like for example I can’t use my MQTT broker with that addon since it doesn’t support advanced security options around certificates, which (understandably) is probably not a high priority for others.

Questions? Issues?

The addon’s documentation and readme cover all the addon’s options and have setup/troubleshooting info. If you need help beyond that, you can:

  • Comment here
  • Open an issue in the repository
  • Ask for help in the #add-ons channel of the HA discord (I’m CentralCommand#0913 there).
6 Likes

How to do I run rtl_433 and rtlamr with two RTL-SDR sticks on a Raspberry Pi HA installation?
Hi I successfully installed this Home Assistant Add-on: rtl_433 with MQTT auto discovery) and receive old thermometers via a RTL-SDR on Bus 001 Device 004: ID 0bda:2838. Now I added a 2nd RTL-SDR stick on Bus 001 Device 006: ID 0bda:2838 and would like to run amr2mqtt in parallel to the well working rtl_433. Two of my meters are smart: water Itron 100WRD Water ERT Type 11 903/927 Mhz and gas Itron 100GDLAN Gas ERT Type 12 908/926.8 Mhz. So far, I am unable to figure out how to “tell” HA, to continue to use this RTL-SDR Bus 001 Device 004: ID 0bda:2838 for the old thermometers etc. via rtl_433 (GitHub - pbkhrv/rtl_433-hass-addons: Collection of Home Assistant add-ons that use rtl_433) and Bus 001 Device 006: ID 0bda:2838 for gas and water. Also, identifying the meters via this command “docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE=“all” --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt” probably requres some adjustments I guess? The system log shows this: 22-04-09 11:48:48 WARNING (MainThread) [supervisor.misc.tasks] Watchdog found a problem with 6713e36e_rtlamr2mqtt!
22-04-09 11:48:48 INFO (SyncWorker_6) [supervisor.docker.interface] Cleaning addon_6713e36e_rtlamr2mqtt application
22-04-09 11:48:50 INFO (SyncWorker_6) [supervisor.docker.addon] Starting Docker add-on 6713e36e/aarch64-addon-rtlamr2mqtt with version 1.7.0
And, when I type in “rtl_tcp” or “rtlamr” into the SSH sheel inside HA, I don’t see anything but an error message.
[core-ssh /]$ rtl_tcp
bash: rtl_tcp: command not found
[core-ssh /]$ rtlamr
bash: rtlamr: command not found
Any help would be greatly appreciated

1 Like

Hi, if I have a meter that is encrypted, but I do have the decryption key, can I make it work? thanks

I need some help setting up this addon.

When completing the configuration, either with my ID or [] and MQTT with either local IP or the IP of home assistant I’m getting the following error.

Failed to save add-on configuration, Invalid list for option ‘meters’ in AMR2MQTT (39bd2704_amr2mqtt). Got {‘meters’: 1564077862, ‘mqtt’: ‘127.0.0.1’}

If I switch to yaml configuration I use the following

watched_meters:
  - id: []
mqtt:
  host: 127.0.0.1
  port: 1883

I get the following error.

Failed to save add-on configuration, Missing option ‘meters’ in root in AMR2MQTT (39bd2704_amr2mqtt). Got {‘watched_meters’: [{‘id’: []}], ‘mqtt’: {‘host’: ‘127.0.0.1’, ‘port’: 1883}}

Not quite sure what to do next. Any help is appreciated.

What version of the addon are you running? When I was first developing the addon before the initial launch I called the config option watched_meters but changed it to meters before v1.0.0. I think I forgot a reference in docs that I fixed in v1.0.2 though?

Anyway watched_meters should be meters. And id should just have a single value, not an array. See configuration in the docs for an example configuration and all the options.

Hi @CentralCommand , got the add-in installed and am seeing data flow through MQTT Explorer. However, I have been unable to aggregate this as a sensor. I have not been able to get any auto-discovery to work, and whenever I manually configure the sensor in configuration.yaml I get ‘sensor not available’.

Here is my AMR2MQTT Configuration:

meters:
  - id: (****)
    protocol: r900
    name: Water_Heater
    type: water
    unit_of_measurement: ccf
mqtt:
  host: core-mosquitto
  port: 1883
  username: (****)
  password: (****)
home_assistant_discovery_enabled: true

Here is my MQTT Explorer readout:

And here is my configuration.yaml for this sensor:

mqtt:
  sensor:
    - name: Water Meter
      unique_id: water_meter
      state_topic: "amr2mqtt/(****)"
      unit_of_measurement: "ccf"
      value_template: "{{ value_json.Consumption }}"

Is there something obvious I am missing here?

Secondary question - is there a way to ‘sleep’ or slow down the reads? I am on an Intel NUC and the addon can consume 40% CPU time - looks like it is reading every 10 seconds.

Thanks!

Anything needed to get this working with the new water consumption coming to the energy dashboard in 2022.11?

yeah also curious how to get this working with the energy dashboard… I get this when I go to add a water source: “No matching statistics found”

I got it to show up like this:

configuration.yaml

mqtt:
  sensor:
    - name: "Water Meter"
      unique_id: water_meter
      state_topic: "rtlamr/XXXXXXXX/attributes"
      #unit_of_measurement: "\u33A5"
      unit_of_measurement: "m³"
      json_attributes_topic: "rtlamr/XXXXXXXX/attributes"
      value_template: "{{value_json.Consumption | float / 10}}"
      state_class: total_increasing
      device_class: water
      availability:
        - topic: "rtlamr/status"
      payload_available: "online"
      payload_not_available: "offline"
{
"Message Type": "SCM+", 
"FrameSync": 5795, "ProtocolID": 30, 
"EndpointType": 171, 
"EndpointID": XXXXXXXX, 
"Consumption": 3754, 
"Tamper": 18688, 
"PacketCRC": 11345
}
statistics_not_defined
sensor.water_meter
Entity unavailable
The state of these configured entities are currently not available:
sensor.water_meter (unknown)

Ok got it with some help from Thanasis fixed above.
Was defining attributes but specifying state which just had a regular value in it not value_json.
Also watch that M3 value if it is not the correct value it won’t show up under the water meter for the energy page. You can manually fix it by going into the dev tools and manually selecting m3 from the drop-down.



image

image

Seems I got the default injection of rtlamr working so I removed the above now just working with this:

# -- Configuration file starts here --
# (Optional section)
general:
  # Sleep for this amount of seconds after one successful reading of every meter
  # This parameter is helpful to keep CPU usage low and the temperature low as well
  # Set this to 0 (default) to disable it
  sleep_for: 300
  # Set the verbosity level. It can be debugged or info
  verbosity: debug
  # Enable/disable the tickle_rtl_tcp. This is used to "shake" rtl_tcp to wake it up.
  # For me, this started to cause the rtl_tcp to refuse connections and miss the readings.
  # This may help with a remote rtl_tcp server.
  tickle_rtl_tcp: false
  # (Optional) USB Device ID. Use lsusb to get the device ID
  # Use "single" (default) if you have only one device
  # device_id: 'single'
  device_id: '0bda:2838'

# MQTT configuration.
mqtt:
  # Whether to use Home Assistant auto-discovery feature or not
  ha_autodiscovery: true
  # Home Assistant auto-discovery topic
  ha_autodiscovery_topic: homeassistant
  # Base topic to send status and updates
  base_topic: rtlamr
  # By default, leaving host, port, user, and password unset will tell
  # rtlamr2mqtt to use the default home assistant mqtt settings for those
  # options. If needed, you can override these default settings:
  # MQTT host name or IP address.
  host: IP
  # MQTT port.
  port: 1883
  # TLS Enabled? (False by default)
  tls_enabled: false
  # TLS CA certificate (mandatory if tls_enabled = true)
  tls_ca: "/etc/ssl/certs/ca-certificates.crt"
  # TLS server certificate (optional)
  tls_cert: "/etc/ssl/my_server_cert.crt"
  # TLS self-signed certificate/insecure certificate (optional, default true)
  tls_insecure: true
  # MQTT user name if you have, remove if you don't use authentication
  user: user
  # MQTT user password if you use one, remove if you don't use authentication
  password: password123

# (Optional)
# This entire section is optional.
# If you don't need any custom parameter, don't use it.
# ***DO NOT ADD -msgtype, -filterid nor -protocol parameters here***
# -d parameter is not necessary anymore if you use device_id
custom_parameters:
  # Documentation for rtl_tcp: https://osmocom.org/projects/rtl-sdr/wiki/Rtl-sdr
  rtltcp: "-s 2048000"
  # Documentation for rtlamr: https://github.com/bemasher/rtlamr/wiki/Configuration
  # If you want to disable the local rtl_tcp and use an external/remote one, you must add "-server=remote-ip-address:port" to the rtlamr section below.
  rtlamr: "-unique=true -symbollength=32"

# (Required section)
# Here is the place to define your meters
meters:
    # The ID of your meter
  - id: XXXXXXXX
    # 7823010
    # The protocol
    protocol: scm+
    # A nice name to show on your Home Assistant/Node Red
    name: meter_water
    # (optional) A number format to be used for your meter
    format: "#.#"
    # (optional) A measurement unit to be used by Home Assistant
    # Typical values are ft³ and m³ (use the superscript) for water/gas meters
    # and kWh or Wh for electric meters
    unit_of_measurement: "m³"
    #"\u33A5"
    # (optional) An icon to be used by Home Assistant
    icon: mdi:gauge
    # A device_class to define what the sensor is measuring for use in the Energy panel
    # Typical values are "gas" or "energy". Default is blank.
    device_class: water
    # "total_increasing" for most meters, "total" for meters that might go
    # backwards (net energy meters). Defaults to "total_increasing" if unset.
    state_class: total_increasing
  #- id: 6567984
  #  protocol: scm
  #  name: meter_hydro
  #  unit_of_measurement: kWh
  #  device_class: energy
# -- End of configuration file --

Did you have any luck with this? I’m looking to do the same.

So is this to actual config for the app ? It doesnt seem to support custom_parameters at all fro what I can tell

https://github.com/mdegat01/addon-amr2mqtt/search?q=custom_parameters

Am I missing something ?

cc @CentralCommand

This is in a separate configuration file my docker-compose yaml looks like this:

version: "3"
services:
  rtlamr:
    container_name: "rtlamr2mqtt"
    image: "allangood/rtlamr2mqtt"
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
      - "com.centurylinklabs.watchtower.monitor-only=false"
    restart: "no"
    devices:
      - /dev/bus/usb
    volumes:
      - /var/lib/libvirt/images/usb001/docker-storage/rtlamr2mqtt/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml
      - /var/lib/libvirt/images/usb001/docker-storage/rtlamr2mqtt/data:/var/lib/rtlamr2mqtt
    mac_address: "9e:57:59:8e:5e:31"
    networks:
      - dhcp
networks:      
  dhcp:
    name: "dbrv700"
    external: true

Then I go to the folder I specified above and dump that configuration from the last post there. Which you can set to where ever you would like. You can also remove/ignore the watchtower labels and network stuff unless you use watchtower to update your containers and VLAN bridges and dnsmasq static set DHCP by MAC addresses with your dockers.

/var/lib/libvirt/images/usb001/docker-storage/rtlamr2mqtt/rtlamr2mqtt.yaml

Hope this is the missing link and helps you get going.

That option doesn’t exist for this addon. You seem to be using this one, that’s a different addon.

What is the difference between them?

Besides support for the parameter you’re showing - I have no idea. I’ve never used the other one.

1 Like

Extending some thanks and a bravo here, this was stupidly easy to get setup and running.

-Installed the Add-on per this thread
-Plugged in a USB Radio, this one was detected right away: https://www.amazon.com/dp/B009U7WZCA?
-Looked on my gas meter and saw the bold ID number, put that into the meter config
-Added my MQTT config
-Started the Addon and had gas readings in about 5 minutes.

I found my meter updates upon a threshold of gas usage, which ends up being every 10-15 min now that is winter and the heat is on.

I also used MQTT explorer to monitor the topic without anything in the meters config to confirm that my meter was showing up and what protocol it was using.

1 Like

So I have installed this Add-On and Mosquito Broker as well. I have added the configuration as per docs:

meters:
  - id: ***********
    protocol: scm
    name: Energy Meter
    type: energy
    multiplier: 0.01
    unit_of_measurement: kWh
    model: C1A3B
mqtt:
  host: 127.0.0.1
  port: 1883

However, if I check my configuration I see this:

Integration error: meters - Integration ‘meters’ not found.
Invalid config for [mqtt]: [host] is an invalid option for [mqtt]. Check: mqtt->mqtt->host. (See /config/configuration.yaml, line 96).

what I’m missing here? Any suggestions @CentralCommand

That config is for the addon. It goes in the config tab for the addon, not in the configuration.yaml file that Home Assistant uses

For some reason I can’t get this to work :thinking: each time I try to save the configuration I get this:

Failed to save add-on configuration, expected int. Got {‘meters’: [{‘id’: ‘*******’, ‘protocol’: ‘scm’, ‘name’: ‘Energy Meter’, ‘type’: ‘energy’, ‘multiplier’: 0.01, ‘unit_of_measurement’: ‘kWh’, ‘model’: ‘C1A3B’}], ‘log_level’: ‘debug’}