How to add Rflink PIR sensor

I’m trying to add cheap 433Mhz PIR sensors using a RFlink gateway.
The Sensor is detected as light switch, and when presence detected it switches on and never switches back to off. If i look at the sensor section of the RFLINK docs i can’t see any PIR or presence option. The switch should be switched to off after a few seconds … How can i add this PIR motion sensor to home assistant?

I had something similar on my RF link where a wall switch was sending “ON” signals and the switch also appeared as a light. I worked around it with an automation that toggled the light I was interested in an then set the generic switch to the off position after it toggled it.

Here is an example of my automation (formatted by the new frontend automation maker):
note light.stairs_light is the actual light and light.vhome_entry_3 is RF the transmitter

- action:
  - data:
      entity_id: light.stairs_light
    service: light.toggle
  - data:
      entity_id: light.vhome_entry_3
    service: light.turn_off
  alias: Vhome Entry 3
  hide_entity: true
  id: 'VhomeEntry3'
  trigger:
  - entity_id: light.vhome_entry_3
    from: 'off'
    platform: state
    to: 'on'

unfortunately it doesn’t look like RF link has a binary sensor component so I would set up a template binary sensor (https://home-assistant.io/components/binary_sensor.template/) that reads the light position and add an automation to turn the “light” off a specified time after the “ON” event.

I haven’t set up any PIR motion sensors yet so if you report back that would be appreciated.
Also a link to where you got them from would be great as it is hard to know what is and isn’t supported.

Hi, i solved it using automation but i prefer to have a timer option in the binary template sensor. I tried to do this with the value_template option using the last_updated var , but could not get it to work.

Finally I created a rf link switch, a binary sensor and an automation, but this is to complicated for a simple pir sensor in my opinion. This should be configurable in the RFLINK sensor component. The PIR sensor i used can be bought on ebay:

–>

binary_sensor:

  • platform: template
    sensors:
    pirhalbeneden:
    friendly_name: Hal Beneden
    value_template: “{{ states.switch.pirhalbeneden.state == ‘on’ }}”
    device_class: motion

automation:

  • alias: Reset Motion Sensor pirhalbeneden
    trigger:
    platform: state
    entity_id: switch.pirhalbeneden
    to: ‘on’
    for:
    seconds: 30
    action:
    service: homeassistant.turn_off
    entity_id: switch.pirhalbeneden

This is how I did it also - although I used the mqtt_publish service.

Shouldn’t make a difference - your way is actually a little neater!

The nice thing about this is you can see activity levels in the graphs of the sensor to understand levels of activity/presence.

eg:

I have the same PIR sensor. The sensor is displayed under switch, but state stays off. What is going wrong.

switch:
  platform: rfxtrx
  automatic_add: True
  devices: 
    09130000849826019180:
      name: pirwoonkamer

You should add it as binary template sensor:

switch:
  platform: rflink
  devices:
    ev1527_0d714a_06:
      name: PIR-HALBENEDEN

binary_sensor:
   - platform: template
 sensors:
   pirhalbeneden:
     friendly_name: Hal Beneden
     value_template: "{{ states.switch.pirhalbeneden.state == 'on' }}"
     device_class: motion

Then add a reset automation in automations.yaml:

- id: reset_pir_halbeneden
  alias: Reset Motion Sensor pirhalbeneden
  trigger:
    platform: state
    entity_id: switch.pirhalbeneden
    to: 'on'
    for:
      seconds: 30
  action:
    service: homeassistant.turn_off
    entity_id: switch.pirhalbeneden
1 Like

Just noticed youbare using rfxtrx, so it is possible not supported by rfxcom
Maybe you have to manually add it to the rfxcom firmware if possible.

Thanks for your reply. I found post from y-pollart, which was very helpfull for me and did the trick: Can't get RFXTRX to add my sensors

Next thing to figure out is how I can send binary signal via HA. Any suggestions?
The remote control swith I have:

Hi,
I have a cheap sonoff RF PIR2 that only sends the on command on movement
As suggested above i’ve created a binary sensor.
My goal is to turn on lights when motion is detected and turn them off when for a certain period of time, no motion is detected.

I have the following code:

- platform: template
  sensors:
    pir_woonkamer:
      friendly_name: PIR woonkamer bs
      device_class: motion
      value_template: "{{ states.switch.pir_woonkamer.state == 'on' }}"

automation:    
- alias: PIR woonkamer auto off
          trigger:
            platform: state
            entity_id: switch.pir_woonkamer
            to: 'on'
            for:
              minutes: 5
          action:
          - service: switch.turn_off
            entity_id: switch.pir_woonkamer

But this always turns the sensor off after five minutes. What i want is that the sensor only turns offy when no movement is detected within that 5 minutes. If motion is detected, it should restart to count down the 5 minutes before turning off.
Is it possible? If yes: how?

The automation to turn the light on and off i use:
I have two sensors to switch the light on…

- id: lichthalbeneden_aan
  alias: Licht Hal beneden Aan
  trigger:
    platform: state
    entity_id: 
      - binary_sensor.pirhalbeneden
      - binary_sensor.pirhalbeneden4
    from: 'off'
    to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: light.licht_beneden_hal
    
- id: lichthalbeneden_uit
  alias: Licht Hal beneden Uit
  trigger:
    platform: state
    entity_id: 
      - binary_sensor.pirhalbeneden
      - binary_sensor.pirhalbeneden4
    from: 'on'
    to: 'off'
    for:
      minutes: 8
  action:
    service: homeassistant.turn_off
    entity_id: light.licht_beneden_hal

Thanks for the reply

My PIR sensor doesn’t send an ‘off’ signal. so i have to set it to the off state after i.e. 2 seconds after the on state was triggered. But, if one ofyour mentioned PIRS is triggered within the 8 minutes. does it reset and start counting the 8 minutes from the beginning?

Can you show me the binory_sensor part? I have some difficulties to set my PIR up as a binary sensor.
Thanks in advance!

Never mind, It is working. Combining multiple code examples in this thread.

@bbQ Dank je wel!

Hi sholofly

Can yo advise what RF devic you are using i.e rftrx or rflink?

I have rflink but it is not detecting my sonoff PIR2’s

Cheers

Hi, I use the rf link too. Turn on the logging in your config to find out what the rf data is for detecting movement.

Any tips on getting this to turn off? The MQTT client never sends a doorbell “off” message because that’s not really how doorbells work…they’re just momentary. Am I doing this the wrong way??

binary_sensor:
  - platform: mqtt
    name: "Front Doorbell"
    state_topic: "home-assistant/front/bell"

Just create an automation that turns the doorbell of after it’s triggered. .

Thanks, I eventually figured it out. Bit new to this!!

1 Like