RPi RF Receiver addon

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

In case anyone else is trying to use this with Hassbian, not as an addon with Hassio, this is how I got it working.

Thanks for the script, great idea! Here is a high level break down of what I did in case it helps anyone else. This works great, for what I wanted. I wanted a quasi way to keep the state of my 433 switches current in HA. I will also be able to run other automations with the remotes, if so desired. I’m using the superheterodyne radios posted earlier in this thread. I used the provided scripts in rpi-rf (https://pypi.python.org/pypi/rpi-rf) to test the transmitter and receiver install and capture my remote codes.

I placed @Pantomax rpi-rf_receive.py script in the config folder along with my yaml files to make it easy to get to.
I then created a script to run this in the background during boot:

rpi-rf_receive script to start / stop script at boot / shutdown
create in: /etc/init.d/
name it: rpi-rf_receive

#! /bin/sh
# /etc/init.d/rpi-rf_receive

### BEGIN INIT INFO
# Provides:          rpi-rf codes monitoring from 433 mhz receiver
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: A script to start a program at boot
# Description:       A script which will start / stop a program at boot / shutdown.
### END INIT INFO

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting rpi-rf_receive"
    # run application you want to start
    (python3 /home/homeassistant/.homeassistant/rpi-rf_receive.py) &
    ;;
  stop)
    echo "Stopping rpi-rf_receive"
    # kill application you want to stop
    pkill -9 -f rpi-rf_receive.py
    ;;
  *)
    echo "Usage: /etc/init.d/rpi-rf_receive {start|stop}"
    exit 1
    ;;
esac

exit 0

configuration.yaml
I installed mosquitto & mosquitto-client to run my own broker outside Hassbian. The broker is set up to run automatically and I didn’t need to touch any of the configuration. I’m doing everything on the same Pi3, so just put the IP address of this device in the broker parameter to point to my installation of the mosquitto broker. I have an example of one switch I set up called Kitchen.

# Running my own MQTT Broker outside of Hassbian (install: mosquitto & mosquitto-client)
mqtt:
  broker: 192.168.1.200

# Read RF signal codes and send MQTT messages.  A separate service outside Hassbian (rpi-rf_reciever) is picking up 433 codes and sending them as messages to MQTT
sensor:
  - platform: mqtt
    state_topic: "sensors/rf/receiver"
    name: "RF Receiver"

switch:
  - platform: rpi_rf
    gpio: 17
    switches:
      Kitchen:
        code_on: 5510451
        code_off: 5510460
        pulselength: 168
        protocol: 1
        signal_repetitions: 5

automations.yaml
I used the UI automations tool to setup the following automations. This is what receives the remote control signals and repeats it and updates the states in HA. In a way it’s acting as a repeater also.

- action:
  - data:
      entity_id: switch.kitchen
    service: switch.turn_on
  alias: Kitchen ON
  condition: []
  id: '1519264552913'
  trigger:
  - entity_id: sensor.rf_receiver
    platform: state
    to: '5510451'
- action:
  - data:
      entity_id: switch.kitchen
    service: switch.turn_off
  alias: Kitchen OFF
  condition: []
  id: '1519264597099'
  trigger:
  - entity_id: sensor.rf_receiver
    platform: state
    to: '5510460'
3 Likes

Do i need to have a separate RPi or can i use the same RPi where i run the hassio?

The same is OK.