Geek-MD / SmartHomeBot

A simple Telegram Bot used to automate notifications of a Smart Home

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SmartHomeBot

A simple Telegram Bot used to automate notifications of a Smart Home. This is a work in progress.

Made with Python MIT License GitHub Releases GitHub Branches GitHub Stars

Basic Installation

This bot is designed to work on a Raspberry Py and relies mainly on python-telegram-bot, so you have to install this package first with

pip install python-telegram-bot

Also you have to install gpiozero, psutil and requests libraries used for /system and /version command.

pip install gpiozero
pip install psutil
pip install requests

Now clone this repo with

git clone https://github.com/Geek-MD/SmartHomeBot.git

Edit config.json and add your bot Telegram token, id number of allowed and admin users, id number of bot owner, chat id used by your bot, bot id and you're done. Now run with

python smarthomebot.py

If you want to run the bot at startup, or advanced configuration, check the Wiki.

Roadmap

  • Basic functionality, only /start and /help commands. v0.1.0
  • Added a list of allowed users who can interact with the bot. v0.2.0
  • Added a list of admin users who can run admin restricted commands. v0.3.0
  • Fixed a bug with admin restricted commands. v0.3.1
  • Added /reboot command, restricted to admin users. v0.4.0
  • Added confirmation buttons to execute /reboot command. v0.4.0
  • Critical data like Telegram bot token, allowed users list and admin users list are stored in external separate JSON files. v0.5.0
  • Added /system command so admins can check CPU temperature of server, CPU and RAM load. v0.6.0
  • The information displayed by /system command is grouped into one unique message. v0.6.1
  • CPU Temperature is available only in Linux due to limitations of gpiozero library. Added OS check to bypass CPU Temperature measurement. v0.6.2
  • Added /listusers command so any user can check allowed users list. v0.7.0
  • Fixed a bug with /listusers command. Users data now is read using getChatMember API method. Deleted users_data.json so user info is not stored locally. v0.7.1
  • Added owner tag for main user so he can't be kicked off from allowed users or admin list. v0.7.2
  • Added a dynamic keyboard constructor for future commands that uses an inline keyboard. v0.7.2
  • Deleted smarthomebot.json, allowed_users.json, admin_users.json and chats.json files, and unified them on a single file named config.json. v0.7.2
  • Added /adduser command so admins can add users to the allowed users list. v0.8.0
  • Added /user command so admins can remove users from the allowed users list, with the exception of bot owner. v0.8.0
  • Modifications to allowed users list are stored directly to config.json. v0.8.0
  • Added /makeadmin command so admins can upgrade a user to admin list. v1.0.0
  • Added /revokeadmin command so an admin can downgrade a user from admin to allowed user, with the exception of bot owner. v1.0.0
  • Added a specific /adminusers command for listing users with admin capabilities. v1.1.0
  • Highlight admin users at /listusers command. v1.1.0
  • Fixed a bug related to admin users filter. v1.1.0
  • Added f-string to some dialogs. v1.1.0
  • Fixed a bug related to users and commands filters. v1.1.1
  • Fixed a bug related with configuration not getting saved to config file. v1.1.1
  • Added /version command to show local and GitHub version of the bot. v1.2.0
  • Renamed /banuser command to /removeuser. v1.2.0
  • Added /join command to let users ask an admin to approve them into allowed users list. v1.2.0
  • Added /requests command to let admins check pending requests to join allowed users list, and approve or dismiss them. v1.2.0
  • Added /dismiss command to reject a request for joining allowed users list. v1.2.0
  • Fixed a bug related with admin restricted commands, which could be used by non admin users. v1.2.0
  • Added /banuser command so an admin can add a user to banned users list so he can't request joining allowed users list. v1.3.0
  • Added /unban command so an admin can remove a user from banned users list. v1.3.0
  • Added code cleaning, command parser and bug fixes. v1.3.0
  • Added /chatmembers command to list members of a chat, highlighting allowed users, admins and bot. v1.4.0
  • Added a workaround to discover existing and new chat members, so this can be used by /chatmembers command. v1.4.0
  • Fixed a bug with /join command routine. v1.4.1
  • Fixed a bug with listusers_command subroutine. v1.4.2
  • Integrated bot version and bot id in config.json. v1.4.2
  • Added a listusers dictionary so /listusers, /adminusers, /chatmembers and /banlist commands are unified in a single subroutine for code efficiency. v1.4.2
  • Added /time command wich allows users check local hour and date. v1.5.0
  • Splited help string into allowed users help string and admin users help string. v1.5.0
  • Added /admincommands command which shows available commands for admin users. v1.5.0
  • Added /timer command which allows users to set and display timers. v1.5.0
  • Added /alarm command which allows users to set and display alarms. v1.5.0
  • Added specific help for /timer and /alarm commands so main help does not get overpopulated. v1.5.0
  • Add tags to timers and alarms, so they can get an identifier like "dryer", "washing machine", etc.
  • Add restart argument for /timer or /alarm commands, to restart all configured timers or alarms.
  • Add localization and internationalization standards (i18n) so admin can select bot's prefered language.
  • Add /language command so admins can select bot's prefered language.
  • Add /status command so admins can see a list of running Docker containers.
  • Add /restart command so admins can restart a specific Docker container.
  • Add Ring functionality thanks to python-ring-doorbell.

External Functionality

  • Watchtower notification for Docker container updates through Telegram.
  • Receive Telegram notifications from Home app.

About

A simple Telegram Bot used to automate notifications of a Smart Home

License:MIT License


Languages

Language:Python 100.0%