A Telegram Bot for managing Tasmota devices over MQTT
TasmotaBot is intended to be deployed in Linux environments, since it uses systemd
to run as a background service.
You will need:
- A Linux machine with ASP.NET Core 6 runtime installed
- A Mosquitto server that allows anonymous connections.
Authorization support may be added in later versions. - At least one Wi-Fi relay flashed with Tasmota
- A Telegram bot with power toggle and power state commands for each device. More info here
- Download the package that corresponds to the architecture of your Linux machine.
- Configure the application using
appsettings.yml
. - Create a
.service
file:
sudo vim /etc/systemd/system/tasmota-bot.service
You can use this gist or make your own service file.
This article explains how to create a systemd
file for a .NET application in great detail.
Don't forget to set ownership for all application files in the directory to yourself:
sudo chown $USER /path/to/application
- Run the app:
sudo systemctl enable tasmota-bot.service && sudo systemctl start tasmota-bot.service
This section will walk you through the process of configuring your bot.
- Create an
appsettings.yml
file in the application directory.
You can find the default suggested setup inappsettings_template.yml
- Provide a host name or an IP address for your Mosquitto server in
MqttInfo:Server
. - List the devices connected to your Mosquitto server that you wish to control in
MqttInfo:Devices
.
The list must be in the object array format; each object bust have the following properties:Name
- The name of the device that will be used by the bot to refer to it in chat messages.Topic
- A unique topic for the device.TelegramCommands
- Commands sent through Telegram chats responsible for toggling the power of the device (TogglePower
) and showing current power state of the device (Status
).
For instance, if the device controls your kitchen light, you must have two respective commands for turning on/off the device (e.g./kitchenlight_toggle
) and requesting the status (e.g./kitchenlight_status
).
These commands should be declared using BotFather.
- Provide the authentication token for your Telegram bot in
Telegram:BotToken
. - List the IDs of the users who are permitted to use the bot in
Telegram:AllowedIds
.
Q/A will be added upon their emergence and resolution.