Can Home Assistant Listen to 433MHz Remotes?

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.

If you are not compiling it it will listen to all anyway. When compiling you get options of which devices/protocols you want to listen for.

The latest version pilight 8 should just install.

Whether you can see the smoke detectors depends on the protocol as well as being sent at 433mhz, if for instance they are manchester encoded the normal python scripts can’t pick them up as they don’t do manchester decoding, pilight does however so it sees most things :slight_smile:

Well it did install initially, but when i tried to uninstall it for a development branch, that’s when things went wrong. I’m sure i will find a way to reinstall it though.

However, back to where i got before i tried to uninstall, i ran the commands service pilight start followed by pilight-receive. The terminal just jumped to the next line and i pushed the doorbell button multiple times, long presses and close to the receiver etc. Nothing showed up in the terminal. Maybe i have to define the GPIO pin for the rx module somewhere? Only thought about that now. But i don’t know where to look if that’s not the place to look for input.

You have to setup the config.json as per the pilight docs…

Here’s an example of mine…

{
	"devices": {
		"pibedroompir": {
			"protocol": [ "kaku_switch_old" ],
			"id": [{
				"id": 31,
				"unit": 1
			}],
			"state": "on"
		},
		"pilivingroompir": {
			"protocol": [ "kaku_switch_old" ],
			"id": [{
				"id": 30,
				"unit": 15
			}],
			"state": "on"
		},
		"pihallpir": {
			"protocol": [ "kaku_switch_old" ],
			"id": [{
				"id": 23,
				"unit": 5
			}],
			"state": "on"
		},
		"pikitchenpir": {
			"protocol": [ "kaku_switch_old" ],
			"id": [{
				"id": 31,
				"unit": 0
			}],
			"state": "on"
		}
	},
	"rules": {},
	"gui": {
		"pibedroompir": {
			"name": "bedroompir",
			"group": [ "bedroom" ],
			"media": [ "web" ],
			"readonly": 0
		},
		"pilivingroompir": {
			"name": "livingroompir",
			"group": [ "livingroom" ],
			"media": [ "web" ],
			"readonly": 0
		},
		"pihallpir": {
			"name": "hallpir",
			"group": [ "hall" ],
			"media": [ "web" ],
			"readonly": 0
		},
		"pikitchenpir": {
			"name": "kitchenpir",
			"group": [ "kitchen" ],
			"media": [ "web" ],
			"readonly": 0
                 }
	}'
	"settings": {
		"log-level": 6,
		"pid-file": "/var/run/pilight.pid",
		"log-file": "/var/log/pilight.log",
		"port": 5000,
		"webserver-enable": 1,
		"webserver-http-port": 5001,
		"webserver-cache": 1,
		"webserver-root": "/usr/local/share/pilight/webgui",
		"standalone": 1,
		"gpio-platform": "raspberrypi3"
	},
	"hardware": {
		"433gpio": {
			"sender": 0,
			"receiver": 1
		}
	},
	"registry": {
		"pilight": {
			"firmware": {
				"version": 20976,
				"lpf": 556850,
				"hpf": 219750
			},
			"version": {
				"current": "8.0.3"
			}
		},
		"webgui": {
			"tabs": 3
		},
		"webserver": {
			"ssl": {
				"certificate": {
					"secure": 0,
					"location": "/etc/pilight/pilight.pem"
				}
			}
		}
	}
}

Couple of things with this file :-

  1. You can’t edit it while the daemon is running as it will overwrite it when you save it
  2. it’s located in /etc/pilight

The hardware section has to be setup, however this is correct for the the pins as per the docs for plugging the hardware pilight suggests, so if you have done the same it should be OK, but do check it.
The webgui needs setting up to if you are using it.

1 Like

Yes, i found that file, but there wasn’t much in there, just some basic settings, maybe 5-6 lines. Should the devices i triggered be generated and listed in there? They weren’t. I have no idea which protocol i should use for my devices if i tried to set it up manually.

Yeps just the place holder, you need to add your devices and web gui bits and the hardware.

When you get pilight-receive working it will tell you what it finds, I suggest you pipe the output to a file.

OK, just to be clear, pilight-receive should display input in the terminal as they are triggered?

EDIT: Do i need to configure GPIO or something like that first?