Repository: Dasher; RTL433 to MQTT Bridge; Ink printer ink reporting

Thanks. That got rid of the errors on the log. Havent, goyt it working yet but that’s progress :slight_smile:

Is there any way to install this on a hassbian install?

Really I’m not sure…
You might be able to follow same or similar install process as is used to create the docker image (although this is for alpine linux not debian).

The install commands are in the dockerfile here:

i.e.

apk add --no-cache --virtual build-deps alpine-sdk cmake git libusb-dev && \
    mkdir /tmp/src && \
    cd /tmp/src && \
    git clone git://git.osmocom.org/rtl-sdr.git && \
    mkdir /tmp/src/rtl-sdr/build && \
    cd /tmp/src/rtl-sdr/build && \
    cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local && \
    make && \
    make install && \
    chmod +s /usr/local/bin/rtl_* && \
    cd /tmp/src/ && \
    git clone https://github.com/james-fry/rtl_433 && \
    cd rtl_433/ && \
    mkdir build && \
    cd build && \
    cmake ../ && \
    make && \
    make install && \
    apk del build-deps && \
    rm -r /tmp/src && \
    apk add --no-cache libusb mosquitto-clients jq

Thanks for the reply.

I’ve been banging my head against a wall trying to figure out a way to read some codes from two 433mhz hunter ceiling fan remotes.

I know they are 433.92mhz and use ASK modulation encoded in PCM. I already have them learned in the broadlink component and can control the fans/lights from HA via a Broadlink RM Pro.

For some reason I haven’t found any good solution to read them (aside from the limited “learn” mode on the broadlink). I’ve tried the 433toMQTTGateway by @1technophile but when i punch a button on the remote nothing happens. I have verified that the hardware works by putting some demo sketches on the NodeMCU boards I have and seeing the results on the serial monitor for the receiver.

From my understanding the sketch he uses is based on the RCSwitch library and it’s likely that the library doesn’t support the proper protocol for the remotes.

I’ve been reading till my head is going in circles trying to find either a hardware/software setup that will read my remotes or trying to find decent ceiling fan remotes that are readable by the above gateway.

Or I’m just going to go in a completely different direction…which is where this thread came into play.

I’m also looking at using pilight and/or rpi-rf and/or ???

I’m completely open to suggestions if you have any.

@hijinx Hi James-

I am interested in trying your addon. However, I have a custom version of acurite.c I use when I build rtl_433 on my own so that it can read a sensor of mine that is not supported in the official version.

Would there be a way I could put that acurite.c file in my hassio config directory then modify your script to overwrite the acurite.c in the src/devices directory just prior to doing the build of rtl_433?

It seems like this would be feasible but I don’t know enough about docker to make it happen, such as what the pathname is for my config folder for docker to access it.

IMO the easiest way for you do get this done is to create a local addon.
This is easiest if you use samba addon mount the addons dir IMO :slight_smile:

  • You’ll need to have forked the rtl_433 repo on github and have your acurite.c updated there
  • In the addons folder in hassio create a new dir named for your addon e.g. \\hassio\addons\rtl433
  • Copy/clone my addon into the folder from here: https://github.com/james-fry/hassio-addons/tree/master/rtl4332mqtt
  • Edit the dockerfile and change row 31 to clone YOUR version of rtl_433 not mine
  • install your locally built addon from hassio add-on store --> local addons

More info here: https://www.home-assistant.io/developers/hassio/addon_development/

Another option would be to modify my addon to allow a volume mount… but I am a bit busy to try it atm :frowning:

Is anyone running the RTL433 addon successfully on HassOS? I’m having trouble starting the addon.

Hello,

I am also having trouble getting this addon working. I need a newbies guide lol. I have a bunch of acurite temperature and humidity sensors I want to get working.

So far I installed the addon and put in my MQTT settings but I get this error in the log of the RTL433 to MQTT Addon Log

MQTT Topic = homeassistant/sensor/currentcost
RTL_433 Protocol = 100
RTL_433 Frequency = 319500000
RTL_433 Gain = 60
RTL_433 Frequency Offset = 350
Registering protocol [1] “Interlogix GE UTC Security Devices”
Registered 1 out of 101 device decoding protocols
Found 1 device(s)
trying device 0: Realtek, RTL2838UHIDIR, SN: 00000001
Found Rafael Micro R820T tuner
Using device 0: Generic RTL2832U OEM
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000.
Bit detection level set to 0 (Auto).
Tuner gain set to 60.000000 dB.
Reading samples in async mode…
Tuned to 319500000 Hz.
Allocating 15 zero-copy buffers
Failed to allocate zero-copy buffer for transfer 0
Falling back to buffers in userspace

any suggestions?

I don’t think I had the same error. Mine was solved by installing the 32bit version instead of the 64bit version of hassos

Can you share your add-on settings?
Do you know if your frequency, gain and offset are correct? Also protocol 100 is for Interlogix GE UTC Security Devices. I don’t know them but it does not seem a humidity sensor like you mentioned

How do you know if you have the 32 bit or the 64 bit? lol. I just followed the instructions off the website for a Raspberry Pi 2. I noticed the image files for Raspberry Pi 3 has a separate 32 bit and 64 bit.

I am unsure about the gain and offset, but my frequency should be 433290000. Also I believe the protocol was 40 or 11 but I went back to default before I posted my log above to see if the error would disappear but didn’t. No matter what I change my frequency, gain, offset or protocol too I receive the same error.

I can’t post my addon settings at the moment. I updated to 0.75.0 and can’t access my Hass.io screen. Need to figure out how to fix that.

Thanks

Okay I was able to fix this but now I don’t see anything in MQTT. Doesn’t seem to be picking up the sensors. Here are my addon settings:

{
“mqtt_host”: “192.168.0.20”,
“mqtt_user”: “",
“mqtt_password”: "
”,
“mqtt_topic”: “homeassistant/sensor/currentcost”,
“protocol”: 40,
“frequency”: 433920000,
“gain”: 0,
“frequency_offset”: 350
}

and my log:

Starting RTL_433 with parameters:
MQTT Host = 192.168.0.20
MQTT User = ****
MQTT Password = ****
MQTT Topic = homeassistant/sensor/currentcost
RTL_433 Protocol = 40
RTL_433 Frequency = 433920000
RTL_433 Gain = 0
RTL_433 Frequency Offset = 350
Disabling all device decoders.
Registered 0 out of 108 device decoding protocols
Found 1 device(s)
trying device 0: Realtek, RTL2838UHIDIR, SN: 00000001
Found Rafael Micro R820T tuner
Using device 0: Generic RTL2832U OEM
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000.
Bit detection level set to 0 (Auto).
Tuner gain set to Auto.
Reading samples in async mode…
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers

The sensors I have are Acurite 592TX which is what protocol 40 is. Any help would be greatly appreciated.

Thanks

Here’s what I’m getting…

/rtl2mqtt.sh: line 2: 
: not found
/rtl2mqtt.sh: line 4: 
: not found
/rtl2mqtt.sh: line 7: 
: not found
/rtl2mqtt.sh: line 14: 
: not found
/rtl2mqtt.sh: line 158: 
: not found
/rtl2mqtt.sh: line 161: 
: not found
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
jq: error: Could not open file /data/options.json
: No such file or directory
/rtl2mqtt.sh: line 171: 
: not found
Starting RTL_433 with parameters:
MQTT Host = 

MQTT User = 

MQTT Password = 

MQTT Topic = 

RTL_433 Protocol = 

RTL_433 Frequency = 

RTL_433 Gain = 

RTL_433 Frequency Offset = 

/rtl2mqtt.sh: line 182: 
: not found
/rtl2mqtt.sh: line 184: 
: not found
/rtl2mqtt.sh: line 202: syntax error: unexpected "done" (expecting "then")

Hass.io 0.76.0 > System > Hardware shows the NooElec receiver:

input:
MCE IR Keyboard/Mouse (dvb_usb_rtl28xxu)
Realtek RTL2832U reference design
core-ssh:/# lsusb
Bus 001 Device 005: ID 0bda:2838
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 0424:2514
Bus 001 Device 002: ID 0424:2514
Bus 001 Device 006: ID 0424:7800
Bus 001 Device 004: ID 10c4:8a2a

I’m sure I have the protocol options wrong as I’m going for Honeywell/Ademco motion sensors and I don’t see that in the big list, but it seems like something else is missing.

Any ideas?

Thanks

hello @hijinx and thanks for the addon.

I am trying to add my doorbell so I can implement to HA.

I use this command “/usr/local/bin/rtl_433 -a -t -F json | while read line” so that rtl gets into analyse mode and also save the results in cu8 files.

I am getting a lot of pulses but cant find the cu8 files. I connect with winscp and ssh to hassio but look in every folder and cant find any.
also the “set -x ## uncomment for MQTT logging…” line in your script does it work?
thanks
theodoros

signal_len = 156115, pulses = 675
Iteration 1. t: 107 min: 76 (391) max: 139 (284) delta 2900
Iteration 2. t: 100 min: 65 (316) max: 136 (359) delta 130
Iteration 3. t: 100 min: 65 (316) max: 136 (359) delta 0
Pulse coding: Short pulse length 65 - Long pulse length 136
Short distance: 56, long distance: 127, packet distance: 244
p_limit: 100
bitbuffer:: Number of rows: 15
[00] {45} 7c 81 68 f2 f9 c0 : 01111100 10000001 01101000 11110010 11111001 11000
[01] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[02] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[03] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[04] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[05] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[06] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[07] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[08] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[09] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[10] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[11] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[12] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[13] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
[14] {45} fc 81 68 f2 f9 c0 : 11111100 10000001 01101000 11110010 11111001 11000
signal_bsize = 393216 - sg_index = 2097152
start_pos = 1532644 - buffer_size = 3145728
*** Saving signal to file g150_433.92M_250k.cu8
*** Writing data from 1532644, len 393216

I got this to work:
{
“mqtt_host”: “hassio.local”,
“mqtt_user”: “XXXX”,
“mqtt_password”: “XXXX”,
“mqtt_topic”: “homeassistant/sensor/currentcost”,
“protocol”: 40,
“frequency”: 433920000,
“gain”: 0,
“frequency_offset”: 350
}

Starting RTL_433 with parameters:
MQTT Host = hassio.local
MQTT User = XXXX
MQTT Password = XXXX
MQTT Topic = homeassistant/sensor/currentcost
RTL_433 Protocol = 40
RTL_433 Frequency = 433920000
RTL_433 Gain = 0
RTL_433 Frequency Offset = 350
Registering protocol [1] “Acurite 592TXR Temp/Humidity, 5n1 Weather Station, 6045 Lightning”
Registered 1 out of 101 device decoding protocols
Found 1 device(s)
trying device 0: Realtek, RTL2838UHIDIR, SN: 00000001
Found Fitipower FC0013 tuner
Using device 0: Generic RTL2832U OEM
Exact sample rate is: 250000.000414 Hz
Sample rate set to 250000.
Bit detection level set to 0 (Auto).
Tuner gain set to Auto.
Reading samples in async mode…
Tuned to 433920000 Hz.
Allocating 15 zero-copy buffers

I’m trying to get access to the MQTT agent but i have no success i have this error when i start Hassio, my setup is: Hassio in a docker on a ubuntu server.

Config entry for mqtt not ready yet. Retrying in 5 seconds.
Configuration.yaml

mqtt
mqtt:
broker: 192.168.88.10

Config of the addon:

{
“mqtt_host”: “192.168.88.10”,
“mqtt_user”: “”,
“mqtt_password”: “”,
“mqtt_topic”: “/homeassistant/sensor/Temperature”,
“protocol”: 10,
“frequency”: 433920000,
“gain”: 60,
“frequency_offset”: 350
}

Log of the addon:

Starting RTL_433 with parameters:
MQTT Host = 192.168.88.10
MQTT User =
MQTT Password =
MQTT Topic = /homeassistant/sensor/Temperature
RTL_433 Protocol = 10
RTL_433 Frequency = 433920000
RTL_433 Gain = 60
RTL_433 Frequency Offset = 350
rtl_433 version 18.12-204-gb1b62f2 branch master at 201905030920 inputs file rtl_tcp RTL-SDR
Trying conf file at “rtl_433.conf”…
Trying conf file at “/root/.config/rtl_433/rtl_433.conf”…
Trying conf file at “/usr/local/etc/rtl_433/rtl_433.conf”…
Trying conf file at “/etc/rtl_433/rtl_433.conf”…

Consider using “-M newmodel” to transition to new model keys. This will become the default someday.
A table of changes and discussion is at Add new model keys option by zuckschwerdt · Pull Request #986 · merbanan/rtl_433 · GitHub.

Registered 1 out of 125 device decoding protocols [ 10 ]
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 60.000000 dB.
Frequency correction set to 350 ppm.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers

If i do a netstat -an |grep 1883 i have nothing.

EDIT: I installed the MQTT broker, and added the sensors but they are empty:

  • platform: mqtt
    name: Temperature
    state_topic: “homeassistant/sensor/Temperature”
    unit_of_measurement: “°C”
    value_template: ‘{{ value_json.temperature_C }}’
  • platform: mqtt
    name: Humidite
    state_topic: “homeassistant/sensor/temperature”
    unit_of_measurement: “%”
    value_template: ‘{{ value_json.humidity }}’

Thanks for your help

In the rtl2mqtt.sh file try uncommenting the line:

#set -x ## uncomment for MQTT logging...

It will show in the addon log all the commands executed by the script…

Ahh thanks ! it help me to diagnose the problem !

I added a new addon to report printer ink levels that was inspired by this custom component.

This addon is very much a hack job (esp the shell script that calls ink and mosquitto client for MQTT) but it works great for my Canon Pixma 5300, and supports HA MQTT autodiscovery - albeit in a very hard coded way :wink:

You can find it in my hassio addons repo:

To get other printers working you will probably need to edit the ink2mqtt.sh script.

Here is my lovelace card to show ink levels using the superb custom cards bar-card and vertical-stack-in-card:

image

type: 'custom:vertical-stack-in-card'
title: Canon MG5300 Printer Ink
cards:
  - type: 'custom:bar-card'
    columns: 5
    direction: up
    entities:
      - color: MediumTurquoise
        entity: sensor.canon_mg5300_cyan_ink_level
      - color: MediumOrchid
        entity: sensor.canon_mg5300_magenta_ink_level
      - color: Gold
        entity: sensor.canon_mg5300_yellow_ink_level
      - color: Black
        entity: sensor.canon_mg5300_black_ink_level
      - color: Black
        entity: sensor.canon_mg5300_photoblack_ink_level
    height: 200px
    max: 100
    min: 0
    padding: 2px
    target: 20
    title_position: bottom
    icon_position: inside
    unit_of_measurement: '%'
    width: 100%

Hope it helps someone…

I installed the add-on and see it’s working, created sensors and tested out the template json parsing with dev tools > templates, but I can’t get the state to change.

Any pointers?

Starting RTL_433 with parameters:
MQTT Host = 192.168.2.10
MQTT User = mqtt-user
MQTT Password = mqttpwd
MQTT Topic = homeassistant/sensor/honeywell
RTL_433 Protocol = 70
RTL_433 Frequency = 344975000
RTL_433 Gain = 0
RTL_433 Frequency Offset = 50
+ + read line
/usr/local/bin/rtl_433 -F json -R 70 -f 344975000 -g 0 -p 50
rtl_433 version 18.12-210-g7ab2894 branch master at 201905261917 inputs file rtl_tcp RTL-SDR
Trying conf file at "rtl_433.conf"...
Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
	Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
	A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.
Registered 1 out of 126 device decoding protocols [ 70 ]
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.
Frequency correction set to 50 ppm.
Tuned to 344.975MHz.
Allocating 15 zero-copy buffers
+ echo '{"time"' : '"2019-06-12' '23:56:06",' '"model"' : '"Honeywell' Door/Window 'Sensor",' '"id"' : 827623, '"channel"' : 8, '"event"' : 128, '"state"' : '"open",' '"heartbeat"' : '"no"}'+ 
jq --raw-output .model
+ tr -s ' ' _
+ DEVICE=Honeywell_Door/Window_Sensor
+ + jq --raw-output .id
echo '{"time"' : '"2019-06-12' '23:56:06",' '"model"' :+ tr -s ' ' _
 '"Honeywell' Door/Window 'Sensor",' '"id"' : 827623, '"channel"' : 8, '"event"' : 128, '"state"' : '"open",' '"heartbeat"' : '"no"}'
+ DEVICEID=827623
+ MQTT_PATH=homeassistant/sensor/honeywell
+ '[' 28 ]
+ MQTT_PATH=homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor
+ '[' 6 ]
+ MQTT_PATH=homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/827623
+ '[' -w /tmp/rtl_433.log ]
+ echo '{"time"' : '"2019-06-12' '23:56:06",' '"model"' : '"Honeywell' Door/Window 'Sensor",' '"id"' : 827623, '"channel"' : 8, '"event"' :+  128, '"state"' : '"open",' '"heartbeat"' : '"no"}'
/usr/bin/mosquitto_pub -h 192.168.2.10 -u mqtt-user -P mqttpwd -i RTL_433 -r -l -t homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/827623
+ read line

home-assistant.log

2019-06-13 00:22:03 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/827623: b'{"time" : "2019-06-13 00:21:21", "model" : "Honeywell Door/Window Sensor", "id" : 827623, "channel" : 8, "event" : 128, "state" : "open", "heartbeat" : "no"}'
binary_sensor:

  - platform: mqtt
    state_topic: homeassistant/sensor/honeywell
    #state_topic: "homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/827623"
    name: "Honeywell Sunroom Door East"
    qos: 0
    device_class: door
    value_template: '{% if (value_json.event is equalto 160) %} on {% elif (value_json.event is equalto 128) %} off {% else %} {{states.binary_sensor.honeywell_sunroom_door_east.state}} {% endif %}'

If I use the topic with the device id in it (like the commented line in the sensor), I see this…

2019-06-13 01:17:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/998796: b'{"time" : "2019-06-13 01:16:25", "model" : "Honeywell Door/Window Sensor", "id" : 998796, "channel" : 8, "event" : 0, "state" : "closed", "heartbeat" : "no"}'
2019-06-13 01:17:17 WARNING (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: Honeywell Front Door with state_topic: homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/998796

````

Made some progress… It has to do with my binary_sensor. If I create it as a sensor, it detects the state change, but can’t be set to device_class: door. So it doesn’t automatically have the nice icon and color change…

sensor:
- platform: mqtt
  state_topic: "homeassistant/sensor/honeywell/Honeywell_Door/Window_Sensor/998796"
  name: "Honeywell Front Door"
  value_template: '{% if (value_json.id is equalto 998796) and (value_json.event is equalto 128) %} on {% elif (value_json.id is equalto 998796) and (value_json.event is equalto 0) %} off {% else %} {{states.sensor.honeywell_front_door.state}} {% endif %}'