For just $2, convert any existing wired doorbell into a smart doorbell

Recently I come across this blog when I was looking for ideas to make my existing doorbell smart. No cloud wanted, video/photo not needed. Only “problem” was that this project is using ESPHome and Home Assistant. Since I use ESPeasy and openHAB, I converted the software part to those 2 systems.

Please read this blog for the basics before continuing below. Hardware needs and setup are explained there. Kodus for @Frenck for creating this project!

I assume you already have some ESPeasy’s with MQTT in your network. I won’t guide your through the process of settings this up. There are plenty of howto’s available online.

The ESPeasy part

I’m using firmware version ESP_Easy_mega-20200328_normal_ESP8266_1M.bin. But this should probably work on newer and older versions too.

I disabled some hardware settings, since we won’t need them:

I have only added a switch to ESPeasy, the relay is controlled by GPIO and MQTT.

Enable the rules engine in Tools -> Advanced:

A new tab “Rules” will appear after you press submit. Add the following rule:

on drukknop#State do
    if [drukknop#State] = 1
        gpio,0,0
    else
        gpio,0,1
    endif
endon

Now your doorbell should already work without the interference of openHAB. So even if openHAB is offline for some reason, your doorbell just works.

The openHAB part

thing

Thing mqtt:topic:deurbel "Deurbel" (mqtt:broker:MosquittoMqttBroker) @ "Meterkast"  {
  Channels:
    Type switch : gpio0    "Power Switch"     [ commandTopic="/deurbel_15/gpio/0", on="0", off="1" ]
    Type switch : drukknop    "Switch State"     [ stateTopic="/deurbel_15/drukknop/State", on="1", off="0"]
}

items

Switch Deurbel_relay “Gong” (gMeterkast, gSensorsStatuses) {channel=“mqtt:topic:deurbel:gpio0”, expire=“1s,state=OFF”}
Switch Deurbel “Deurbel” (gMeterkast, gSensorsStatuses) {channel=“mqtt:topic:deurbel:drukknop”}

rules

val telegramAction = getActions(“telegram”,“telegram:telegramBot:Telegram_Bot”)

var Timer deurbelautooff = null
var Timer ringingprotection = null
var boolean ringing = false

rule “Deurbel auto OFF”
when
Item Deurbel changed to ON
then
logInfo(“Deurbel”, "1a. ringing = " + ringing)
if (ringing == false) {
logInfo(“Deurbel”, "1b. Ringing = " + ringing)
//Deurbel_relay.sendCommand(ON) //UNCOMMENT THIS and delete the rule on the ESPeasy if you want openHAB to control your doorbell.
telegramAction.sendTelegram(“Er staat iemand voor de deur!”)
}

    //Adds protection for pushing the doorbell multiple times within 10 seconds. Doesn't work when the ESPeasy rule controls the doorbel
    if (ringingprotection === null) {
        ringing = true
        ringingprotection = createTimer(now.plusSeconds(10), [|
        logInfo("Deurbel", "2. Ringingprotection = " + ringingprotection)
            ringing = false
            ringingprotection = null
        ])
    }

    if(deurbelautooff === null) {
        logInfo("Deurbel", "3. deurbelautooff = " + deurbelautooff)
        deurbelautooff = createTimer(now.plusSeconds(1), [|
            logInfo("Deurbel", "4. deurbelautooff = " + deurbelautooff)
            Deurbel_relay.sendCommand(OFF)
            deurbelautooff = null
        ])
    }

end

I’ve added multiple protections to turn the doorbell off after 1s.

In my experience there is quite a big lag sometimes between pushing the button and hearing the doorbell when openHAB controls it. So I stopped doing that and created the ESPeasy rule.

2 Likes