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
|
|
Resources
Setting up Node-RED to interact with a Telegram Bot - Ktinkerer