RPi RF Receiver addon

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'

Hmm, I have the same error with a local addon now. While it was working last week…

@onkytonk, @Romkabouter if you upgrade to 0.63 the addons will magically install again… probably it’s something related to Python 3.4 which has been deprecated… got no idea…

Building addons on local fails since 0.62.1 :slight_smile:

1 Like

I’m using the build in MQTT broker of Home assistant and getting to following error in the addon log

2018-02-18 18:44:41 - [INFO] rpi-rf_receive: 541134868 [pulselength 1562, protocol 4]
Error: The connection was lost.

And the following in the Hassio log:

2018-02-18 18:33:14 ERROR (MainThread) [hbmqtt.broker] Invalid connection from (client @=46.129.25.194:35966) : [MQTT-3.1.2-1] Incorrect protocol name: “MQIsdp”

Does anyone know how to fix this?

Hi,

I ca’t get this to work, or maybe I do but then I don’t understand the working of it. I have Hassio setup with this addon, and am able to switch my light on and of by sending 1361 and 1364. But is I press the buttons on the remote that also switches the lights on and off I get a bunch of random numbers on random protocols (always 1,2 3, of 4). The remote I’m using is an Elso AB440R.

I also have an KAKU remote (model AWST-8801) and that remote doens’t show up at all when I press one of it’s buttons.

Am I missing something here? Hope someone can help, sending RF signals and turing the lights on or off is great, but I really want to incorporate some smart logic so I need the remotes to be seen too.

Thanks in advance,

Cheers,
/Cacti

I’m pretty new to all this. I am running Hassbian, so I know I can’t run as an addon, but when I set everything up and run the script and hit a button I get: sh: 1: mosquitto_pub: not found.
I don’t know much about mqtt, but I think I have it setup, but this implies that I don’t. Any idea on what I might be missing, or where to look? Thanks in advance!

2018-02-19 20:25:55 - [INFO] rpi-rf_receive: 5518595 [pulselength 167, protocol 1]
sh: 1: mosquitto_pub: not found
2018-02-19 20:25:55 - [INFO] rpi-rf_receive: 5518595 [pulselength 168, protocol 1]
sh: 1: mosquitto_pub: not found

@Catman, probably you have to install the mosquitto clients library:

sudo apt-get install mosquitto-clients.

Mosquitto should be already installed, if not, install both:

sudo apt-get install mosquitto mosquitto-clients

Hey cacti (@Le_cactus),
Maybe the remotes are not 100% standard to the 433 rf transmission. I mean, some of them use rolling codes, so the codes are not always the same and some others just don’t use the correct frequency or protocol.

Hi @Try2Fly, I’ve got no idea. You changed the parameters in the script, right? I mean

mosquitto_address = “192.168.1.100”
mosquitto_port = “1883”
mosquitto_user = “homeassistant”
mosquitto_password = “password”

with your settings?

Ah right @Pantomax ! Thank you so much, I’m not used to virtualization and I keep forgetting that Hass is running in another environment. So neither were installed. Now I have to figure out why I’m getting:
Error: The connection was lost.

Thanks!

1 Like

Are you using the latest version of Home Assistant? Actually I didn’t update to the latest because it gave me many problems. If you and @Try2Fly are both getting this kind of error, probably it could be something related to that. I’ll try ASAP.

Actually, and maybe unfortunately, I just upgraded to 0.63.3 yesterday. And I just noticed I’m getting errors in my log file now:
Invalid connection from (client @=127.0.0.1:33586) : [MQTT-3.1.2-1] Incorrect protocol name: “MQIsdp”
6:14 AM core.py (ERROR)

So that would probably explain the error from the script!

How is your MQTT broker configured in the configuration.yaml?
Mine is like this:

mqtt:
  broker: core-mosquitto
  username: !secret mqtt_username
  password: !secret mqtt_password
  port: 1883
  client_id: home-assistant-1
  keepalive: 60
  protocol: 3.1 

Well, once I got my head on straight, I got the broker and client working and see the state changes from your script showing up in the log files. My problem was getting confused on who was running the broker, Hassbian or me.

So I see the state logs in the log file, now I assume I need to do some more changes to tie that state change to the UI, so I see my switch state change in the UI when I click a remote.

1 Like

Yes I’ve changed the settings to my own settings, the same as I use in another working mqtt setup. Tried my internal IP address as well as my external URL. I get the same error.

Is it because I use the build in MQTT broker?

I only have this in my configuration:

mqtt:

I am using the built in MQTT broker as well and it works fine. Try changing your configuration using “homeassistant” as user and adding a password and all the other settings (check also the addon settings, they should match). Maybe the MQTT server needs a complete profile to maintain a stable connection.

I’ve tried the exact same set-up as you posted above but gtting the following errors:

2018-02-21 20:42:09 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 145, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/init.py”, line 399, in async_setup
success = yield from hass.data[DATA_MQTT].async_connect()
File “/usr/lib/python3.6/site-packages/homeassistant/components/mqtt/init.py”, line 506, in async_connect
self._mqttc.connect, self.broker, self.port, self.keepalive)
File “/usr/lib/python3.6/asyncio/futures.py”, line 332, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 250, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
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/paho/mqtt/client.py”, line 768, in connect
return self.reconnect()
File “/usr/lib/python3.6/site-packages/paho/mqtt/client.py”, line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File “/usr/lib/python3.6/socket.py”, line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File “/usr/lib/python3.6/socket.py”, line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
2018-02-21 20:42:11 WARNING (MainThread) [homeassistant.components.recorder] From version 0.64.0 the ‘recorder’ component will by default purge data older than 10 days. To keep data longer you must configure ‘purge_keep_days’ or ‘purge_interval’.
2018-02-21 20:42:20 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt