Muting dumb doorbell on command (Sonoff Mini R2 + Tasmota)

I recently moved into my own apartment and have been wanting to automate my doorbell. I have a regular doorbell switch, but my kid wakes up on the sound of the bell chime so I wanted the ability to mute it during his afternoon nap. I still want a phone notification so it wasn’t as easy as just turning off the doorbell.

I started off by putting a Sonoff Mini R2 behind the door button to make it smart (flashed with Tasmota). This is how the switch, the Mini R2, and the bell chime as connected to each other:

Doorbell Switch ‘Dumb’ → Mini R2 (Tasmota) → Bell chime

I found that the command ‘SwitchMode 15’ in Tasmota detaches the physical button press from controlling the chime relay. To my benefit, it still sends an MQTT message to HA informing that the switch has been pressed. So it was an easy matter to just run the command when I want to mute the doorbell and reset it back when I want to activate it again.

However, I also wanted HA to keep a track of the mute/ unmute state and make sure it is always aligned to the actual state of the Sonoff (in case of power outage/ HA restarts/ etc.). To get around this I defined a dummy relay in Tasmota like this:

Relay 2 is a dummy relay that I am using the track the mute/ unmute state. I’ve defined two rules in Tasmota:

Rule1 On Power2#state=1 Do Switchmode1 15 Endon
Rule2 On Power2#state=0 Do Switchmode1 0 Endon

These rules detach the doorbell relay when the dummy relay2 is activated and reset it when the dummy relay is turned off.

That was it! I brought in the dummy relay in HA, named it ‘Quiet Mode’ and also attached a timer to reset it in an hour if we forget to turn if off. Added a few automations to listen to the MQTT button press events and notify our phones if the doorbell is pressed when quiet mode is on.

Now whenever the kid is asleep we push this button and get all the doorbell notifications on our phones instead! Really happy with how this has turned out!

image

(Away mode is a separate functionality)

Here are some relevant configurations:
MQTT sensor in HA to listen to bell press event when detached from the relay:

binary_sensor:
  - platform: mqtt
    name: "Doorbell virtual press"
    state_topic: "tele/doorbell_switch/SENSOR"
    value_template: "{{ value_json.Switch1 }}"
    payload_on: "OFF"
    payload_off: "ON"

Note that for some reason the MQTT messages are inverted so I had to use the ‘payload’ triggers to put them in the correct state.

Here’s the automation to send notification when the doorbell press is detected in quiet mode. It captures a picture from my Dahua video doorbell and creates the phone notification.

alias: Doorbell pressed (virtual) - send notification
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.doorbell_virtual_press
    to: 'on'
condition: []
action:
  - service: camera.snapshot
    target:
      entity_id: camera.door_camera_mjpeg
    data:
      filename: /config/www/doorcam.jpg
  - service: notify.mobile_app_galaxy_phone
    data:
      message: Doorbell pressed
      data:
        image: https://url.com:port/local/doorcam.jpg
        clickAction: /lovelace/door
        ttl: 0
        priority: high
        actions:
          - action: URI
            title: Talk
            uri: app://com.mm.android.direct.gdmssphone
  - service: notify.mobile_app_galaxy_phone
    data:
      message: TTS
      title: Ding Dong
mode: single

Happy to answer any questions if anyone wants to replicate this functionality.

2 Likes

@sachinss Thanks for sharing! I’m in the middle of creating smart doorlbell from dumb-switch-doorbell and I used hw-622 relay board flashed with tasmota. So similiar to your switch. It works with PulseTime since I don’t know how to configure button press as button :crazy_face:

I find your approach very interesting and I want to create mute too (have small kids too) and use it during night time (after 9pm till 6.30am) and when kids have after lunch nap :dizzy_face:

I’m also considering to get notification always when the doorbell button is pressed…

May I ask you:

  1. how did you configure to or command tasmota do switch on quiet mode and away mode? Is it automation? Can you please share?

  2. another question on rules since I’m quite new to HA and tasmota (noob :slight_smile: ):
    Can you explain rule1 and rule2 - what it means, so I could maybe use it?

  3. how did you configure module in tasmota? I have hw-662 board and I use button (physical doorbell button) and I can’t configure in tasmota to be relay fired (on) only when the button is pressed. I could only get it working with switchmode 0 and then PulseTime3 to turn off relay after short period of time.
    Thanks!

I have implemented similar solution with ability to see the doorbell button presses and ability to disable the doorbell when required.
https://community.home-assistant.io/t/contact-sensor-for-doorbell/341167/13?u=birca1987

I don’t have the HW-622 relay board so it would be good if you provide a link or a schematic as to how you have wired it. But since you have flashed it with Tasmota I’m guessing it has an ESP82xx chip on it. You can integrate the switch to your Home Assistant by using the SetOption19 command (make sure you have the full Tasmota firmware and not a minimal version)

Once you have integrated with HA you should see a switch which replicates the state of your doorbell. Based on this you can have an automation to run when the state of the switch turns to ‘on’. For example see the YAML code in my first post where the trigger is the doorbell press, and the actions are to send the notification to my phone. You’ll have to replace the entity ids with your entities for it to work

how did you configure to or command tasmota do switch on quiet mode and away mode? Is it automation? Can you please share?

To start off, go to the console on your Tasmota device and run ‘Switchmode 15’. This should detach your buttons from your relays. Try pressing the doorbell and now the relay should not turn on (use Switchmode 0 to reset the functionality). If this works then you can run an automation to set and reset the switchmodes at particular times. Look into how to send commands to Tasmota through MQTT here: Commands - Tasmota

another question on rules since I’m quite new to HA and tasmota (noob :slight_smile: ):
Can you explain rule1 and rule2 - what it means, so I could maybe use it?

Rules are pre-defined ‘automations’ that can be defined to run on certain actions. A good resource to start is here: Rules - Tasmota
As per Rule1 vs. Rule2 - those are just numbers to differentiate between the rules. My rule Rule1 On Power2#state=1 Do Switchmode1 15 Endon defines that when Relay2 is turned on, the Switchmode 15 command should be executed. It’s nothing fancy!

how did you configure module in tasmota? I have hw-662 board and I use button (physical doorbell button) and I can’t configure in tasmota to be relay fired (on) only when the button is pressed. I could only get it working with switchmode 0 and then PulseTime3 to turn off relay after short period of time.

I didn’t have to do anything special for the Sonoff Mini R2. I use switchmode 0 as well. Maybe try using switchmode 1 (follow mode) or the other switchmodes. A good reference is here: Buttons and Switches - Tasmota

1 Like

Thanks @sachinss for this! Much appreciate your help and explanation. Been away and couldn’t test it and fiddle with it:). It this relay with esp. Tasmota works, physical button/switch also.

My problem is with detaching the relay1 from physical switch/button. I used your rule1 and rule2. I can’t see any problems with rules…if I put command rule1 I get:

11:30:01.942 MQT: stat/tasmota_D3132E/RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":41,"Free":470,"Rules":"On Power2#state=1 Do Switchmode1 15 Endon"}}

and for rule2:

11:31:45.987 MQT: stat/tasmota_D3132E/RESULT = {"Rule2":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":40,"Free":471,"Rules":"On Power2#state=0 Do Switchmode1 0 Endon"}}

status command:

11:33:04.710 MQT: stat/tasmota_D3132E/STATUS = {"Status":{"Module":33,"DeviceName":"Tasmota-12F-relay","FriendlyName":["Tasmota-relay1",""],"Topic":"tasmota_D3132E","ButtonTopic":"tasmota_D3132E","Power":0,"PowerOnState":0,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"tasmota_D3132E","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0}}
state
11:34:02.383 MQT: tele/tasmota_D3132E/STATE = {"Time":"2022-03-14T11:34:02","Uptime":"0T00:10:11","UptimeSec":611,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"OpenWrt_IOT","BSSId":"98:DA:C4:C9:04:57","Channel":1,"Mode":"11n","RSSI":54,"Signal":-73,"LinkCount":1,"Downtime":"0T00:00:03"}}

So the physical switch/button from doorbell is connected to GPIO5 and relay to GPIO4. As for dummy relay2 is virtually connected to GPIO1 and button for this relay to GPIO0.

If I press the doorbell button (in tasmota button1) the relay fires and bell rings. Also, if I press virtual switch in HA it rings.

So, I could use some help with detaching relay from physical switch, please… anyone has any idea what I’m doing wrong?

I tried detaching relay also with also setoption114 and setoption73 and no luck, can’t detach it…

Try running ‘Switchmode1 15’ on Tasmota console and check by pressing the physical button connected to the device.

One thing to note - the Tasmota and the HA buttons directly control the relays, so detaching the physical button from the relay won’t have any impact there.

Thanks @sachinss , I tried that already, but I noticed just now that switching relay2 switches the led on board🙄. It could be the wrong gpio for relay?

Switchmode1 15 command should work. The same thing had happened to me where I had played around with different commands a lot that it wasn’t working. I’d suggest reset Tasmota (“Reset 1”) and try out the command before doing anything else.

And yes, I’d suggest don’t attach a relay to GPIO0. It is used for setting the programming flag as well.

@sachinss
I reset the whole thing, started from scratch…couldn’t get switchmode1 15 or switchmode 15 working. But eventually it works with setoption73 1 which is similar, but now my goal is to “decypher” json values HA gets over mqtt.
With setoption73 1 after button press i get:

14:10:14.442 MQT: stat/tasmota_D3132E/RESULT = {"Button1":{"Action":"SINGLE"}}

I don’t know how to configure sensor since there is no ON or OFF value. Maybe instead sensor and not binary sensor…
My config for sensor is:

  - platform: mqtt
    name: Doorbell Button Press
    state_topic: "stat/tasmota_D3132E/RESULT"
    value_template: "{{ value_json.Button1 }}"
    unique_id: doorbell_button_press

And then when is pressed, the sensor report is like:

{'Action': 'SINGLE'}

Is it possible to create binary sensor out of this?

And another question:
How to disable double action when button is pressed twice? When in normal switchmode 0 and in setoption73 0 the double pressing on button activates relay2 and command setoption73 1 and doorbell mutes. In this mode I can press double or triple and doesn’t toggle to unmute/mute. So just from unmute->mute.
Any clues?
Thanks!!!

That’s great!

I’d suggest you keep it as a ‘sensor’ instead of a binary_sensor so that you can parse single/ double/ hold actions and create different automations if you want.

Looking at the json try something like this under value_template:

value_template: "{{ value_json.Button1[0].Action }}"

I am more of a change-and-try guy so you may have to try out a few variations until you get it right.

1 Like

Thanks!
I try with normal sensor and I made autiomation if I get mqtt message like this…to get notification.

Thank you @sachinss again for help and the idea!!!

That’s also a good way to do it.

As for your other question, the page at Buttons and Switches - Tasmota says that you cannot disable the double click functionality:

Multi-Press Functions

Multipress functions for 2 and more presses cannot be changed using SetOptions or rules.

Since 2 presses controls Relay2 and 3 presses controls Relay3, maybe try assigning a high value to your second relay like 7 and hope no one presses your doorbell 7 times in a row! :slight_smile:

1 Like

I disabled it with setoption13 1, with this I sacrificed double or triple press :slight_smile:
I’ll test it a little bit, but for now it works!

Did it a bit different without changing the Switchmode, but with disabling the rule which connects the switch (push button) to the relay (buzzer).
I want to know if somebody rings the doorbell, even when the buzzer is switched off (night time).
And when the ESP reboots, I want the push button and buzzer connected with each other by default.

This is my setup:

This is the physical setup:
GPIO 15 - Push button from the front door
GPIO 16 - Relay to the buzzer

GPIO 4 and GPIO 12 are randomly chosen and dummy relais.

These are my two rules:

Rule1
ON POWER1#State=1 DO POWER2 ON ENDON
ON POWER1#State=0 DO POWER2 OFF ENDON

Rule2
ON POWER3#State=1 DO Rule1 1 ENDON
ON POWER3#State=0 DO Rule1 0 ENDON

Rule3
ON System#Boot DO POWER3 ON ENDON

This is what it looks like in Home Assistant
image

1 Like