Today we will try to connect the Kerui doorbell to Node-Red and Telegram. As a bonus, we’ll also add a Hikvision camera snapshot to the message.

You will need:


We have covered parts of this project in previous tutorials so I will only point them out to you.

Let me explain the logic first: the sonoff bridge is connected to Node-Red via MQTT. First input nodes subscribes to the topic of the sonoff bridge and outputs all data received. Second node limits the data to 1 message per second. As the data is in string form, we need to convert that into an object (3rd node). The switch node filters the data and forwards only the messages from the doorbell. If such a message is received, the flow will split in two parts: the first part is sending us a text message via Telegram and the second part takes a snapshot from a Hikvision camera and forwards it to you.

The nodes:

MQTT input node

Take a look at this post. It will explain step by step how you connect the Sonoff RF Bridge to Node-Red

Delay node

The delay node from the Node-RED offers you the possibility to limit the rate of the messages. I’ve chose 1 message per second and I think this will work in your case also.

JSON node

Nothing to configure here, leave it as is.

Switch node

First of all, let’s add a debug node after the JSON node to find the code for the doorbell.

Debug node

When you touch the doorbell a message will appear in the debug window. Note that down.

Finally, the switch node:

Function node – message

Follow this tutorial to learn how to send messages from Node-Red

Taking a snapshot

Follow this tutorial to learn how to take snapshots using Hikvision ip camera. You can use /dev/shm/snapshot.jpg for the filename.

For sending images through Telegram, use a function node that contains:

msg.payload = {
    chatId: YOUR-ID-HERE,
    type: "photo",
    content: "/dev/shm/snapshot.jpg"
};
return msg;

Find your Telegram ID

We created a bot that could tell you your Telegram ID. Ask it for your ID using /myid command

Click here to chat with our bot.