Can't get RFXTRX to add my sensors

Hi there

I’ve been using HA for a few hours now, so I guess I still know very little about the system. However, I’ve managed to enable support for my RFXCOM device to pick up 433 MHz wireless devices, and I see that the unit picks up my sensors/remote by for example this line:

Recv: 0x09 0x13 0x00 0x01 0x27 0xdd 0x77 0x02 0x3c 0x60
16-09-13 23:44:49 INFO (Thread-2) [homeassistant.components.rfxtrx] Receive RFXCOM event from (Device_id: 27dd77 Class: LightingDevice Sub: 0)

I just can’t add the devices to HA - not manually or by the use of “automatic_add: True”.

Could it be due to the sensors using Lighting4?

Is your config like this:

rfxtrx:
  device: PATH_TO_DEVICE

sensor:
  platform: rfxtrx
  automatic_add: True

switch:
  platform: rfxtrx
  automatic_add: True

Any errors when you run:
hass --script check_config

Well… Yes… and no… :worried:

The “Class: LightingDevice” part in the output above fooled me into believing that RFXTRX would see my sensors as light devices, so I only had:

rfxtrx:
  device: PATH_TO_DEVICE

light:
  platform: rfxtrx
  automatic_add: True

Today, I added “all three automatic_add” sections (light, sensor and switch), and now they are added correctly. Sensors from my alarm system as “switches”, and my doorbell/mailbox sensor as “sensors” :slight_smile:

Being a total newb, I just need to figure out how to use them. It seems like HA can’t really figure out the state of the sensors. For example the window switches transmits, when the window is opened - not when it is closed. Also, the code transmitted is based on a jumper setting inside the unit, which could be set to anything.

BTW: Thanks for replying to my first post. It is highly appreciated!

Hi Hansen,

I had a problem similar to yours with my cheap chinese sensors and I’ve started to write an additional “binary_sensor” component based on the rfxtrx platform. I think it suits motion and door sensors better than the current “switches” on the latest stable home-assistant release. I’d be glad to help you try and test my components if you want.

Best regards,
Yannick.

Hi Yannick

That sounds interesting :slight_smile: Can you post your code here?

My code is still experimental in the sense that the code may change, but the module does what it is supposed to do.
As I don’t have too much time to spend on a clean “developper installation” with a virtual python environment, the way I’m using my own module may look “dirty” but it works and going back to a stable HASS is not difficult anyway.

And here is how to use my “rfxtrx binary sensor” component:

  • First, get a copy of the rfxtrx-binary-sensor branch on my github repo in your home directory:

      cd
      git clone https://github.com/y-pollart/home-assistant
      git checkout rfxtrx-binary-sensor
    
  • Find where your “stable” HASS is installed on your system. On mine (python3.4 on Raspbian), it’s at:

      /usr/local/lib/python3.4/dist-packages/homeassistant
    
  • Make a backup of the rfxtrx.py platform source code:

      cp /usr/local/lib/python3.4/dist-packages/homeassistant/components/rfxtrx.py ~/hass-rfxtrx.py.bak
    
  • If home-assistant is running, stop it.

  • Then copy 2 files from the cloned repo to the HASS directory, using sudo:

      sudo cp  ~/home-assistant/homeassistant/components/rfxtrx.py /usr/local/lib/python3.4/dist-packages/homeassistant/components
      sudo cp  ~/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py /usr/local/lib/python3.4/dist-packages/homeassistant/components/binary_sensor
    
  • Update your configuration.yaml in order to add your binary_sensor devices (see the wiki for an example), don’t forget to remove your device from the existing switch or lighting components.

  • Restart HASS.

  • If you have any trouble, stop HASS and recover the backed-up rfxtrx files:

      sudo rm -i /usr/local/lib/python3.4/dist-packages/homeassistant/components/binary_sensor/rfxtrx.py
      sudo cp ~/hass-rfxtrx.py.bak /usr/local/lib/python3.4/dist-packages/homeassistant/components/rfxtrx.py
    

If you have any question, don’t hesitate to ask!

1 Like

@y-pollart has now made a pull request for a rfxtrx binary sensor: https://github.com/home-assistant/home-assistant/pull/4218

@Hansen: Could you test if this works for you?

I’m sorry to say that I’m not using HASS anymore (I went to one of the “competitors”).

I will, however, see if I can get an additional RPi up and running with HASS in the near future.

Hi,

if that can help …
i bought motion sensor on chinese market.
So i’ll test it, as soon as received (15days) .

I took that :
http://www.banggood.com/PIR-Infrared-Motion-Sensor-Detector-Accessory-For-433MHz-Wireless-Burglar-System-p-1082295.html?rmmds=search

I followed the instructions above but cannot proceed:

pi@RPI3:~ $ git clone https://github.com/y-pollart/home-assistant
Cloning into 'home-assistant'...
remote: Counting objects: 51311, done.
remote: Total 51311 (delta 0), reused 0 (delta 0), pack-reused 51311
Receiving objects: 100% (51311/51311), 43.19 MiB | 2.72 MiB/s, done.
Resolving deltas: 100% (39029/39029), done.
Checking connectivity... done.
pi@RPI3:~ $ git checkout rfxtrx-binary-sensor
fatal: Not a git repository (or any of the parent directories): .git
pi@RPI3:~ $

Did I miss something? I cannot find a step-by-step instruction on the wiki page.
Any help is highly appreciated

Hi!

After a long battle trying to set up HA (and escape from Domoticz), I luckily bumped into this binary-switch improvement.

Until now, none of my cheap chinese sensors and switches worked at all. After copying these new files onto my installation (Raspberry Pi) everything is working!

PIRs and little remotes seem to work fine. I can test future development of this code.

@y-pollart the learning curve is quite steep for me as a noob :wink: I would like to try this, but don’t know how to add this new code to my HA. Could you help me and give some directions how to do this?

More than happy to test and let everyone know if it worked. (and if so, this means I also can escape from Domoticz). The following hardware I could test:
This sensor gives on signal via rfxtrx component. With automation I can switch it off: https://nl.aliexpress.com/item/433MHz-Wireless-PIR-Sensor-Motion-Detector-For-Wireless-G2-GSM-PSTN-Auto-Dial-Home-Security-Alarm/32611184439.html?spm=2114.13010608.0.0.mH7n7S

HA found these sensors via RFXcom component, but doesn’t show on/ off/ register movement:

Gate remote:
The control/ signal is added, but that’s it…

Hi everyone,

It seems I’ve not been notified of your messages.

@goprojojo my bad, I forgot to ad cd home-assistant between git clone and git checkout :slight_smile:

[yannick@ypollart src]$ git clone https://github.com/y-pollart/home-assistant
Cloning into 'home-assistant'...
remote: Counting objects: 65836, done.
remote: Total 65836 (delta 0), reused 0 (delta 0), pack-reused 65836
Receiving objects: 100% (65836/65836), 55.96 MiB | 8.87 MiB/s, done.
Resolving deltas: 100% (50288/50288), done.
[yannick@ypollart src]$ cd home-assistant/
[yannick@ypollart home-assistant]$ git checkout rfxtrx-binary-sensor
Checking out files: 100% (1167/1167), done.
Branch rfxtrx-binary-sensor set up to track remote branch rfxtrx-binary-sensor from origin.
Switched to a new branch 'rfxtrx-binary-sensor'

From there you can access ``homeassistant/components/binary_sensor/rfxtrx.pyandhomeassistant/components/rfxtrx.py```

@hb100,
I don’t have my setup at hand so I’m giving you information from what I recall, but the principle is quite simple.
Once you have copied the “rfxtrx.py” files at the right places (see my post above), edit your configuration file
and use “automatic_add” in order to make the binary sensor component detect your devices when they fire some events.

Please refer to my documentation of the rfxtrx-binary-sensor component on github, I’m trying to explain how to get new devices identified and configured.

Any comments are welcome. Sorry I don’t have too much time to spend on the code right now. I’ve just merged the current master branch into mine, so using the component should work on recent versions of HASS.

@hb100 I’m using the exact same PIR detector as you. Like all of the detectors I’ve tried, there is no event for “no more motion”. Hence the off_delay configuration option: the PIR device can be configured to detect motion once in every 5 seconds or every 5 minutes (if I remember correctly), using a switch. Just configure the off_delay parameter with the same value and you’re done.

You should be able to get your other PIR sensors working in the same way. I have at least 3 different kind of PIR sensors and they all work similarly, the main difference being the delay between two motion detection events.

As for the gate remote, as long as it is supported by your RFXtrx box, you should be able to catch the “button pressed” events. Using the “off_delay” you can assign different HASS devices for each button, or you can get a “on” event on button “A” and “off” event on button “B” on the same HASS device.

Many thanks so far and good to know that you have the same pir’s so we know for sure it should be possible to get it up and running…the cd home-assistant is very helpfull, but still not working.

Home Assistant is installed in a virtual Python environment in my case (see https://home-assistant.io/docs/hassbian/installation/) could this be the reason that these instructions don’t work in my case? Any advice?

The steps I followed were:
cd
git clone https://github.com/y-pollart/home-assistant
cd home-assistant
git checkout rfxtrx-binary-sensor

→ results:
Branch rfxtrx-binary-sensor set up to track remote branch rfxtrx-binary-sensor from origin.
Switched to a new branch ‘rfxtrx-binary-sensor’

Next need to find where HASS is installed via
sudo find / -name homeassistant
→ results:
/srv/homeassistant/

Stopped home-assistant via user interface and copied files:
sudo cp ~/home-assistant/homeassistant/components/rfxtrx.py /srv/homeassistant/lib/python3.4/site-packages/homeassistant/components
sudo cp ~/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py /srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/binary_sensor

No feedback, so this worked…
To be sure:
cleaned configuration.yaml to minimum
sudo reboot

Results:
2017-06-13 20:29:35 ERROR (MainThread) [homeassistant.loader] Unable to find component binary_senor

Did several attempts with variations in the configuration.yaml

binary_senor: #nor switch, nor sensor it didn't do the trick.. 
  platform: rfxtrx
  automatic_add: True
  devices:
    09130000849826019180:
      name: motion_room1
      sensor_class: motion
      off_delay: 5

You forgot the “s” in binary_sensor (re-read your config extract)
Then the off_delay parameter is also written incorrectly.

Your configuration file section should contain:

binary_sensor:
  platform: rfxtrx
  automatic_add: True
  devices:
    091300006ca2c6001080:
    name: motion_hall
    sensor_class: motion
    off_delay:
      seconds: 5

I would advise you to start with a minimal configuration section:

binary_sensor:
  platform: rfxtrx
  automatic_add: True

Then start hass and trigger your sensor. Look at HASS logs, you should see a log like the following, provided your sensor is the one you have configured previously:

INFO (Thread-6) [homeassistant.components.binary_sensor.rfxtrx] Added binary sensor 091300006ca2c6001080 (Device_id: 6ca2c6 Class: LightingDevice Sub: 0)

Once you get the device id, add it in your configuration file like before with the off_delay option and disable automatic_add.

I hope I could help you a little…

You make my day! Many thanks!

Movement is detected, loving it.

Tomorrow I will try the gate remote controller.

HA recognizes the senors.:sunglasses: Also the signal from my gate remote control switch. But, this is not a senor it’s a switch. In other words, is it possible to send the “on” signal of this binary remote control?

[homeassistant.components.rfxtrx] Receive RFXCOM event from (Device_id: 8984a1 Class: LightingDevice Sub: 0, Pkt_id: 091300008984a1015e80)
2017-06-14 09:57:27 INFO (Thread-13) [homeassistant.components.rfxtrx] rfxtrx: found possible device 8984a1 for 849826 with the following configuration:
data_bits=20
command_on=0x49826
command_off=0x984a1

2017-06-14 09:57:27 INFO (Thread-13) [homeassistant.components.binary_sensor.rfxtrx] Found possible matching deviceid 849826.
2017-06-14 09:57:27 INFO (Thread-13) [homeassistant.components.binary_sensor.rfxtrx] Added binary sensor 091300008984a1015e80 (Device_id: 8984a1 Class: LightingDevice Sub: 0)

Glad I could help.

Indeed, a remote controller has switches, not sensors. A binary sensor have a lot in common with a switch, having only “on” and “off” states. But their goals are different. Switches are dealt with by the “rfxtrx switch” component.

I have door sensors that can trigger “open” / “close” events, as well as a “tampering” event (when someone is trying to remove the sensor from where it’s mounted). I’ve setup hass with a binary_sensor device for “on” / “off”, and a switch device for “tampering”.

Sending signals from hass to your door relay (if you want to open or close your door) is an entirely different matter. I think you should have a look at the “switch” component. So far I have not experimented with that so I’m sorry I cannot provide any help.

Thanks for your help.

All my COCO devices and PIR’s are working great now. Will look and try to find a solution to switch the gate relay. It is possible. HA recognizes the signal, now just send it…;).