Security: opening control via gates Sonoff RF Bridge e Appthe HomeKits (via Homebridge)

4 minutes of reading
  • Check opening of the gates (doors, finestre, bascule etc.) via 433mhz radio magnetic contacts, Sonoff Bridge RF and Homebridge
  • Difficulty level: medium
  • Cost: reduced (<30 €)
  • Un Sonoff RF Bridge duly reworkedproprogrammed Sonoff-Tasmota
  • A magnetic 433mhz radio contact (projet tested with Sonoff DW1)
  • iPad and / or AppTVs in the home network (both for remote control of home automation) Apple, both for the functionnamesame as the plugin)


Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.

Sonoff  RF  BridgeAbstract

Il Sonoff RF Bridge is a home automation component able to receive and send codes by radio frequency 433mhz. Through adoption of the firmware Sonoff-Tasmota and also able to perform these functions through proMQTT tocollo. In this procast we will focus on the features of MQTT telemetry publishing on the net upon receipt of codes.

Through the combined use of:

we are going to get at the home automation of Appthe "House" one or more motion sensors useful to know at least the opening event of one or more gates of the house. The sensor closing event is available against a sensor that offers this functionality.

The functionnameis simple. Since the magnetic sensor is able to send a specific code (different for each sensor) via radio frequency 433mhz and since the Sonoff RF Bridge is able to receive this code and then republish it (through the adoption of protocol MQTT) on the network as MQTT telemetry, then via the "home" pluginbridge-mqtt-sonoffrf-receiver ”we will be able to intercept this telemetry and make it interpret like domotics "Opening gap".

Nb. The present procast illustrates how to domotize in key Appthe HomeKit of the magnetic sensors means Sonoff RF Bridge; it goes without saying that once you have introduced these sensors in home automation, you can use them in automation scenarios such as activation of lights, sirens, etc. in turn already included in home automation.

ATTENTION: this projet has pure educational purpose and does not replace a real alarm / anti-theft system e proprio.

It starts

Installation of sensors

The sensors usually go applicati at the gate to be monitored (but is it?) so that the radio pulse is triggered when it is opened then received by the RF Bridge and therefore the domotics interpret the thing as "opening gap". On the subject of the functionnameof the sensor, we refer to the dedicated page al Sonoff DW1, or the sensor used for the present projet.

Side configuration Sonoff RF Bridge

Downstream of the firmware implementation Sonoff-Tasmota sull'RF Bridge it must be configured to make it a radio frequency receiver (and possibly emitter - but it is not a subject covered in the present projet).

To do this, go to the menu item "Configuration> Module configuration" and set the configuration as shown in the figure:

Configuration Sonoff  RF  Bridge

This configuration will enable the unit's radio frequency functions.

Find out the sensor code

As explained, each sensor presents a specific hexadecimal code that identifies it. This code is sent in 433mhz radio frequency and is therefore collected from / by Sonoff RF Bridge (which must obviously be within reach of the radio signal) which in turn republishes it as MQTT telemetry.

To find out the sensor code it will therefore be sufficient to go via the web to the "Console" of the unit and activate the magnetic sensor.

In console appa string similar to this will appear:

MQT: tele/BridgeRF/RESULT = {"RfReceived":{"Sync":12610,"Low":400,"High":1250,"Data":"F413AC","RfKey":"None"}}

What interests us it is simply the content of the code in the "Data" field, in this case "F413AC".

Plugin installation

Pronow we are going to install the plugin. As with all plugins it is very simple.

Run the following command - on unix-based systems (linux, Raspberry etc.) from the terminal, from systems windows su procommand mpt:

sudo npm install -g homebridge-mqtt-sonoffrf-receiver

and wait for the end of proprocedure.
Nb. In case Homebridge is already running as a service (as described in our installation guides), prosee to interrupt it before installing using the command:

sudo systemctl stop homebridge

Configuration at Homebridge

Once the "home" plugin is installedbridge-mqtt-sonoffrf-receiver ”, to add the sensor to the configuration just include the following code in the "accessories" section:

  "accessory": "mqtt-sonoffrf-receiver",
  "name": "Ingresso",
  "url": "mqtt://",
  "topic": "tele/BridgeRF/RESULT",
  "username": "username",
  "password": "password",
  "rfcode": "F413AC",
  "ondelay": "10000",
  "accessoryservicetype": "MotionSensor"


accessoryRequired - Must necessarily be “mqtt-sonoffrf-receiver ”(all tiny).
nameRequired - Name of the accessory
urlRequired - MQTT broker address. In this case the local address is indicatedhost as this role resides on the same computer that hosts Homebridge
usernameOptional - The username to log into the MQTT broker, if configured.
passwordOptional - The user password to access the MQTT broker, if configured.
rfcodeRequired - The hexadecimal code of the sensor
ondelayOptional - Time expressed in milliseconds in which to suspend any new opening receptions
Optional - Type of accessory, "Motionsensor" (default) or "StatelessProgrammableSwitch”
rfcodeonOptional - Use in case the sensor is "smart" and send both opening and closing codes, not just opening like the Sonoff DW1 used in this projet
Optional - Use in case the sensor is "smart" and send both opening and closing codes, not just opening like the Sonoff DW1 used in this projet
Nb We also recommend to read carefully also the guide dedicated to the theme of configuration of the MQTT components in the profirst home automation.


Once executed Homebridge with the new configuration, appa new sensor will be displayed as shown in the following images (in the following example we have simulated the positionnameof an opening sensor on the garage access door):

This slideshow requires JavaScript.

Trigger and notification

To ensure that when the sensor opens be notified byapp "Home", it is necessary to access the sensor details and set the "Allow notifications" switch ("Allow Notifications"):

homebridge-mqtt-sonoffRF-receiver Sensorand Movement - details

When the sensor opens, the notification will be similar to the following:

Appthe HomeKit motion detection notification

Use in automation

As explained above, following the configuration the sensor added in home automation will behave like any other sensor, therefore it can be used as trigger to trigger of automations, for example the activation of one or more sirens, lights and / or more.

ITEAD Sonoff BasicATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Sonoff (and more generally to devices ESP8266), for any doubt, question, information on the specific merit of these components.


Stay up to date through ours Telegram channel!