RPi RF Receiver addon

What the addon does is just reading the codes from the GPIO 27 and writing it in the MQTT database. If you want, you can make your own addon changing the pin number or I could try to make a new one. I’m not sure I’d be able to add another pin inside the script this addon is using but I could try.

it is from a remote control. But this one is a old one, it was just to test the connectivity.
I’m waiting to receive a rolling code remote controll, then I will clone the ones that I have now working. Having the new remote control working I want to connect that remote control to my RPI using a relay, that relay will “press” the button and trigger the required action.

ok @MACscr, I just added a new file called rpi-rf_receive2.py where I made some changes.

If you use this new one (just remember to rename it to rpi-rf_receive.py), you’ll be able to read codes from two different GPIOs, the #27 and the #22 which is next to the 27.
Refer to this image to find out where it is:

https://www.element14.com/community/servlet/JiveServlet/previewBody/73950-102-11-339300/pi3_gpio.png

Then you’ll have 2 MQTT sensors:
sensors/rf/receiver —> GPIO 27
sensors/rf/receiver2 —> GPIO 22
Since I’m not really a coder I hope it will work and when I’ll be at home tonight I’ll try to connect another receiver to see if it works (the one on the GPIO 27 still works correctly).
Sorry for my english guys.

1 Like

Ok, it looks like it’s working. Both my 433 MHz receivers are receiving the same codes on two different pins. So it should work also with your 434 Mhz receiver. This could also be useful if someone wants to be sure to receive the RF codes using two different receivers :slight_smile:
Obviously you can change the GPIO pin if you’re already using the #22 just editing the rpi-rf_receive.py script and changing default=22 with something else.

First, thanks for the nice add on. Can you help me understanding the signals I’m receiving? The sensor works and gives big numbers. For what I understood the remote that I am using uses the “hx2262 2014T” chip. I guess that has a pulse length of 422 µs but this I do not see in the log.

The sockets I can trigger using the rcswitch-pi libary on a different project.

I have the feeling that the codes I should be recieving are called “Tri-State”, but that this is not what is displayed in the sensor. Any chance to modify the add on such, that this “Tri-State” is returned (Something like “0F0F0F0FFF0F”)? Would that be useful?

Many thanks

hey @Rudertier, actually my addon uses the python module you can find here:

and on that page there’s a link to another page where you can find a full list of compatible devices and chipsets and I’m afraid that your remote chipset it’s not really compatible:

Thanks again for the quick reply.
As I said, I use this libary to generate rf signals to control the outlet successfully. So caling mySwitch.switchOn(11111, 4) switches the outlet.

void RCSwitch::switchOn(char* sGroup, int nChannel) {
 this->sendTriState( this->getCodeWordA(sGroup, nChannel, true) );
}

Shouldn’t the remote send exactly the same code?

Hi Pantomax!

First of all, thank you for your work on this addon!

I’ve installed it and it seems working. More or less… :slight_smile:

So, here is my log:

2018-01-22 19:12:50 - [INFO] rpi-rf_receive: 4 [pulselength 1776, protocol 2]
Error: Host is unreachable
2018-01-22 19:12:53 - [INFO] rpi-rf_receive: 262144 [pulselength 1113, protocol 4]
Error: Host is unreachable
2018-01-22 19:12:56 - [INFO] rpi-rf_receive: 4194368 [pulselength 1970, protocol 4]
Error: Host is unreachable
2018-01-22 19:12:59 - [INFO] rpi-rf_receive: 256 [pulselength 1027, protocol 5]
Error: Host is unreachable
2018-01-22 19:13:02 - [INFO] rpi-rf_receive: 1 [pulselength 1048, protocol 4]
Error: Host is unreachable
2018-01-22 19:13:05 - [INFO] rpi-rf_receive: 2 [pulselength 1109, protocol 5]
Error: Host is unreachable
2018-01-22 19:13:08 - [INFO] rpi-rf_receive: 8192 [pulselength 865, protocol 5]
Error: Host is unreachable
2018-01-22 19:13:11 - [INFO] rpi-rf_receive: 184 [pulselength 153, protocol 3]
Error: Host is unreachable
2018-01-22 19:13:14 - [INFO] rpi-rf_receive: 32 [pulselength 341, protocol 1]
Error: Host is unreachable

This is not all the log, but my problem can be seen. Every 2nd line is host unreachable. I tried with two different receiver, first was the original what was mentioned in the rpi-rf instruction, second one is an LR45B (still cheap but with less noise).
Also I can’t catch the same code from the same remote at least two times.
Tried with 3.3v and 5v power too.

I have a broadlink rm pro, and it could learn my remotes (they are for my shutters) and I can use broadlink to control them, so I’m happy with my install now, just trying new things.

Any idea for the host problem or the code receiving?

Regards
Tamás

Hi there Tamás
probably the problem is that the addon is trying to record the mosquitto sensor but it cannot find the mosquitto broker. Did you modified the rpi-rf_receive.py script editing these fields?

mosquitto_address = "192.168.1.100"
mosquitto_port = "1883"
mosquitto_user = "homeassistant"
mosquitto_password = "REDACTED" 

Is it the mosquitto broker addon installed and started? :slight_smile:

Any update

Not Yet, only yesterday I have received my my multi frequency remote control. Now I’m waiting for the RPI relay. It takes time, everything coming from china :slight_smile:

Thanks Pantomax!

I forgot to change cos I was using exact these IP :slight_smile: just forgot that I’ve changed it to 109 some weeks ago :stuck_out_tongue:
Since then there are no unreachable messages.

I have set up a transmitter module too, and I can clearly receive the sent out codes.
But still no luck with the remotes, it feels like that this component don’t know the remotes protocol.

Anyway the receiver works :slight_smile:

1 Like

I am getting this as the last few messages in the hassio RPi RF Receiver log (under hassio add-ons in the frontend):

Successfully built rpi-rf RPi.GPIO
Installing collected packages: RPi.GPIO, rpi-rf
Successfully installed RPi.GPIO-0.6.3 rpi-rf-0.9.6
  File "/share/rpi-rf_receive.py", line 7
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax

Should I expect to see the received codes in my home-assistant.log file?

Did you remember to copy the rpi-rf_receive.py file in the share folder?

Yes it is there. This is what the first few lines say:







<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://assets-cdn.github.com">
  <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com">
  <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">

I think I see the issue. Right clicking and choosing ‘save as’ doesn’t give me the same file as clicking on the file. I tried again with the correct file this time. It was much more obvious of where to put my MQTT information on this one. I get the following message under my mosquitto add-on:

starting version 3.2.2
1517087196: mosquitto version 1.4.12 (build date 2017-06-01 13:03:48+0000) starting
1517087196: Config loaded from /etc/mosquitto.conf.
1517087196: Opening ipv4 listen socket on port 1883.
1517087196: Opening ipv6 listen socket on port 1883.
1517087196: Warning: Mosquitto should not be run as root/administrator.
1517087196: New connection from MY_RPI_IP_ADDR on port 1883.
1517087197: Socket error on client <unknown>, disconnecting.
.
.

It seems like the socket error and subsequent disconnect are a bad sign.

The RPi RF Receiver log (hassio frontend under addons) says:

Successfully built rpi-rf RPi.GPIO
Installing collected packages: RPi.GPIO, rpi-rf
Successfully installed RPi.GPIO-0.6.3 rpi-rf-0.9.6
2018-01-27 16:47:45 - [INFO] rpi-rf_receive: Listening for codes on GPIO 27

That seems like a good sign. I’m trying to trigger the reception of a code, but I don’t know where I should be able to view them.

The addon started correctly. Now, if the receiver works, you should see the codes both in the addon log and in a sensor called sensor.rf_receiver

I had GPIO 17 and 27 reversed for the transmitter and receiver. I just had some codes come through for the first time. Thanks for the help and thanks for making the add-on.

After doing a bunch of testing, I am mostly seeing noise from my noise sensors. They are from an existing ADT alarm system, so I wonder if the codes change. These are the sensors: Wireless Door/Window Contact - WS4945, Intrusion Detector | DSC Security Products | DSC

I used the Raspberry Pi RF Switch component with GPIO 17 to send out the 433MHz signals.

I put this in my configuration.yaml file:

switch:
  - platform: rpi_rf
    gpio: 17
    switches:
      test_rf_code:
        code_on: 1234567
        code_off: 7654321
        signal_repetitions: 30

I had to increase the signal repititions to get the code every time. As you can see there is still a lot of noise and variation in the code, pulse width and protocol.

2018-01-27 21:19:56 - [INFO] rpi-rf_receive: 1234567 [pulselength 359, protocol 1]
2018-01-27 21:19:56 - [INFO] rpi-rf_receive: 1234567 [pulselength 154, protocol 3]
2018-01-27 21:19:56 - [INFO] rpi-rf_receive: 4096 [pulselength 1134, protocol 2]
2018-01-27 21:19:56 - [INFO] rpi-rf_receive: 1234567 [pulselength 356, protocol 1]
2018-01-27 21:19:56 - [INFO] rpi-rf_receive: 602 [pulselength 365, protocol 1]
2018-01-27 21:19:57 - [INFO] rpi-rf_receive: 8192 [pulselength 1876, protocol 4]
2018-01-27 21:19:57 - [INFO] rpi-rf_receive: 1234567 [pulselength 353, protocol 1]
2018-01-27 21:19:57 - [INFO] rpi-rf_receive: 1234567 [pulselength 355, protocol 1]
2018-01-27 21:19:57 - [INFO] rpi-rf_receive: 1024 [pulselength 1059, protocol 4]
2018-01-27 21:19:59 - [INFO] rpi-rf_receive: 401408 [pulselength 1498, protocol 4]
2018-01-27 21:20:16 - [INFO] rpi-rf_receive: 1 [pulselength 1846, protocol 4]
2018-01-27 21:20:16 - [INFO] rpi-rf_receive: 1048576 [pulselength 1867, protocol 4]
2018-01-27 21:20:16 - [INFO] rpi-rf_receive: 16 [pulselength 1073, protocol 4]
2018-01-27 21:20:16 - [INFO] rpi-rf_receive: 512 [pulselength 1104, protocol 2]
2018-01-27 21:20:16 - [INFO] rpi-rf_receive: 16384 [pulselength 794, protocol 5]
2018-01-27 21:20:17 - [INFO] rpi-rf_receive: 7654321 [pulselength 355, protocol 1]
2018-01-27 21:20:17 - [INFO] rpi-rf_receive: 7654321 [pulselength 155, protocol 3]
2018-01-27 21:20:17 - [INFO] rpi-rf_receive: 6605745 [pulselength 156, protocol 3]
2018-01-27 21:22:06 - [INFO] rpi-rf_receive: 4 [pulselength 220, protocol 1]
2018-01-27 21:22:28 - [INFO] rpi-rf_receive: 32768 [pulselength 924, protocol 4]
2018-01-27 21:22:43 - [INFO] rpi-rf_receive: 1025 [pulselength 1109, protocol 4]
2018-01-27 21:24:34 - [INFO] rpi-rf_receive: 1048576 [pulselength 2485, protocol 4]
2018-01-27 21:24:34 - [INFO] rpi-rf_receive: 1234567 [pulselength 156, protocol 3]
2018-01-27 21:24:34 - [INFO] rpi-rf_receive: 1234567 [pulselength 155, protocol 3]
2018-01-27 21:24:35 - [INFO] rpi-rf_receive: 1048576 [pulselength 785, protocol 5]
2018-01-27 21:24:35 - [INFO] rpi-rf_receive: 1234567 [pulselength 157, protocol 3]
2018-01-27 21:24:35 - [INFO] rpi-rf_receive: 1234566 [pulselength 156, protocol 3]
2018-01-27 21:24:35 - [INFO] rpi-rf_receive: 1234567 [pulselength 354, protocol 1]
2018-01-27 21:24:44 - [INFO] rpi-rf_receive: 272 [pulselength 754, protocol 5]
2018-01-27 21:24:44 - [INFO] rpi-rf_receive: 1282 [pulselength 667, protocol 5]
2018-01-27 21:24:44 - [INFO] rpi-rf_receive: 1048576 [pulselength 2482, protocol 4]
2018-01-27 21:24:44 - [INFO] rpi-rf_receive: 119598 [pulselength 155, protocol 3]
2018-01-27 21:24:45 - [INFO] rpi-rf_receive: 7654321 [pulselength 158, protocol 3]
2018-01-27 21:24:45 - [INFO] rpi-rf_receive: 256 [pulselength 1827, protocol 4]
2018-01-27 21:24:45 - [INFO] rpi-rf_receive: 7652273 [pulselength 159, protocol 3]
2018-01-27 21:24:50 - [INFO] rpi-rf_receive: 32768 [pulselength 92, protocol 3]

I am using these components:
https://www.amazon.com/RioRand-Superheterodyne-transmitter-receiver-3400/dp/B00HEDRHG6/ref=as_li_ss_tl?s=electronics&ie=UTF8&qid=1471570787&sr=1-1&keywords=superheterodyne+433&linkCode=sl1&tag=brau01-20&linkId=c62fa32ddca909d4d8b14cce85af7917

There are the ones linked to in this Bruh video:

This automation was handy to test the Transmitter talking to the Receiver.

  - id: rf_433_test_on
    alias: RF 433MHz On
    trigger:
      platform: template
      value_template: >-
        {%- if is_state('sensor.rf_receiver', '1234567') -%}
          true
        {%- else -%}
          false
        {%- endif -%}
    action:
      - service: homeassistant.turn_on
        entity_id: 
          - input_boolean.test1

When you were able to get transmission through 3 walls, what did you use for an antenna? What was the transmitting source?

I know this topic is about RF addon. But I also belive that many of you have several devices using rolling code. For that reason I’m sharing here my setup to control devices with rolling code.
Basicly I bought a RPI/Arduino Relay and I connected that relay to a clone of my normal remote control. You can see that setup in the picture.

Then I just added a new switch in the configuration of HA:

  • platform: rpi_gpio
    ports:
    17: button 1
    27: button 2
    invert_logic: True

And I also created an automation to turn off the button milliseconds after turn on.

  • action:
    • delay:
      milliseconds: 20
    • data:
      entity_id: switch.button_1
      service: switch.turn_off
      alias: UP
      condition: []
      id: ‘xxxxxxxxxx’
      trigger:
    • entity_id: switch.button_1
      from: ‘off’
      platform: state
      to: ‘on’

I hope this can be useful for someone.

3 Likes

Hi guys,
Every time I try to install this from within Hass.io, the install button spins, then turns red about 3 seconds later.
I’m getting this in the log. Any ideas please?

18-02-09 14:24:02 INFO (SyncWorker_18) [hassio.docker.addon] Start build de3cd379/armhf-addon-rfreceiver:1.5
18-02-09 14:24:08 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 416, in start
    resp = yield from self._request_handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web.py", line 325, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 93, in impl
    return (yield from handler(request))
  File "/usr/lib/python3.6/site-packages/hassio/api/security.py", line 34, in security_layer
    return await handler(request)
  File "/usr/lib/python3.6/site-packages/hassio/api/utils.py", line 33, in wrap_api
    answer = await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/addons/addon.py", line 554, in install
    if not await self.instance.install(self.last_version):
  File "/usr/lib/python3.6/site-packages/hassio/docker/utils.py", line 18, in wrap_api
    return await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/docker/addon.py", line 259, in _install
    return self._build(tag)
  File "/usr/lib/python3.6/site-packages/hassio/docker/addon.py", line 274, in _build
    image.tag(self.image, tag='latest')
AttributeError: 'tuple' object has no attribute 'tag'