Send a telegram notification every time a wifi client is connected / disconnected from your OpenWrt router.
- Create a telegram bot at https://t.me/BotFather Copy your
BOT_TOKEN - Start your bot by sending it any message.
- On your browser, go to:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getupdatesyou'll see something like this:{"ok":true,"result":[{"update_id":897000000,"message":{"message_id":2,"from":{"id":6341811111,"is_bot":false,"first_name":"500000","language_code":"en"},"chat":{"id":6341811111,"first_name":"500000","type":"private"},"date":1707224377,"text":"Test"}},{"update_id":897000000, 6341811111is yourCHAT_ID. Copy that as well.- SSH to your OpenWrt router and do:
touch /etc/config/telegram-bot uci set telegram-bot.mybot=wifibot uci set telegram-bot.mybot.token='YOUR_BOT_TOKEN' uci set telegram-bot.mybot.chat_id='YOUR_CHAT_ID' uci commit - Edit
/etc/dnsmasq.confand comment out the following linelog-facility=so your/etc/dnsmasq.confshould look like this:Then restart the service:#log-facility=/etc/init.d/dnsmasq restart - Copy the script
98-client-join-notificationto your OpenWrt folder at/etc/hotplug.d/dhcp/ - Copy the script
client-remove-notification.shto your OpenWrt folder at/usr/bin/ - Make both scripts executable:
chmod +x /etc/hotplug.d/dhcp/98-client-join-notification /usr/bin/client-remove-notification.sh - Edit your OpenWrt crontab with the command
crontab -elike this:* * * * * /usr/bin/client-remove-notification.sh - Restart your crontab:
/etc/init.d/cron restart - DONE. Try turning your wifi off / on, you should see a notification on your telegram account.
- When you reboot your router, you'll get a bunch of
New device JOINED your networkmessages on telegram - When a device is removed from your network, it takes 1 minute to be notified on telegram

