Easy unflashed/untasmotized Sonoff RF Bridge door and window state view (Sonoff Lan)

UPDATE: THE GUIDE BELOW IS VALID FOR ONE BRIDGE ONLY.
SCROLL DOWN TO THE 2ND POST FOR THE CHANGES NEEDED FOR MULTIPLE BRIDGES

Finally found a solution to my problem so I ll post it here. Although it may not be as good, coding-wise (I m no YAML expert by any means), it just works and it is a simple solution to monitor your door sensors that any user with a basic understanding of the whereabouts of HA will be able to follow.

Requirements:

  1. Mosquito broker add-on, setup and running on your installation
  2. Sonoff LAN add-on from AlexxIT, installed through HACS
  3. Sonoff RF Bridge (Installed and paired throuh the ewelink app on your phone)
  4. GS WDS07 door/windows sensors

Steps:

  1. Once we pair the Sonoff RF Bridge to our mobile application, we select the Bridge and add our sensors twice as an alarm.
    Tap on your bridge name, then on the add (+) icon on the bottom right and then “Alarm”. The Bridge will beep and you can move your magnet away from the sensor, thus registering the “OPEN” state of your sensor. Give it a friendly name “Door 1 open” for example and click on the (+) sign again, select Alarm and when your bridge beeps, bring your magnet in contact with your sensor thus registering the CLOSE state. Give it a friendly name like “Door 1 Closed” and keep on adding sensors until you are done.

  2. We go on to our Home Assistant’s File Editor and we rename .sonoff.json (there is a dot before sonoff) to sonoffback.json. (You can just delete it but I prefer the safe way)

  3. Configuration, Server Controls, Check config, Restart Home Assistant

  4. Now we need to edit our configuration.yaml file by adding the binary sensors one by one like in the picture below
    configuration

Device Class can be door, window, opening etc. Choose what’s best for you.

Name is your entity name by which you will see the sensor in your UI
state topic is something descriptive for your specific application, it could be anything like basement/rfbridge1/window or anything that you like
payload on and off is again free for you to choose whatever you like, as long as you remember it. :slight_smile:

  1. Depending on the order by which we introduced the sensors and their respective states to the ewelink app there will be a “command” portion that is sent to home assistant through our rf bridge.
    For example.
    We first paired the open state of our door 1 sensor with the app. This was command 0
    We then paired the close state of our door 1 sensor with the app. This would be command 1
    Then the open state of our second door sensor, that would be command 2 and so on and so forth

  2. Go on to Developer Tools -> States and scroll down to your sonoff bridge which will be named something like sonoff.remote_xxxxxxxxxxx
    Grab one of your sensors at a time and watch the state change and the command shown as you close the contact or move it away.

The command shown in each case (open and close) is the number you have to write down in order to move on to the next step and create an automation.

  1. Now we will create automations that will take this command portion and translate it into an mqtt message that we can use, in order to create a meaningfull lovelace card with the door states.
    (I am 100% sure that there is a better coding way to do this, but as I have said, I m no expert in this, just an enthusiast like so many others out there)

You need to create two automations for each sensor, one for the closed state and one for the open state, like in my example below

Be careful not to make any mistakes in the topic and payload values as they will have to be exactly the same as the ones you typed down in your configuration.yaml file, when you created your binary sensor.

  1. When you are done, restart Home Assistant.

Create a lovelace glance card.

You will see your enitites(the ones you created in your configuration.yaml file listed with their respective names.

Once you re done open the visual code editor, if you prefer to change your icons to something other than the default that comes with device class, manually, like so. (Be careful with your identation)

glance card 2

Enjoy your unflashed/untasmotized door/window state view.

glance card final

[Updated to include a better image]

1 Like

I ran into a problem when I introduced my second bridge to the system.

  1. The new sensors that got paired to the 2nd bridge, send the same command portion to the sonoff.remote event. This means that the first alarm you pair to the second bridge will send command 0 to the event. But, this is the same command that is send by the first contact you paired with the first bridge.
    So for example, if you open your basement door (1st bridge, command: 0) you ll see that the attic window shows as open too (2nd bridge, command: 0)
    To get around this we pair the contacts in the ewelink app and give them friendly names that make sense in our project. I didnt use spaces just in case.

We delete.sonoff.json and restart home assistant so the file gets recreated with the new names we gave the sensors.

We then, like before, create our automation but this time we use the exact name we gave in the ewelink app.

This way you can have as many stock firmware bridges in the house as you like.

Hope you enjoy.

1 Like

Supported RF sensors in latest release

Also for your two states Door Sensor

Hello
Thanks to both for this very interesting tutorial. It’s exactly what I’m looking for.
I have 2 bridges and Antonia’s post seems to be the right way for me too.
But I don’t understand what do you mean by “pair the contacts in the Ewelink app”. I don’t find a such menu in the app. Please could you explain this point antonis?
Regards

Hi there patrickmx,

Glad you found something useful in here. Have you paired the sonoff rf bridge to the eweelink mobile app?
Once you have, you click on the bridge’s name and on the bottom right corner you ll see a (+) sign. You click on that and from the next menu you select alarm. Let me know how it goes.

Hi antonis,
Well, so “to pair” was the regular registration process. I thought you had a way to group 2 sensors.
No matter, I discovered a better way:
when you have many bridges, use “name mode” and not “command mode”. “name: Sensor one”
In this case, no matter which is the bridge who’s received the signal and what’s “command number” in it.

Space character accepted.in the name.

Test example wich run in my case : (in automations.yaml)

  • id: ‘XXXXXXX’
    alias: Toggle the light on when motion is detected
    description: essai PIR garage
    trigger:
    • event_data:
      name: entree maison
      event_type: sonoff.remote
      platform: event
      condition: []
      action:
    • device_id: b9XXXXXXXXX
      domain: light
      entity_id: light.led_tv
      type: toggle
      mode: single

In this example, HA send the command to a Hue Ledstrip.
I’m no trying to command a Sonoff S31 but still looking for the right way.

SonoffLAN is really a great job !!! Many thanks to Alexxit !!!

1 Like

Hello,
Is there any video to show this?
I have tried but I have hadnt success yet.

I cant add binary sensors like in the picture.

There are something missing at step 4-6… Please could you help me?

Saludos!
A Alvarez

Hi
I am a bit confused, please help if possible.
I am testing a door sensor right now.
in my configuration.yaml I have

sonoff:
  rfbridge:
    Button1:  # button name in eWeLink application (open signal)
      name: Garage Door Open  # optional, you can change sensor name
      device_class: door  # e.g. door, window
      timeout: 0  # disable auto close timeout
      payload_off: Button2  # button name in eWeLink application (close signal)
    Button3:
      name: Garage Door Closed
      device_class: door
      timeout: 0
      payload_off: Button4

in the events I see

Event 3 fired 7:27 PM:
{
    "event_type": "sonoff.remote",
    "data": {
        "command": 1,
        "ts": "2020-09-25T16:27:14.000Z",
        "name": "Garage Door Closed",
        "entity_id": "remote.sonoff_10009b4350"
    },
    "origin": "LOCAL",
    "time_fired": "2020-09-25T16:27:13.259466+00:00",
    "context": {
        "id": "f7c2dff6ff4b11ea8e73d37b18d72851",
        "parent_id": null,
        "user_id": null
    }
}
Event 2 fired 7:26 PM:
{
    "event_type": "sonoff.remote",
    "data": {
        "command": 0,
        "ts": "2020-09-25T16:26:47.000Z",
        "name": "Garage Door Open",
        "entity_id": "remote.sonoff_10009b4350"
    },
    "origin": "LOCAL",
    "time_fired": "2020-09-25T16:26:46.757330+00:00",
    "context": {
        "id": "e7f6f795ff4b11eaab253967862debb3",
        "parent_id": null,
        "user_id": null
    }
}

and here I am stuck.

First I need to add them in lovelace card
Then I need to get their state (open-close) for my automations.

I don’t know how to continue. Should I follow @antonis mqtt way or there is a new (and hopefully) easier one?

Makis in order to be able to display them in a lovelace card you have to add them to your config.yaml file as such

binary_sensor:
  - platform: mqtt
    name: "Freezer 1 Door"
    state_topic: "home/rfbridge/doorstate"
    payload_on: "freezer1dooropen"
    payload_off: "freezer1doorclosed"
    qos: 0
    device_class: door
  - platform: mqtt
    name: "Freezer 4 Door"

and so on…

Then you ll have an entity called binary sensor for each which you can choose for displaying on a card.

1 Like

It is ok, I manage to add them (found your other thread). I only have 2 door sensors so I add them.
2 as open - 2 as closed.
If I need to install 2 more I will need another sonoff bridge?

As long as it is in RF range you won’t need another one. I manage six doors on one bridge, 12 alarms. (6 open , 6 close) without a problem.

1 Like

Hi all,

I can’t for the life of me get the DW2 to register as closed :frowning:

When I try and add the second alarm by clicking ADD then close the door it doesn’t pick it up ….

How did you manage to register the DW2 RF as closed?
Mine just won’t…

@nckslater

binary_sensor:
  - platform: mqtt
    name: "Freezer 1 Door"
    state_topic: "home/rfbridge/doorstate"
    payload_on: "freezer1dooropen"
    payload_off: "freezer1doorclosed"
    qos: 0
    device_class: door
  - platform: mqtt
    name: "Freezer 4 Door"

[/quote]

Sorry for the late reply. I really don’t remember what I had done to be honest. Anyway, I guess that in the sonoff app you see that the door is closed. If you have followed the instructions the only thing could go wrong (I think) is that something is written wrong in the binary sensor.
Have you checked the states in developers tools? Probably the numbers aren’t 0 or 1 like the example

We first paired the open state of our door 1 sensor with the app. This was command 0
We then paired the close state of our door 1 sensor with the app. This would be command 1

Post your binary sensors and screenshot of dev tools to try to see what is not going well

Hi.
Thanks for your response.

I just got a reply from ITEAD and they have said that the DW2 RF door sensor just supports “open” status.

Doh! that will be why I can’t get closed to work :thinking: What’s the point in having a sensor that only detects when open…

I guess I’ll ditch the Bridge and the DW2-RF and get the DW2 Wifi version

Hi nckslater. Don’t ditch the bridge. Just get those and you ll be fine…

1 Like

Thank you.
Just ordered 5 of these :+1:

My sensors arrived in the post.

Just configured one of them as described above and works perfectly :slight_smile:

Thanks for your help

1 Like

I am so glad you got it working!

:clap::clap::clap::clap:
All working

1 Like