Overview
This is to help setup and document reed sensors using a Sonoff RF Bridge with PIR Sensors integrated into Home Assistant.
My Gear
- Sonoff RF Bridge 433 Mhz Wifi – https://amzn.to/2BvYJui
- Sonoff PIR Motion Sensor Wireless Dual Infrared Detector 433Mhz RF – https://amzn.to/2tc7x3U
- KERUI Avantgarde Door Windows Detector – https://amzn.to/2Bvt77S
Sonoff Commands
Use the commands below for each binary sensor if your using Tasmota 6.4.1 or above. You can also find a complete reference guide to the Sonoff-Tasmota commands on their Wiki page – https://github.com/arendst/Sonoff-Tasmota/wiki/Commands
If you have never flashed a Sonoff then watch DrZzs for getting started.
The PIR Sensor
The commands are needed for one sensor that doesn’t publish an OFF message after publishing ON while the other does. That device is a Sonoff Motion Detector using RF433 Mhz. The data comes from when you invoke a device and will show up in the RF Bridge console in an object format such as:
{“RfReceived”:{“Sync”:8670,”Low”:330,”High”:960,”Data”:”5C69EE”,”RfKey”:”None”}}
The below commands are performed on the RF Bridge since it receives these device signals:
rule1 on RfReceived#Data=D3180E do backlog publish2 RF_Bridge/motion1 ON; ruletimer1 5 endon on rules#timer=1 do publish2 RF_Bridge/motion1 OFF endon
Rule1 1 #enables the rule above
SetOption19 1 #enables Home Assistant discovery
Switchmode1 0 #(default) Set switch mode to TOGGLE
Switchretain1 1 #Set ButtonTopic to Topic and enable MQTT retain flag on button press
Switchtopic1 0 #Disable use of MQTT switch topic
PowerRetain1 1 #Enable MQTT power retain on status update
Timezone -5 # for EST Time
Latitude 34.080000
Longitude: -84.000000
The Reed Door Sensor
The following commands are used for a sensor that does publish an ON & OFF message. the device is a Sonoff Reed Switch on a door using RF433 Mhz.
rule2 on RfReceived#Data=D3182E do backlog publish3 RF_Bridge/inside_basmt_door ON; ruletimer2 5 endon on rules#timer=1 do publish3 livingroom_switch/stat/POWER ON endon
Rule2 1 #enables the rule
Switchmode2 0 #disables
Switchretain2 1 #enables
Switchtopic2 0 #enables
PowerRetain2 1 #enables
Home Assistant Configuration
The following Binary Sensor configuration was used with the PIR sensor. Notice I commented out what I was originally doing without using Sonoff rules.
– platform: mqtt
name: PIR Detector Front Door
#state_topic: “RF_Bridge/tele/RESULT”
state_topic: “RF_Bridge/motion1”
availability_topic: “RF_Bridge/tele/LWT”
#payload_on: “D3180E”
payload_on: “1”
payload_off: “0
payload_available: “Online”
payload_not_available: “Offline”
device_class: motion
off_delay: 5
qos: 1
#value_template: ‘{{ value_json.RfReceived.Data }}’
The following Binary Sensor configuration was used with the reed door sensor that publishes both ON and OFF messages. This config doesn’t use the Sonoff rules.
– platform: mqtt
name: Basement Inside Door
state_topic: “RF_Bridge/tele/RESULT”
availability_topic: “RF_Bridge/tele/LWT”
payload_on: “5C693E”
payload_off: “5C6937”
payload_available: “open”
payload_not_available: “closed”
device_class: door
qos: 1
value_template: ‘{{ value_json.RfReceived.Data }}’
Leave a Reply