Sonoff RF Bridge (ESPurna FW) how to activate a Light When PIR detects a Motion

I have a Sonoff RF Bridge running on ESPurna firmware. The Bridge has been setup (via code learning) to detect motion for switch #0 ON
OFF portion Is left blank.

I have a walk way light that is connected to sonoff basic (Tasmato flashed)

I want to automate the following way:

  1. Turn my walk way light when a Motion is detected.
    a. Walkway light Should Turn ON only during night. (say between 9pm and 6am)
  2. Also Once its ON , it should automatically switch OFF after few Mins (Say 10 Minutes).

For above scenario

Part 1:
My Motion sensor configured as binary sensor in confuratour .yamal Code is as follows:

  • name: “WalkWay Sensor” #0
    platform: mqtt
    state_topic: SBRIDGE01/relay/0
    command_topic: SBRIDGE01/relay/0/set
    payload_on: “30A2019A04CED2908E”
    payload_off: “30A2019A04CED29OFF”
    availability_topic: SBRIDGE01/status
    payload_available: 1
    payload_not_available: 0
    device_class: Motion
    optimistic: false
    qos: 1
    retain: false
    My Motion sensor Automation.yaml code to turn OFF to Binary sensor back to off state once motion is detected
    • alias: WalkWay Motion State
      hide_entity: true
      initial_state: ‘on’
  • platform: state
    entity_id: binary_sensor.walkway_sensor
    to: ‘on’
    seconds: 5
  • service: mqtt.publish
    topic: SBRIDGE01/relay/0
    payload: 30A2019A04CED29OFF
    Part 2: (Once light is ON) I have the following automation: (Below automation code works fine while switching ON light using HA UI)
    • id: ‘1530192351578’
      alias: ON Mirror Light at Night
  • entity_id: switch.mirror_light
    hours: 0
    minutes: 2
    from: ‘off’
    platform: state
    to: ‘on’
  • after: ‘18:00:00’
    before: 06:00:00
    condition: time
  • alias: ‘’
    entity_id: switch.mirror_light
    service: switch.turn_off


  1. My Motion sensor is always ON & never goes to OFF state

  2. How to Turn ON lights when Motion is detected?