Automate light with Sonoff 433MHz PIR

Hello,

Please help.

I can’t find, what I’m missing.

I have a Sonoff 433MHz PIR connected with Sonoff433MHZ RF bridge without any modifications.
I want to use it in a room to switch the light on and switch off after 10 minutes of no movement.
The light is switched on by a Sonoff Mini Switch also connected to HA.
Both Sonoff devices are using the eWelink app and the HA integration.

The automation i allready made:

alias: Badkamer lamp aan pir
description: ''
trigger:
  - platform: state
    entity_id: remote.sonoff_1000cdcc13
    attribute: ts
condition:
  - condition: state
    entity_id: remote.sonoff_1000cdcc13
    attribute: name
    state: Movesens badkamer
action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.sonoff_1000e53157
mode: single

This works fine.

The second automation, that follows the first one is what happens after the switch is on.

alias: Badkamer lamp aan
description: ''
trigger:
  - platform: state
    entity_id: switch.sonoff_1000e53157
    from: 'off'
    to: 'on'
condition: []
action:
  - delay: '00:00:01'
  - service: light.turn_on
    data: {}
    entity_id: light.badkamer_lamp
  - scene: scene.badkamer_normaal_licht
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    entity_id: light.badkamer_lamp
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    entity_id: switch.sonoff_1000e53157
mode: single

This also works fine.

But now the light goes off after 10 minutes, even when I’m in the room. I can’t figure out, how to restart the 10 minute timer, when a new state change from the PIR occurs.
As far as i know, the PIR does not have on/off. It only fires one message by movement.

I will really apreciate any help.

Thanks in advance,

Mischa

Do you have any other PIR working with the same sonoff rf switch?

Not now, but planned. This is the first one to learn it, when i get this working, more will be added.
I do have three door sensors on that same Sonoff RFbridge, they behave the same, being a remote in HA.

There is an option to create sensors with respect to each sensors. Please look at this url and make a sensor for your PIR.

After making the sensor, copy this to your second automation.

alias: Badkamer lamp aan
description: ''
trigger:
  - platform: state
    entity_id: switch.sonoff_1000e53157
    from: 'off'
    to: 'on'
condition: []
action:
  - delay: '00:00:01'
  - service: light.turn_on
    data: {}
    entity_id: light.badkamer_lamp
  - scene: scene.badkamer_normaal_licht
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.<sonoff_pir_entity_id>
        to: 'off'
        for: '00:10:00'
    continue_on_timeout: false
  - service: light.turn_off
    data: {}
    entity_id: light.badkamer_lamp
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    entity_id: switch.sonoff_1000e53157
mode: single

In the code above please replace sensor.<sonoff_pir_entity_id> with the entity_id of the sensor you created for PIR. And try

Thank you very much. I followed all the instructions, but still, it does not work. There are some strange things.

The manual from AlexxIT says i have to put this in:

sonoff:
  rfbridge:
    PIR Sensor 1: Movesens badkamer
      device_class: motion
      timeout: 60

When i do it that way, i just cant enter the eWelink device name directly behind the PIR sensor line. It results in syntax errror in the file editor.
Putting it like this makes a new sensor, but i think, that this sensor is not associated then:

sonoff:
  username: ******
  password: *****
  reload: always
  rfbridge:
    Door Sensor 1:
      name: Deur Woning
      device_class: door
      timeout: 5
    Door Sensor 2:
      name: Deur Terras
      device_class: door
      timeout: 5
    Door Sensor 3:
      name: Deur Schuur
      device_class: door
      timeout: 5
    PIR Sensor 1:
      name: Movesens badkamer
      device_class: motion
      timeout: 1

so using your suggested code:

alias: Badkamer lamp aan pir
description: ''
trigger:
  - platform: state
    entity_id: remote.sonoff_1000cdcc13
    attribute: ts
condition:
  - condition: state
    entity_id: remote.sonoff_1000cdcc13
    attribute: name
    state: Movesens badkamer
action:
  - service: light.turn_on
    data: {}
    entity_id: light.badkamer_lamp
  - scene: scene.badkamer_normaal_licht
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.movesens_badkamer
        to: 'off'
        for: '00:03:00'
    continue_on_timeout: false
  - service: light.turn_off
    data: {}
    entity_id: light.badkamer_lamp
mode: single

now results in light going on, but no more off. (Yes, i removed the switch in software to make this debugging easier, and get rid of the second automatisation)

I can’t understand, why the file editor does not accept the AlexxIT way of writing it.

Someone does?

Please try it like this

sonoff:
  rfbridge:
    Movesens badkamer:
      device_class: motion
      timeout: 60

Got rid off the Sonoff PIR’s, changed everyone for Fibaro Z-wave PIR’s. Should have done that sooner… :slight_smile: , they are way, way better and easier…