set up sonoff RF bridge to respond to 433MHz devices and send alerts via Home Assistant

it’s not hard to make use of old or inexpensive 433MHz RF devices so that you can use them with modern smart home devices. For example, a 443MHz bell push button on my desk toggles a Hue smart lamp nearby. A 433MHz PIR motion sensor on a driveway alerts my phone that the post has arrived. A 433MHz magnetic contact sensor (window-open) alerts Alexa that a door is open. These ‘433MHz transmitter devices’, a water leak sensor and a certain smoke alarm, are sensors that the Sonoff RF Bridge are likely to respond to. The way to know if a gadget (eg a one-button remote) will work with the Sonoff RF bridge is to try it (or buy it labelled as compatible with ‘ewelink’)*.

The Sonoff RF bridge can pair with a small range of 433MHz devices and this for me is sufficient. You’ll need to modify the bridge or use other hardware (eg see this very popular RFlink project write-up) if you need to pair with Friedland; Oregon Scientific or Home Easy devices.

see also: 433MHz smarter letterbox

what you need for this project

  • Home Assistant set up eg on a raspberry Pi with the Sonoff custom integration
  • Sonoff RF bridge R1 or R2
  • compatible 433MHz sensors eg bought with the bridge

set up the Sonoff RF bridge with a phone app so that it will read your RF sensors

The easiest ready-to-go device to integrate 433MHz RF devices with a smart home is the Sonoff RF Bridge. Install the eWelink app on a mobile device and register an account. Add the RF bridge to your app – it will connect to your wifi so you can communicate with it. Click ‘+’ and ‘add alarm’ so that the Sonoff bridge will go into pairing/learning mode waiting for you to trigger the device you want to monitor. Trigger and give the listed device an easy to recognise name. Also note the order in which you paired the devices. (The Sonoff Bridge numbers them from 0 upwards and this number can be used to distinguish them). You can pair more devices. BTW if you delete devices down the line there’s a chance that Home Assistant will remember the ‘old’ device number and name. It might not if you continue as below:

Add the Sonoff custom integration by AlexxTT to Home Assistant – https://github.com/AlexxIT/SonoffLAN

add your 433MHz sensors to Home Assistant (optional)

Surprisingly you don’t need to do much to pick up sensor transmit signals hereon. In Home Assistant go to Developer tools > States > find the ‘remote’ in the big list of entities and trigger one of your paired sensors. Below I triggered the device I named ‘ black round push button’ in the Sonoff ewelink app. It was the 6th device that I had paired (counting from 0). I’ll show how to get HA to respond to this below.

add some code to your Home Assistant configuration.yaml (optional)

You don’t have to add the paired devices to your configuration as follows. However, if you do Home Assistant will firstly keep the device’s history for you – as displayed below in a history graph. Lastly, you’ll have a binary sensor entity which you can listen to for a state change in an Automation.

sonoff:
rfbridge:
# command 0
gate pir far: # button/alarm name in eWeLink application
device_class: motion
timeout: 600 # optional timeout in seconds for auto turn off
# command 1
gate pir near:
device_class: motion
timeout: 600
# command 2
porch door:
device_class: door
timeout: 600
# command 3
letterbox L:
device_class: motion
timeout: 600
# command 4
white bell push:
device_class: button
timeout: 6
# command 5
black round push button:
device_class: button
timeout: 6

an automation to listen for a device trigger

The following automation listens for a message from the Sonoff RF bridge matching the ‘event data’ below. The example below will create a message in the HA notification panel. You may add your own ‘actions’ such as toggle a light.

automation:
- alias: black button press
trigger:
platform: event
event_type: sonoff.remote #event type is a thing we can't edit
event_data:
name: black round push button #as you named it in eWeLink app
action:
service: persistent_notification.create
data:
message: black button pressed

an automation to listen for all the binary sensors I have defined

I have five RF sensors and a trigger on each one requires a different action (eg notify me or turn on a light). It feels tricky – however the idea is to name each event – aka ‘give the event a trigger ID’. Lastly you want different things to happen – note the action section. ‘Then do” starts with a ‘choose’ and ‘target’.

Above you see how my automation looks in Home Assistant > Settings > Automation. Below you see a YAML version of the automation with two rather than six options. If you have made some automations yet never used ‘trigger IDs’, this example presents us with a very good reason to use them.

alias: RF sonoff signals
description: "receive and act on RF messages - "
triggers:
- trigger: state
entity_id:
- binary_sensor.f2f3_2
id: porch door opens or closes
to: "on"

- trigger: state
entity_id:
- binary_sensor.f2f3_5
id: black round push button press

conditions:
- condition: time
after: "07:00:00"
before: "00:00:00"

actions:
- choose:
- conditions:
- condition: trigger
id:
- porch door opens or closes
sequence:
- action: light.turn_on
metadata: {}
data:
rgb_color:
- 113
- 219
- 26
target:
entity_id: light.desk_stand_lamp
- delay:
hours: 0
minutes: 1
seconds: 1
milliseconds: 0
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.desk_stand_lamp


- conditions:
- condition: trigger
id:
- black round push button press
sequence:
- action: homeassistant.toggle
metadata: {}
data: {}
target:
entity_id: light.hue_desk_light
mode: single

can the sonoff RF bridge send messages to control other things?

Every sensor described above transmits a 433MHz signal/pulse which the Sonoff RF Bridge receives and identifies because we taught it each signal. The bridge also includes a transmitter which can fire off a signal/pulse to make say, a 433MHz mains socket turn on or off. You can find RF light switches too. Or the RF bridge can make a door chime play a tune. As I warned above, the Sonoff RF bridge signals are not recognised by the full gamut of devices including door chimes and gates and garage doors – you can but try yours.

Hereon I realise why 433MHz is less good for controlling devices: our RF bridge can send messages without a clue as to whether the receiving device is on or off or open or closed or even heard the message. Anyway here’s what you’d need to do

  • set the receiving device, eg a chime into its pairing mode, eg with a 2-second press on a button
  • send a signal/pulse from the ‘ewelink’ app and hope it’s learned
  • write a script (as below) to get the Rf bridge to replicate and send that same signal.
script:
send_door_alarm:
alias: make-a-noise
sequence:
- service: remote.send_command
data:
entity_id: remote.sonoff_bcdef #this is your bridge entity in Home Assistant
command: dooralarm # button name in eWeLink app

Leave a Reply

Your email address will not be published. Required fields are marked *