Sonoff Basic Expansion Mod - Buttons, PIR Motion Sensors, Tasmota Rules and more!

The Sonoff Hydra-Basic with two capacitive touch buttons and a PIR motion sensor.  Break into the powerful Rules of the Tasmota firmware and control more than one light/function with a Sonoff Basic.

Parts List:
Sonoff Basic
USB FTDI Adapter(Sonoff Flashing)
Male Headers
AM312 PIR Sensor
Capacitive Touch Button
Jumper Wires
Fuses (optional but recommended)

DrZzs video on step by step how to flash a Sonoff -

Tasmota Rules Commands Used:

backlog switchmode1 3;switchmode2 1;switchmode3 1

rule1 on switch2#state=1 do publish cmnd/S20Beta/POWER TOGGLE endon
rule1 on

rule2 on switch3#state=1 do publish HydraBasic/PIR/state YES endon on switch3#state=0 do publish HydraBasic/PIR/state NO endon
rule2 on

rule3 on switch3#state=1 do publish cmnd/TuyaDimTest/Dimmer 75 endon on switch3#state=0 do publish cmnd/TuyaDimTest/Dimmer 25 endon
rule3 on

HomeAssistant Binary Sensor Config YAML

- platform: mqtt
    name: "HydraBasic Motion"
    state_topic: "HydraBasic/PIR/state"
    availability_topic: "tele/HydraBasic/LWT"
    qos: 1
    payload_on: "YES"
    payload_off: "NO"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false
    device_class: motion

GitHub Link with all the rules and sample HomeAssistant Config -

The Sonoff Basic is mains powered device!  There is a danger of electrocution if not installed properly. If you don't know how to install a Sonoff, please call an electrician.


  1. This is great, thank you for taking the time to share your knowledge. I like that little jumper bridge.. that is great. I wish I would have seen this video before.. I fried a sonoffsv while doing the magnetic door lock.

  2. Hi there.
    I have followed your videos and they are great. I have setup my PIR and Sonoff similar to your video. The PIR is connected to GPIO3 and I would like it to turn a hue light on with automation
    For some reason I see the sensor state changing in sonoff console from Yes to No (on or off), however I do not know why the Binary sensor is not changing state in the states tool
    When I look at the state it shows off. I does not change to on even when the sonoff consoles show it change from off to on and on to off.
    I hope that makes sense, and hope you can help.
    I am still learning and i think it might have something to do with the rules or MQTT setup
    Please help as once this is working I will setup 3 more around the house.
    I am not switching the local relay on the Sonoff, I just want to switch on a light in the bedroom using MQTT and automation.
    Bruce in NZ


Post a Comment