Home Assistant Add-on: rtl_433 with MQTT auto discovery

Hello,

I can’t get RTL_433 to sent MQTT messages from my weather sensors. Or maybe that RTL_433 is not demodulating anything, I’m not sure.

From the logs, RTL_433 is started and is able to connect to the MQTT broker:

I can see the successful connection from Mosquitto:

However, nothing is being sent over MQTT :

My RTL_433 config file:

output mqtt://10.0.0.158:1883,user=mqtt,pass=mqttpassword,retain=0
convert     si
frequency   433.92M

I am able to see MQTT messages from my weather stations using another add-on:
acurite2mqtt.

My configuration for this add-on is:

The goal is to switch from acurite2mqtt to RTL_433 because I need to use the flex decoder to expand to other non-weather related devices, such as the SONOFF 433MHz buttons, PIR sensor and magnetic door sensors.

However, there’s no point in trying to make these flex decoders work, since I’m not able to simply demodulate the already known working weather stations.

I’d like to split the problem in two; how can I display / print in a log what’s being demodulated by RTL_433? I am not sure if the problem lies with the demodulator itself or with the MQTT configuration.

image

Booted with Raspbian, running RTL_433 from the command line and it does work. I am not connecting to the MQTT server, because it was shut down I only have one pi.

I also tried running from the command line RTL_433 from windows with the same .conf file, this time connecting to MQTT, and it does work.

So there is something wrong running with hass.io, still don’t know where the problem is …

Any help appreciated!

I’m running an older version of HA, but with the quantity of stuff I have in HA … if it ain’t broke, don’t fix it (unless otherwise advised!)

Easiest thing to do is add a second output line with output kv or output json. If rtl_433 is picking up something, it will log it to the addon logs as well as try to send it to your mqtt broker.

Nothing is being output’d in the addon’s log when using “output kv” or “output json”. Safe to say MQTT isn’t to blame?

Yes, that’s a good assumption. I would check again by running rtl_433 directly with the radio (even on a computer outside of HA). If there’s still no messages picked up, at least you’ll know it’s not home assistant or the addon.

Messages ARE picked up on that same raspberry running rasbian instead of hassio. Not sure what’s next; update HA to the current version?

I’m running into the same issue

Because the add-on started sporadically crashing about once a day (LIBUSB_ERROR_NOT_FOUND), I ended up ditching the add-on and running RTL_433 on a separate pi zero W running Raspbian.

That kills two birds with one stone: no more crashes & I can add my own decoder, and it works perfectly with MQTT.

1 Like

I’d like to use this to listen for some buttons that I got from AliExpress. Is this possible? I don’t see “0x1 (Lock)” in the types. This is the rtl_433 output. The other thing is that it needs to be debounced, sometimes the button will send multiple depending on how long you press it.

{"time" : "2022-02-07 20:48:34.778490", "protocol" : 48, "model" : "Akhan-100F14", "id" : 258848, "data" : "0x1 (Lock)", "mod" : "ASK", "freq" : 433.889, "rssi" : -0.106, "snr" : 15.181, "noise" : -15.287}

Need alittle help.

Recently added a usb sdr and installed both these addons. I used the included antenna and started picking up a bunch of sensors. Of course I couldn’t just leave it alone so I ordered an adapter and tried plugging in a powered over the air tv antenna I had laying around. After doing that all of a sudden I wasn’t picking up anything. Thinking maybe the antenna wasn’t compatible I switched back. Still nothing.

So did I fry the usb dongle with the powered antenna? Or did I goof something up switching antennas?

Hi all.

Firstly, thanks very much for the information provided here!

I’m attempting to collect data from some 433mhz sensors and bring it into HA. I’ve followed the instructions provided in the rtl_433 addon documentation, as well as rtl_433 MQTT auto discovery & mosquito broker.

This seems to have worked somewhat, as when I use MQTT explorer, I see all sensors I know are within range of my device. HA even auto-discovered one of these devices, and I configured it & added it to my lovelace.

But everything stops right there. The data in lovelace as well as MQTT explorer remains the same, even after restarting all addons and “forcing” new data to be sent to MQTT - the lovelace device states “updated (20) seconds ago”, but the data from earlier in the day remains.

This leads me to my second issue - only the first sensor discovered by rtl_433 appears in the HA device discovery page - I have added it, and it appears in my devices list, but after this no other device has been discovered, despite the remaining devices being compatible/decode-able by rtl_433.

I’ve scoured the forums both here & on reddit but to no avail. I’m quite sure this is a very simple issue to fix but after spending a weekend trying to solve it I thought I’d post here.

Thanks in advance.

rtl_433 config file:

output      mqtt://localhost:8123,user=user,pass=pass,events=rtl_433[/model][/id]
frequency   433.92M
register_all true
convert     si
report_meta newmodel
stop_after_successful_events false

rtl_433 logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
/tmp/rtl_433_heredoc: line 20: warning: here-document at line 1 delimited by end-of-file (wanted `EOD')
Starting rtl_433 with rtl_433.conf...
[rtl_433] rtl_433 version 21.12 branch  at 202112141644 inputs file rtl_tcp RTL-SDR
[rtl_433] Use -h for usage help and see https://triq.org/ for documentation.
[rtl_433] Publishing MQTT data to localhost port 8123
[rtl_433] Publishing events info to MQTT topic "rtl_433[/model][/id]".
[rtl_433] 
[rtl_433] New defaults active, use "-Y classic -s 250k" for the old defaults!
[rtl_433] 
[rtl_433] 
[rtl_433] 	Use -G for testing only. Enable with -G 4 if you really mean it.
[rtl_433] 
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

rtl_433 MQTT Auto Discovery logs: (“Nexus-TH-1-116” is the device which WAS auto-discovered, but no longer updates)

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
mqtt found in this Home Assistance instance.
Starting rtl_433_mqtt_hass.py...
MQTT connected: Connection Accepted.
homeassistant/sensor/Nexus-TH-1-116/Nexus-TH-1-116-UTC/config : {"device_class": "timestamp", "name": "Nexus-TH-1-116-UTC", "icon": "mdi:clock-in", "state_topic": "rtl_433/17069798-rtl433/devices/Nexus-TH/1/116/time", "unique_id": "Nexus-TH-1-116-UTC", "device": {"identifiers": "Nexus-TH-1-116", "name": "Nexus-TH-1-116", "model": "Nexus-TH", "manufacturer": "rtl_433"}, "force_update": "true"}
homeassistant/sensor/Nexus-TH-1-116/Nexus-TH-1-116-B/config : {"device_class": "battery", "name": "Nexus-TH-1-116-B", "unit_of_measurement": "%", "value_template": "{{ float(value|int) * 99 + 1 }}", "state_topic": "rtl_433/17069798-rtl433/devices/Nexus-TH/1/116/battery_ok", "unique_id": "Nexus-TH-1-116-B", "device": {"identifiers": "Nexus-TH-1-116", "name": "Nexus-TH-1-116", "model": "Nexus-TH", "manufacturer": "rtl_433"}, "force_update": "true"}
homeassistant/sensor/Nexus-TH-1-116/Nexus-TH-1-116-T/config : {"device_class": "temperature", "name": "Nexus-TH-1-116-T", "unit_of_measurement": "\u00b0C", "value_template": "{{ value|float }}", "state_topic": "rtl_433/17069798-rtl433/devices/Nexus-TH/1/116/temperature_C", "unique_id": "Nexus-TH-1-116-T", "device": {"identifiers": "Nexus-TH-1-116", "name": "Nexus-TH-1-116", "model": "Nexus-TH", "manufacturer": "rtl_433"}, "force_update": "true"}
homeassistant/sensor/Nexus-TH-1-116/Nexus-TH-1-116-H/config : {"device_class": "humidity", "name": "Nexus-TH-1-116-H", "unit_of_measurement": "%", "value_template": "{{ value|float }}", "state_topic": "rtl_433/17069798-rtl433/devices/Nexus-TH/1/116/humidity", "unique_id": "Nexus-TH-1-116-H", "device": {"identifiers": "Nexus-TH-1-116", "name": "Nexus-TH-1-116", "model": "Nexus-TH", "manufacturer": "rtl_433"}, "force_update": "true"}
Published Nexus-TH/1/116: time, battery_ok, temperature_C, humidity

Mosquito Broker Config:

certfile: fullchain.pem
customize:
  active: false
  folder: mosquitto
keyfile: privkey.pem
logins:
  - username: user
    password: pass
require_certificate: false

Mosquito Broker logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing... 
[16:00:00] INFO: Setting up user mqtt
[16:00:01] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:00:02] INFO: Starting NGINX for authentication handling...
[16:00:02] INFO: Starting mosquitto MQTT broker...
1644418802: mosquitto version 1.6.12 starting
1644418802: |-- *** auth-plug: startup
[16:00:03] INFO: Successfully send discovery information to Home Assistant.
[16:00:03] INFO: Successfully send service information to the Supervisor.
1644418802: Config loaded from /etc/mosquitto/mosquitto.conf.
1644418802: Loading plugin: /usr/share/mosquitto/auth-plug.so
1644418802:  ├── Username/password checking enabled.
1644418802:  ├── TLS-PSK checking enabled.
1644418802:  └── Extended authentication not enabled.
1644418802: Opening ipv4 listen socket on port 1883.
1644418802: Opening ipv6 listen socket on port 1883.
1644418802: Opening websockets listen socket on port 1884.
1644418802: Warning: Mosquitto should not be run as root/administrator.
1644418802: mosquitto version 1.6.12 running
1644418802: New connection from 127.0.0.1 on port 1883.
1644418802: Socket error on client <unknown>, disconnecting.
1644418806: New connection from 172.30.33.3 on port 1883.
1644418806: New client connected from 172.30.33.3 as auto-DF6F2E46-52AF-5158-5A77-F89F0DCD9773 (p2, c1, k60, u'addons').
1644418806: New connection from 172.30.32.1 on port 1883.

Found out how to do this on my own. It isn’t auto discovered, but it otherwise works well. The template is there to prevent the automation from being triggered upon restart or automations refresh.

automation:
- alias: MQTT Button Test
  trigger:
    - platform: mqtt
      topic: "rtl_433/9b13b3f4-rtl433/devices/Akhan-100F14/258848/time"
      payload: "on"
      value_template: >
        {% if (now().today() - strptime(value, '%Y-%m-%d %H:%M:%S')) < timedelta(  seconds = 2 ) %}
          on
        {% else %}
          off
        {% endif %}
  action:
    - service: notify.pushover
      data_template:
        message: 'Button Test'
2 Likes

@deviantintegral Hey there, thanks for the great addon. I don’t run Home Assistant OS, so addons aren’t an option for me. But since I run everything in Docker (including rtl_433) I just wanted to dockerize the auto discovery piece. I forked your code and have it working at https://github.com/zacs/rtl_433_ha_autodiscovery.

The component assumes you’ve already got your own installs of HA, MQTT, and rtl_433, which is how I have my environment setup. Wanted to post here in case it is helpful for other non-HassOS folks.

A good way to double check is to plug the dongle into your normal computer and run rtl_433 there.

This is your problem, which corresponds to register_all true. Looks like rtl_433/conf/rtl_433.example.conf at 4f5241987d1d007907b6acdda1d75adde74a2e61 · merbanan/rtl_433 · GitHub needs to be updated upstream. Regardless, I would remove that setting unless you really think you need it.

That’s great. If you haven’t seen it yet, take a look at the next branch: GitHub - pbkhrv/rtl_433-hass-addons at next

The addon actually should build and work now outside of HA. The main reason we’re not using the upstream rtl_433 Docker container is that Home Assistant recommends using their base images to reduce container size.

I’d be open to PRs to address your use case better as long as it doesn’t break the normal HassOS integration.

Ended up being an issue with the HA version which was causing problems with MQTT. Update & the issue went away. Also removed that line as you’re right, it wasn’t necessary.

1 Like

Good news my dongle is fine.

Next question, is there someway to block it from picking up TPMS sensors? I live near a fairly busy road and so far MQTT is up to over 800 devices.

Hi!

Is there a way to configure the addon so it stops discovering new devices? I live in a populated area and it has discovered some 68 devices in the past 3 days. It then automatically adds them to home assistant, and it’s staring to become a mess.

Thanks in advance

800! Wow. In the short term, I would turn off autostart on the discovery addon and only run it when you’re trying to pick up a new device. That should at least reduce some of the devices being added.

I’ve been thinking about this as well, and I’m not sure of the best solution. After all, I’m sure there’s people who want at least some of those sensors to be registered. I wonder if a combination of a way to add devices to HA, but defaulting them to disabled, along with a way to automatically remove devices not seen for some configurable amount of time would work.

I just went through cleaning up my own HA instance, and I discovered there’s no easy way to bulk-delete devices. As a short-term solution, I’ve suggested only running the discovery addon as-needed in the README at https://github.com/pbkhrv/rtl_433-hass-addons/pull/68.

Hey everyone,
I’m trying to get the info gathered by the rtl_433 addon into HA using the addon rtl_433 MQTT Auto Discovery.
I’ve setup rtl_433 and using MQTT Explorer I’m able to see the data, but the rtl_433 MQTT Auto Discovery addon doesn’t seem to do anything.
This is an example of the data caught by MQTT Explorer:

{"time":"2022-02-13 12:35:12","model":"Bresser-7in1","id":48078,"temperature_C":13.3,"humidity":74,"wind_max_m_s":0.6,"wind_avg_m_s":0.6,"wind_dir_deg":78,"rain_mm":1.2,"light_klx":4.084,"uv":0,"battery_ok":1,"mic":"CRC"}

This is the rtl_433 MQTT Auto Discovery config:

And this is the log for it:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
mqtt found in this Home Assistance instance.
Starting rtl_433_mqtt_hass.py...
MQTT connected: Connection Accepted.

Can somebody help me figure this out?