Zigbee Doorbell - WIP

Problem

When I’m sat in my garden or working in my 2nd floor office, I can’t hear people knocking nor can I hear the doorbell. As you can imagine this can be very frustrating!

Firstly it’s worth pointing out that you could just buy a ring doorbell, they are a great consumer product however I’ve noticed that these things never play nice with my smart home and to be honest, using a £8 button (that I had in a box) is a lot cheaper than the cheapest ring version.

Solution

Using a zigbee button, send an alert to my phone so that I know someone is at the door.

Hardware

Xiaomi Mijia Wirelss Switch that connects to my Zigbee network. TRÅDFRI, Signal repeater - IKEA while they are strictly not necessary, I have found these really useful to increase coverage of my Zigbee network.

Software

A smart home setup, in my case I have docker containers running Home Assistant and Node-Red and a Raspberry Pi running Phoscon (precompiled images using Conbee2). Telegram Bot for sending myself a message. I’ve never used Telegram, and this seemed like a perfect opportunity to try it. node-red-contrib-telegrambot Node-Red telegram package.

Setup

1. Create a telegram bot. https://core.telegram.org/bots

Creating a new bot

Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.

The name of your bot is displayed in contact details and elsewhere.

The Username is a short name, to be used in mentions and t.me links. Usernames are 5-32 characters long and are case insensitive, but may only include

Latin characters, numbers, and underscores. Your bot’s username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.

The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API . Keep your token secure and store it safely, it can be used by anyone to control your bot.

2. Start chat with bot and find my chat id

I had Telegram contacts disabled so I went to http://telegram.me/username_of_my_bot and then sent a hello in the app. Get my chatid - http://telegram.me/myidbot and send /getid

3. Node-Red Telegram test

Make sure that you have node-red-contrib-telegrambot installed. This will then give you what you need to configure Telegram in Node-Red.

3. Trigger Telegarm when button pressed

Node-Red Code

1
[{"id":"f7d4e387.435e6","type":"inject","z":"864d7f67.beff8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":680,"wires":[["9bbf06af.821e78"]]},{"id":"9bbf06af.821e78","type":"function","z":"864d7f67.beff8","name":"Create Message","func":"var time_now = new Date();\nmsg.payload = {chatId :123456789, type : 'message', content : time_now.toLocaleString()}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":740,"wires":[["4e87ca46.89ab24"]]},{"id":"4e87ca46.89ab24","type":"telegram sender","z":"864d7f67.beff8","name":"","bot":"","haserroroutput":false,"outputs":1,"x":480,"y":800,"wires":[[Kitchen Storage Idea]]},{"id":"3899b1dc.0995be","type":"comment","z":"864d7f67.beff8","name":"Create a message with chatid and payload of the current datetime","info":"","x":740,"y":740,"wires":[]},{"id":"b7a55f83.be98d","type":"comment","z":"864d7f67.beff8","name":"Configure with bot username and token.","info":"","x":760,"y":800,"wires":[]}]

Resources

Setting up Node-RED to interact with a Telegram Bot - Ktinkerer

node-red-contrib-telegrambot

NotifyMe

https://www.thomptronics.com/about/notify-me