This project allows you to connect a physical doorbell to a Raspberry Pi and send a notification to a Telegram chat when the doorbell is pressed. It's a simple and effective way to integrate your doorbell with a messaging platform for real-time notifications.
- Raspberry Pi (with GPIO support)
- Python 3
- Internet connection
- Telegram account
-
Install Python on your Raspberry Pi:
sudo apt-get update sudo apt-get install python3 python3-pip
-
Install required Python packages by creating a virtual environment (optional but recommended):
python3 -m venv myenv source myenv/bin/activate # activate the virtual environment pip install -r requirements.txt
If you don’t want to use a virtual environment, simply run:
pip3 install -r requirements.txt
-
Create a Telegram Bot:
- Open Telegram and search for
@BotFather. - Start a chat with
@BotFatherand use the/newbotcommand to create a new bot. - Follow the instructions and get your API Token.
- Open Telegram and search for
-
Configure
config.yml:- Copy the API Token you received from
@BotFatherinto theconfig.ymlfile under thetelegram.api_tokenfield. - Send a message to the bot you just created to initialize the chat.
- Retrieve your Chat ID:
- Open a browser and visit the following URL (replace
API_KEY_HEREwith your bot's API key):https://api.telegram.org/botAPI_KEY_HERE/getUpdates - Look for your message and copy the
chat.idvalue.
- Open a browser and visit the following URL (replace
- Add this Chat ID to your
config.ymlfile undertelegram.chat_id.
- Copy the API Token you received from
-
Connect your Doorbell to the Raspberry Pi:
- Connect a button or sensor (doorbell) to one of the Raspberry Pi's GPIO pins (e.g., GPIO pin 17).
- Ensure proper wiring (one side to a GPIO pin, the other side to GND).
-
Edit Configurable Messages:
- You can modify the messages that are sent when the system starts, when the doorbell is pressed, or when the system is stopped. These are located in the
config.ymlfile undermessages:telegram_messages: system_start: "The doorbell notification system is online." doorbell_ring: "Someone is at the door!" system_shutdown: "The doorbell notification system is being turned off." gpio_cleanup: "The system has been shut down and cleaned up."
- You can modify the messages that are sent when the system starts, when the doorbell is pressed, or when the system is stopped. These are located in the
-
Start the Python script to listen for the doorbell:
python3 your_script.py
-
The system will now monitor the GPIO pin for a doorbell press and send a Telegram notification to the configured chat.
settings:
enable_cmd_prints: false # Toggle to enable/disable console prints
log_telegram_send: false # Toggle to enable/disable logging Telegram message send status
gpio_pin: 17 # Define the GPIO pin number here
telegram:
api_token: 'YOUR_BOT_API_KEY'
chat_id: 'YOUR_CHAT_ID'
print_messages:
system_start: "System started and waiting for the doorbell signal."
doorbell_ring: "Doorbell was pressed!"
system_shutdown: "System is shutting down..."
gpio_cleanup: "GPIO cleanup done and system is stopped."
telegram_messages:
system_start: "ℹ️ Important Information\n\nThe doorbell system has started!"
doorbell_ring: "💥 Important Information 💥\n\nThe doorbell has rung!"
system_shutdown: "ℹ️ Important Information\n\nThe system is shutting down!"
gpio_cleanup: "ℹ️ Important Information\n\nThe system has been powered off."- W.I.P Branch there is the TO DO list
- TBC
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
