Home Assistant Add-on: rtl_433 with MQTT auto discovery

Greetings all. Getting error installing. Looks like a permissions error. I use raspbarian on a raspberry pi 4 with a managed install of Home Assistant and no errors with other add ins. Thoughts?

Failed to install add-on

The command ‘/bin/ash -o pipefail -c python3 -m ensurepip && pip3 install --no-cache --upgrade pip’ returned a non-zero code: 1

hmmm. Tried so far the following but still no joy.

  1. set default python to 3.7
  1. Enabled AppArmor support

This worked. Needed to update file - libseccomp2 library.

https://community.home-assistant.io/t/migration-to-2021-7-fails-fatal-python-error-init-interp-main-cant-initialize-time/320648/19

1 Like

Glad to hear you got it running, thanks for sharing the solution.

Hmm. Seems to be working but entities are not showing up. Baffled. Here is some info and perhaps wiser heads might see the problem.

rtl_433

# config for rtl_433
output mqtt://192.168.214.200:1883,user=xx,pass=yy
# output kv 
# output json
frequency 433.92M
convert si
report_meta newmodel

And here is the log.

[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.
Starting rtl_433 -c /config//rtl_433.conf
rtl_433 version 21.05 branch  at 202105091238 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Publishing MQTT data to 192.168.214.200 port 1883
Publishing device info to MQTT topic "rtl_433/9b13b3f4-rtl433/devices[/type][/model][/subtype][/channel][/id]".
Publishing events info to MQTT topic "rtl_433/9b13b3f4-rtl433/events".
Publishing states info to MQTT topic "rtl_433/9b13b3f4-rtl433/states".
Registered 157 out of 186 device decoding protocols [ 1-4 8 11-12 15-17 19-23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151-161 163-168 170-175 177-186 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers
MQTT Connected...
baseband_demod_FM: low pass filter for 250000 Hz at cutoff 25000 Hz, 40.0 us
MQTT Connection established.
pulse_FSK_detect(): Maximum number of pulses reached!
pulse_FSK_detect(): Maximum number of pulses reached!
pulse_FSK_detect(): Maximum number of pulses reached!

If I redirect output to console (including json) I get messages, i.e.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  
time      : 2021-09-20 17:29:40
model     : Cotech-367959 ID        : 211
Battery   : 1            Temperature: 22.3 C       Humidity  : 52 %          Rain      : 17.7 mm       Wind direction: 259       Wind      : 0.0 m/s       Gust      : 0.0 m/s       Light Intensity: 69627 lux UV Index  : 251          Integrity : CRC
{"time" : "2021-09-20 17:29:40", "model" : "Cotech-367959", "id" : 211, "battery_ok" : 1, "temperature_C" : 22.333, "humidity" : 52, "rain_mm" : 17.700, "wind_dir_deg" : 259, "wind_avg_m_s" : 0.000, "wind_max_m_s" : 0.000, "light_lux" : 69627, "uv" : 251, "mic" : "CRC"}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
model     : Prologue-TH  subtype   : 9             id        : 60
Channel   : 3            Battery   : 0             Temperature: 23.90 C      Humidity  : 47 %          Button    : 0
{"time" : "2021-09-20 17:29:54", "model" : "Prologue-TH", "subtype" : 9, "id" : 60, "channel" : 3, "battery_ok" : 0, "temperature_C" : 23.900, "humidity" : 47, "button" : 0}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

Meanwhile the discovery script seems to be doing its thing, i.e.

[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.
Starting rtl_433_mqtt_hass.py...
MQTT connected: Connection Accepted.

homeassistant/sensor/Cotech-367959-211/Cotech-367959-211-B/config : {"device_class": "battery", "name": "Cotech-367959-211-B", "unit_of_measurement": "%", "value_template": "{{ float(value|int) * 99 + 1 }}", "state_topic": "rtl_433/9b13b3f4-rtl433/devices/Cotech-367959/211/battery_ok", "unique_id": "Cotech-367959-211-B", "device": {"identifiers": "Cotech-367959-211", "name": "Cotech-367959-211", "model": "Cotech-367959", "manufacturer": "rtl_433"}}

homeassistant/sensor/Prologue-TH-9-3-60/Prologue-TH-9-3-60-B/config : {"device_class": "battery", "name": "Prologue-TH-9-3-60-B", "unit_of_measurement": "%", "value_template": "{{ float(value|int) * 99 + 1 }}", "state_topic": "rtl_433/9b13b3f4-rtl433/devices/Prologue-TH/9/3/60/battery_ok", "unique_id": "Prologue-TH-9-3-60-B", "device": {"identifiers": "Prologue-TH-9-3-60", "name": "Prologue-TH-9-3-60", "model": "Prologue-TH", "manufacturer": "rtl_433"}}

Strange… Everything seems to be doing its thing.
Anything relevant in HA logs?
Do you have other entities (from sources other than rtl_433) that show up under the MQTT integration?

Resolved. For historical reasons the discovery topic prefix had been changed (now fixed). Thanks for your help.

mqtt:
  discovery: true
#  discovery_prefix: homeassistantulog
  broker: 192.168.214.200
  port: 1883
  client_id: home-assistant-1
  keepalive: 60
  username: **
  password: **
1 Like

Has anyone figured out how to listen to two different frequencies using two different RTLSDR devices using the same instance? I’d like to listen to 433.92M and 916.8M. Can I load a second instance of rtl_433 in home assistant?

device 0
protocol 40
frequency 433.92M

device 1
frequency 916.8M
protocol 116
pulse_detect classic
sample_rate 250k

EDIT: I ended up running a separate docker container for rtl_433, completely separate from HA. I used portainer’s command line option to enter the correct start up information.

@akifbayram I’ve been working on multiple radio support over at https://github.com/pbkhrv/rtl_433-hass-addons/pull/14. I’ve been using that branch myself for the past few months successfully with two radios to listen to weather reports on 433.92M and my doorbell on 916.8M.

2 Likes

That’s perfect! It’s exactly what I needed. What’s your recommended method to use your multidevice branch? I’m having difficulties adding that branch the HA add-on repository. Should I use a separate docker container?

Since you are running custom docker containers, I think you know how to use the command line. In that case, you can clone my fork from git with git clone https://github.com/deviantintegral/rtl_433-hass-addons.git into the addons directory and run git checkout multidevice, getting updates with git pull.

Otherwise, you can get a zip from https://github.com/deviantintegral/rtl_433-hass-addons/tree/multidevice by clicking on the code button, which can be extracted to the same addons directory.

Personally, I have the samba addon so I can develop on my laptop with the addons directory mounted. It wouldn’t perform well for large projects, but for a project in the 10s of files it’s pretty smooth.

Once the addon is in the directory, click “reload addons” (I think) in the three dot menu in the addon list. Then it will show up to install like normal in the UI. It will take a little longer to install because it will build and compile rtl_433 and the docker container locally, instead of pulling a prebuilt image.

If you end up wanting to try out any changes after pulling or editing yourself, you can click “rebuild” and then “restart” in supervisor to update the containers.

1 Like

I am running both the rtl_433 and the rtl_433 mqtt autodiscovery, the latter only every once in a while and it has discovered both my weatherstations. Brilliant. However:
I have a few other 433 sensors and buttons and I struggle to use them. They are not being auto discovered, so I tried to sniff them on MQTT. When I start listening to * on Developer/events i see lots of events, including the weather stations. However, when I listen to the topic rtl_433 or rtl_433/* or rtl_433/9b13b3f4-rtl433/events i get nothing.
The rtl_433 add on’s log file says

Publishing events info to MQTT topic "rtl_433/9b13b3f4-rtl433/events".
Publishing states info to MQTT topic "rtl_433/9b13b3f4-rtl433/states".

And the auto discovery as per the configuration listens - successfully it seems - to rtl_433/+/events

It feels like i am making a very basic mistake…i know there are the right messages being sent and read, but I cant seem to see to be able to see any of the messages on MQTT, not the ones that already work, nor the ones I am hoping to find from new devices. Why?

1 Like

Use MQTT Explorer to see what is passing through your broker.

1 Like

Thanks a lot for this. I can see the MQTT traffic now from the weatherstations which I also see in HA. But after listening for some time, the only other device I can see is the button press of RFBridge. Other sensors and buttons that are supposed to send on 433 apdo not show up. Any tipp on how I can find them? I have all the default protocols enabled on the 433 add on….Thanks!

Thank you so much! Your detailed and thoughtful instructions were very helpful.

I was able to get the addon up and running with the templates but I’m running into a small issue.

How are you avoiding the issue with MQTT refusing the connection from the multiple radios? I’ve tried different MQTT logins but the issue appears to originate at the client-id used by the addon.

rtl_433 log

[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 6: warning: here-document at line 1 delimited by end-of-file (wanted `EOD')
Starting rtl_433 with accurite.conf...
[accurite] rtl_433 version 21.05 branch  at 202105091238 inputs file rtl_tcp RTL-SDR
Starting rtl_433 with doorbell.conf...
[doorbell] rtl_433 version 21.05 branch  at 202105091238 inputs file rtl_tcp RTL-SDR
[doorbell] Use -h for usage help and see https://triq.org/ for documentation.
[doorbell] Publishing MQTT data to 192.168.1.199 port 1883
[doorbell] Publishing device info to MQTT topic "rtl_433/local-rtl433/devices[/type][/model][/subtype][/channel][/id]".
[doorbell] Publishing events info to MQTT topic "rtl_433/local-rtl433/events".
[doorbell] Publishing states info to MQTT topic "rtl_433/local-rtl433/states".
[doorbell] 
[doorbell] New defaults active, use "-Y classic -s 250k" for the old defaults!
[doorbell] 
[doorbell] Registered 1 out of 186 device decoding protocols [ 116 ]
[doorbell] Found Rafael Micro R820T tuner
[doorbell] Exact sample rate is: 250000.000414 Hz
[doorbell] [R82XX] PLL not locked!
[doorbell] Sample rate set to 250000 S/s.
[doorbell] Tuner gain set to Auto.
[doorbell] Tuned to 916.800MHz.
[doorbell] Allocating 15 zero-copy buffers
[doorbell] MQTT Connected...
[doorbell] baseband_demod_FM: low pass filter for 250000 Hz at cutoff 25000 Hz, 40.0 us
[doorbell] MQTT Connection established.
[doorbell] MQTT Connection failed...[accurite] Use -h for usage help and see https://triq.org/ for documentation.
[accurite] Publishing MQTT data to 192.168.1.199 port 1883
[accurite] Publishing device info to MQTT topic "rtl_433/local-rtl433/devices[/type][/model][/subtype][/channel][/id]".
[accurite] Publishing events info to MQTT topic "rtl_433/local-rtl433/events".
[accurite] Publishing states info to MQTT topic "rtl_433/local-rtl433/states".
[accurite] Registered 1 out of 186 device decoding protocols [ 40 ]
[accurite] Found Rafael Micro R820T tuner
[accurite] Exact sample rate is: 250000.000414 Hz
[accurite] [R82XX] PLL not locked!
[accurite] Sample rate set to 250000 S/s.
[accurite] Tuner gain set to Auto.
[accurite] Tuned to 433.920MHz.
[accurite] Allocating 15 zero-copy buffers
[accurite] MQTT Connected...
[accurite] MQTT Connection established.
[accurite] MQTT Connection failed...
[accurite] MQTT Connected...
[accurite] MQTT Connection established.
[accurite] MQTT Connection failed...
[accurite] MQTT Connected...

MQTT broker log (repeated)

1634579256: New client connected from *.*.*.* as rtl_433-b6fbffff (p2, c0, k60, u'****').
1634579256: New connection from *.*.*.* on port 1883.
1634579256: Client rtl_433-b6fbffff already connected, closing old connection.

I think you need to specify the device first: https://github.com/merbanan/rtl_433/issues/1129

1 Like

That was it! Thank you again.

Hello.
Is it possible to set up so that you listen to several frequencies at the same time?
for example, 433.92MHz and 869.68MHz

Probably not. your SDR can only be tuned to one frequency. You would need 2 SDR dongles to listen to 2 frequencies.