Can Home Assistant Listen to 433MHz Remotes?

Don’t give up yet :slight_smile: I think I know how to solve your problem.

You didn’t add port 5000 to pilight congif file, therefore HASS connection is refused. Pilight config file is located here:
/etc/pilight/config.json

At the end of that file you have to add a line:
"port": 5000

So config for pilight in that part looks something like that:

"settings": {
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "port": 5000
},

After you edited your config, save it and restart pilight

sudo su
service pilight restart

After restarting pilight, also restart Home Assistant and it should be working now.

Let me know how it goes :slight_smile:

Oh, and in my configuration.yaml I have:

pilight:
  host: 192.168.0.11
  port: 5000

So an actual IP address (instead of 127.0.0.1) of RPi on which pilight is running.

Thank you for the extra Info, i haven’t found the anything about adding the Port in the config of pilight so Thank you for that :slight_smile:

And in my case pilight and HA are running on the same RPI so localhost or 127.0.0.1 is the right IP adress.

Adding the Port option in the Config from pilight removed the error in HA So i guess that is working now. :smile:
and i did kept 127.0.0.1 as the ip because i haven’t bothered giviing the RPI a static IP i might do that in a later stage but for now i don’t need it.

Thank you again for your help. :slight_smile:

Hi DJFLuFFy-vs-joe,

sorry to bump your thread - did you ever get it to work?

I am trying to do the exact same thing and I am struggling. I can send signals via rf (gpio17) but i still dont know how to receive signals. I have de-coded my remotes on another pi with rasbian installed. So I “Just” need to be able to receive signals from remotes so i can trigger automation-scripts.

if anybody else have ideas, im all ears (i have spent countless nights reading and i just cant seem to crack it)

thanks.

1 Like

i have an arduino that picks up all 433 mhz in my house.
if i have a new remote i just have to click the buttons to recognize the codes and from that moment i can use them.

No, not really,

I was struggling with upgrades and downgrades and pi light but I did not got it working.

In the end it screwed up my image so I made a backup of my configs and I flashed the SD card with the hass.io image

And I never tried to get it working again.

Instead I just bought two hue dimmer switches and now I use those to control my hue lights.

I’m sorry I could not help you.

I’m not sure how to make this a feature request if it’s possible at all.

Another option is modifying the listener script that you can download from the video and instead of printing the output to the display do a web socket request to HA. And then run the script in the background when the pi starts.

But I don’t know how CPU intensive this will be.
And I’m not familiar enough with the python language to create such a thing.

I could give it a try to make such a script in java but at the moment work is busy.

That’s a great solution but in my case I just want to have one device that controls everything.

I live in a small apartment and I prefer to just have the bare necessities for my home automaton.

i have several arduino’s performing that task, but its possible to have 1 arduino (or esp) that listens for the 433 mhz codes and also send the codes.

so it is:

remote >> arduino >> HA >> arduino >> device

that way you can also use a completely different remote to switch 433 mhz switches.

for instance i have a cheap 4 button remote in the bedroom to switch off a heatingblanket which is connected to a 433 mhz switch that normally never would work with that remote.

1 Like

hi again,

thanks for your swift reply, it’s appreciated.

I considered doing what you did with the hue, but ill keep searching for a solution for a while. Maybe i can use my other pi that is sniffing and sending RF with out problems to send a mqtt telegram to the hassio.

Ill let you know if i succeed!

thanks for your input.

That’s totally possible, or even what ReneTode did with an Arduino.

But I prefer the one device solution.

If you use Pilight and RPI_RF together, you can send and receive all day long. I have several remote controls, door/window sensors, and electrical plugs that I control using HASS and the remote controls. But, there are a few things you need to know to do this:

  1. Use a superheterodyne transmitter and receiver. The cheap ones don’t work well, if at all, because the range sucks on them. A good transmitter/receiver should cost you around $13 or so on Amazon.

Good Type: http://www.amazon.com/dp/B00HEDRHG6/
Bad Type: http://www.amazon.com/dp/B00M2CUALS/

  1. Use an external antenna on your superheterodyne transmitter and receiver. The jumper kits that you can get have roughly 6-8" wires in them. These are more than sufficient to have a 50’ or more range.

Jumper Kit Example: http://www.amazon.com/dp/B01LZF1ZSZ/

  1. If you have a remote that already controls an outlet, and the remote/outlet cannot be reprogrammed, you may experience some sync issues with HASS. This is because 433 stuff doesn’t have confirmation messages in its design. If HASS doesn’t “hear” the button press, it won’t know that the light is off/on. That causes the HASS state to not match the live state of the device. If you are intentional in your button presses and make sure you press it for at least a second, this is less likely to happen. But even if it does, you can automate around this to a degree.

So… in my example, you can have the following:

Remote 1
Remote 2
Remote 4
Outlet 1
Outlet 2
Outlet 3

As you can see, we’ve “lost” remote 3, and we’ve also “lost” outlet 4. Now, assume that Remote 1 only controls Outlet 1, Remote 2 controls Outlet 2, etc. So there’s no remote for Outlet 3, and no Outlet for Remote 4. If you know the codes to Outlet 3, you can still use HASS to control it. If it’s reprogrammable (like the ones that BRUH uses), you can reprogram it to match the new remote. If you don’t know the codes, you’ll have to use trial and error to guess the codes, but that’s nearly impossible. We’ll come back to Outlet 3 and Remote 4 later on. Let’s keep going.

In Pilight, you must first setup Pilight to listen to ALL protocols. This is documented in the manual install of Pilight, so I’m not going to go into detail on that.

NOTE: If you are up to date on your firmware on the Raspberry PI, you’ll need to use the Development Branch of Pilight. I’ve written another article on that, so I’m not going into detail on that either.

Once Pilight is installed and setup to listen to all the codes, you’ll use sudo pilight-receive to “listen” the codes from each Remote. When you press a button on the remote, you should see something like this:

{
	"message": {
		"id": "A3",
		"unit": 61,
		"state": "off"
	},
	"origin": "receiver",
	"protocol": "clarus_switch",
	"uuid": "0000-b8-27-eb-4ffabe",
	"repeats": 1
}

Repeat this for each button press on each remote. Once you have your codes and device types, you can re-run the Pilight setup so that Pilight only listens to those protocols that you need.

Once you’ve finished getting all the Pilight codes, you’ll still need to get the codes using RPI_RF so we can transmit them later. To do this, you’ll need the rpi-rf_receive.py file from the RPI_RF repository. The master link is: https://pypi.python.org/pypi/rpi-rf

Using the link above, download the rpi-rf_receive.py file located in the SCRIPTS section. Place that file in your home folder on your PI (not your AIO Virtual Environment if you’ve install HASS using that method). Then run chmod +x ./rpi-rf_receive.py in the same directory that you placed the file. This will allow it to be executed. Now, run the file using sudo ./rpi-rf_receive.py. You should see something like this if you did it correctly:

2017-10-22 22:15:00 - [INFO] rfrx: Listening for codes on GPIO 27
2017-10-22 22:16:00 - [INFO] rfrx: 21280 [pulselength 200, protocol 1]
2017-10-22 22:17:00 - [INFO] rfrx: 21211 [pulselength 200, protocol 1]

This will give you the “codes” that HASS will transmit when the button press is received. Repeat this for each button press.

Now that you have both the Pilight and RPI-RF codes, here’s how to set things up. We will have Pilight receive the codes, and RPI-RF transmit the codes. You “can” do both with Pilight, but I’ve found this method to be nearly bulletproof in accuracy, which is why I use it.

First, create 2 automations. The first one is triggered by the Pilight message that is generated when you press the ON button on the remote and will turn on the RPI-RF switch we will create later. The second one is triggered by the Pilight message that is generated when you press the OFF button on the remote and will turn off the RPI-RF switch we will create later.

automations/pilight_remote1_on.yaml

alias: "pilight_outlet1_on"
trigger:
  platform: event
  event_type: pilight_received
  event_data:
    protocol: clarus_switch
    uuid: 0000-b8-27-eb-4ffabe
    id: 'A3'
    state: 'on'
action:
  - service: homeassistant.turn_on
    entity_id: switch.rpirf_outlet1

automations/pilight_remote1_off.yaml

alias: "pilight_remote1_off"
trigger:
  platform: event
  event_type: pilight_received
  event_data:
    protocol: clarus_switch
    uuid: 0000-b8-27-eb-4ffabe
    id: 'A3'
    state: 'off'
action:
  - service: homeassistant.turn_off
    entity_id: switch.rpirf_outlet1

Next, we will create the RPI-RF switch in HASS:

switches/rpi_rf.yaml

platform: rpi_rf
gpio: 17
switches:
  rpirf_outlet1:
    #Outlet 1
    code_off: 21820
    code_on: 21811
    protocol: 1
    pulselength: 200
    signal_repetitions: 15

Now, make sure Pilight is running and restart HASS to activate the switch/automations you just created. Whenever you press the button on the remote, Pilight will receive that message, place that message on the HASS event bus, and the automation will be triggered. The automation tells the switch to be turned on (or off), which sends the RPI-RF code, which turns on the light.

Now, all you’ve really done is setup a switch in HASS that “mimics” the state of the REAL switch and remote. So now that you are armed with this information, you can now use a remote (Remote 4) to control an outlet that it wasn’t originally programmed for (Outlet 1 or 2). And assuming that you could successfully find the codes for Outlet 3, you could use Remote 4 to control Outlet 3.

Hopefully this helps. Also keep in mind, I wrote this late at night, so if I missed something or something doesn’t make sense, let me know.

2 Likes

So for my next example, I actually use a door/window sensor to turn on a light. In my real-world example, the door sensor turns on a Z-Wave light, but I’ll adopt the example for a RPI-RF switch instead.

Use Pilight to receive the codes as stated above and create 2 automations, one for the door opening and the other for the door closing.

automations/pilight_door1_opening.yaml

alias: "pilight_door1_opened"
trigger:
  platform: event
  event_type: pilight_received
  event_data:
    protocol: ev1527
    uuid: 0000-b8-27-eb-4ffabe
    unitcode: 355554
    state: opened
action:
  - service: homeassistant.turn_on
    entity_id: input_boolean.closet_door

automations/pilight_door1_closed.yaml

alias: "pilight_door1_closed"
trigger:
  platform: event
  event_type: pilight_received
  event_data:
    protocol: ev1527
    uuid: 0000-b8-27-eb-4ffabe
    unitcode: 879842
    state: opened
action:
  - service: homeassistant.turn_off
    entity_id: input_boolean.closet_door

The above Pilight automations trigger a fake switch (input_boolean) in HASS. Now we need to create this input_boolean switch. We use this fake switch in HASS so you can track the status of the door:

input_boolean:
  closet_door:
    name: Closet Door
    initial: off
    icon: mdi:glassdoor

Now, we need to create automations that actually send the RPI-RF codes to turn on/off the light whenever the input_boolean switch is turned on (opened) and off (closed):

automations/closet_door_opened.yaml

alias: "closet_door_opened"
trigger:
  platform: state
  entity_id: input_boolean.closet_door
  from: 'off'
  to: 'on'
action:
  - service: homeassistant.turn_on
    entity_id: switch.rpirf_closet_light

automations/closet_door_closed.yaml

alias: "closet_door_closed"
trigger:
  platform: state
  entity_id: input_boolean.closet_door
  from: 'on'
  to: 'off'
action:
  - service: homeassistant.turn_off
    entity_id: switch.rpirf_closet_light

Now, create the RPI-RF switch in HASS:

rpirf_closet_light:
  #Closet Light
  code_off: 28890
  code_on: 28881
  protocol: 1
  pulselength: 200
  signal_repetitions: 15

Save everything and restart HASS. You should now have a light that turns on when you open the door, and off when you close the door.

1 Like

This is cool, but as i’m trying to wrap my head around it, i’m wondering. It seems that these settings are for switches that stays on or off. I just realized that my doorbell uses RF, and i would like to have HA listen to that signal. So i need to configure an entity that changes state from 0 to 1, or quiet to dingdong for a sec or something that i can use in an automation to, say, send me a notification or blink a light if someone’s at the door. I’m only interested in the receiver as i do not intend to use any RF transmit signal as of now or probably ever. My struggle is to have a momentary state change on a received signal…

does anybody know how to sniff RF codes on Hass.io?

You could always use an Input_Boolean switch that is triggered by the pressing of the doorbell. Then, write an automation that says “anytime the input_boolean is turned on, notify me, delay 15-30 seconds, then turn it off”. That way, the switch will automatically be turned off after the delay time. This delay allows for the person at the door to press the button multiple times without you being notified for each button press. My example uses Pilight as the service that receives the RF.

NOTE: I haven’t personally tested this myself, but it’s modeled off a working setup that I currently use for a different fuction. This is just an attempt to guide you in the right direction.

Input Boolean Switch:

input_boolean:
  front_doorbell:
    name: Front Doorbell
    initial: off
    icon: mdi:glassdoor

automations/front_doorbell_pressed.yaml

alias: "front_doorbell_pressed"
trigger:
  platform: event
  event_type: pilight_received
  event_data:
    protocol: ev1527
    uuid: 0000-b8-27-eb-4ffabe
    unitcode: 879842
    state: opened
action:
  - service: homeassistant.turn_on
    entity_id: input_boolean.front_doorbell

automations/front_doorbell_notification.yaml

alias: "front_doorbell_notification"
trigger:
  platform: state
  entity_id: input_boolean.front_doorbell
  from: 'off'
  to: 'on'
action:
  - service: notify.ios_iphone
    data:
      title: "Check Front Door"
      message: "Front Doorbell Pressed"
  - delay: '00:00:30'
  - service: homeassistant.turn_off
    entity_id: input_boolean.front_doorbell

Be sure to update the notify section with your notify commands. If you don’t use Pilight, change the trigger section of the “front_doorbell_pressed” automation to match whatever RF receiver setup/system you are using.

2 Likes

You really should break that out into a separate thread in the Hass.io section. You’ll have better luck there getting a response.

Hello Jeremy, please do you think pilight will work at raspberry pi3 with latest Hassbian? Or there will be neccesarry to change kernel? Or is there some pilight beta which could be used without kernel change?

And some manual how to install and configure pilight on hassbian or working config files?

Thank you very much.

I’m not sure if it’s possible to run Pilight on Hassbian or not, mainly because I’m not running Hassbian. You should create a thread in the Hassbian section asking for help installing Pilight. I do know that the latest version of Pilight works on Raspbian Stretch, which is what I am running.

As for configuration files, search for my other threads about Pilight. I have posted many different configurations in those threads.

Here: RPi RF Receiver addon

So i’m finally trying to set this up, but i’m a bit stuck about here from your post above:

In Pilight, you must first setup Pilight to listen to ALL protocols. This is documented in the manual install of Pilight, so I’m not going to go into detail on that.

Where do i do this? I can’t find anything about it. And where will the codes show up? I tried running the pilight-receive command in terminal, but nothing happens. I suppose the inputs should show on the next lines or be added to /etc/pilight/config.json. Maybe because i haven’t set it up to listen to ALL protocols?

NOTE: If you are up to date on your firmware on the Raspberry PI, you’ll need to use the Development Branch of Pilight. I’ve written another article on that, so I’m not going into detail on that either.

I saw this and found your other post. I started to uninstall, but i got an error message dpkg: error processing package pilight (--remove). I’ve tried apt-get remove/purge pilight and even apt --fix-broken install, but now i’m seem unable to both remove and install it. It also seems like the current latest release is a stable version, so maybe that procedure was outdated?

Just BTW, I was easily able to pick up the codes from my doorbell with BRUH’s rfrx.py script. However, I was not able to pick up the codes from my E:ZO smoke detectors which is a popular type around here. They specify that it uses 433.92MHz wireless communication.