Read RF with Raspberry PI GPIO Binary Sensor

It seems like a BIG PROBLEM just to read RX from 433MHz receiver which receives signals from motion sensor. It is no problem to read GPIO27 with python script. Some people use PILIGHT but there are issues with Raspi3, hassbian etc. RF to MQTT on the same raspberry where runs HA seems also be some kind of problem - don´t know why.

Would it be possible to read those data from GPIO27 (attached to RXB6 RX 433MHz receiver) and use them for automation (trigger alarm)? Thank you.

If you can do this, you can probably create a command line sensor, and get the information to HA that way.

Alternatively, you can update your Python script to send MQTT messages to HA.

Or a third way would be to change your script to update a sensor using the rest api REST API | Home Assistant Developer Docs

Thanks @gpbenton “Alternatively, you can update your Python script to send MQTT messages to HA.” Do you know how? Or how to create a command line sensor?

Well I use an RF Link board but it seems it is possible to do so using …

You need to include the paho-mqtt package in your python script and use the publish single interface at the point where you have determined the value of the sensor to send the MQTT message.

@gpbenton Thank you - but I´m a newbie. Too complicated for me :frowning:

@keithh666 Maybe this could be the way with Pi RF Switch. But switch needs states ON and OFF. Motion sensor only sends single code - if movement is detected. How to solve some “autooff” of this switch. Do you think it is possible with switch if I need sensor?

@keithh666 IT IS NOT POSSIBLE TO USE PI RF SWITCH - because this component is for sending signal, not receiving. I need to receive signal FROM motion detector and create automation based on this (trigger alarm).

You can use rtl_433 and a supported DVB-T tuner to receive (only receive) 433mhz commands.
There are approx 90 supported protocols.
I understand it works well on RPi - more in this thread:

YOU DON’T NEED TO SHOUT!!! The receive part can be done with the rpi-rf · PyPI rpi_rf module.

I use a combination of pilight and RF Link for my 433Mhz devices as they can both receive and transmit.

The way to get over the fact that most cheap PIR sensors only send a movement detected signal is to create an automation that runs on reception of said “on” signal and delay till just before the retrigger period ends and turn it off. I do the following for my cheap PIR sensors…

From automation.yaml

###############################################################################################
#                                                                                             #
# Turn off the PIR's once they have triggered                                                 #
#                                                                                             #
###############################################################################################
       
 - alias: 'Turn off PIRs'
   trigger:
     - platform: state
       entity_id: switch.rfl_bedroom_pir, switch.rfl_livingroom_pir, switch.rfl_hall_pir, switch.rfl_kitchen_pir
       from: 'off'
       to: 'on'
   action:
     - delay: '00:00:10'
     - service: switch.turn_off
       entity_id: switch.rfl_bedroom_pir, switch.rfl_livingroom_pir, switch.rfl_hall_pir, switch.rfl_kitchen_pir

I hope that helps :slight_smile:
This thread may also help…

And this thread…

And this thread…

Thank you @keithh666. I´m NOT SHOUTING. This is only for better navigation throught this node for anybody who only scans the text :slight_smile:

Pilight seems to be mighty tool but there are many problemy on Raspberry3 with Hassbian. I didn´t get it to work. Regarding to @hijinx solution. Great job. But I prefer not to run docker or anything other on the same device where I run HA. I want to let as much resources as possible for HA itself. I want to do everything in single device. If this will be not possible I will use RFlink (Arduino+RF) - seems to be cheap and versatile solution with good support. Yes, not cheaper than @hijinx but without docker.

Anyway I just don´t want to accept that is is IMPOSSIBLE to receive dummy data from motion sensor directly to HA via GPIO. Many people talk about how easy it is but nowhere on whole internet you can´t find a receipt how to do it. Really strange.

1 Like

OK. Maybe I´ll try HASSIO because there is addon Repository: Dasher; RTL433 to MQTT Bridge; Ink printer ink reporting
I just hope it will be possible to do by us - the mortals :slight_smile:

I’m not really sure what you are expecting. The direct way of using the GPIO with HA is using the GPIO interface.

If this doesn’t work for your sensor, then I have suggested 2 ways of modifying your python script to send data in to HA. There really isn’t much else anyone can offer.

@hijinx It would be great if you could prepare some step-by-step tutorial for RTL433 to MQTT for HASSIO. I will buy you a beer :smiley:

Very first step is to check your device(s) is one of the 94 device protocols supported by rtl_433 here:

It can be difficult to check due to so much rebadging of the same kit.
If your device(s) are not supported then there is no reason to try :slight_smile:

Assuming it is, you need an RTL compatible DVB tuner.
You can get from ebay for £6-7 if shipped from china.

My device is cheap motion sensor - there is listed as [87] Generic wireless motion sensor. So I don´t know how to check if it will be OK.

Using python sniffer I can see that the motion sensor broadcast this:
[INFO] rfrx: 7621980 [pulselength 482, protocol 1]

I have no problem to buy some RTL2832 tuner.

You can try looking in the source code for the protocol - e.g. https://github.com/merbanan/rtl_433/blob/master/src/devices/generic_motion.c

But best way is to get a tuner and run rtl_433 with no protocol specified or with the test mode on.

I knew in advance that my currentcost sensor would work… but my front door bell does not (although the event is captured it cannot be decoded)

@keithh666 or other Please could you recommend how to read from GPIO using rpi_gpio?

RXB6 433MHz receiver is connected to raspberry´s GPIO. RF sniffing python script is able to read codes from rf devices. How to get it into home assistant using rpi_gpio?

You read from the gpio using the folowing …

binary_sensor:
  - platform: rpi_gpio
    ports:
      11: PIR Office
      12: PIR Bedroom

However as I assume you have figured out your pir is not directly connected it’s using RF433 so you need a program to decode the RF and send a appropriate message to HA, this is usually done with either some other HW such as RF Link, Telldus, RFXTX or some RF receiver and transmitter directly connect to the PI with either pilight or some other SW decoding the RF to send a message to HA. You could use some other software to decode the RF and use it to toggle the GPIO pins directly but that would not be efficient and you only have so many GPIO’s. If you have the Rx’er and Tx’er attached to the PI then pilight is the best option that I know. If you have some other software sniffing the code from your Rx’er then just modify it to send a MQTT message to HA.

Hope that helps.

Thanks Keith. I´m right now on the way to try both MQTT and Pilight. I would like to have all on single board (raspberry) so we will see what is better solution. I will need MQTT for other switches so I hope this will be better way for me but seems like there is no direct solution for RF2MQTT on Pi. All I checked till now was based on arduino :frowning: