MQTT Client Telegram Bot
mqtg-bot is an easy-to-configure for your needs MQTT client Telegram bot. Without programming knowledge you can configure the bot to send various commands (turn on the light, open the garage door, etc.) or request any information (the temperature in the house, the state of the heating system, etc.) or receive frames from security camera. In general the functionality of this solution is very rich.
You can run the bot on your Raspberry Pi home server or free Heroku dyno.
Clone this repository:
git clone https://github.com/xDWart/mqtg-bot
Message @BotFather /newbot
command to create a bot and get his HTTP API access token.
TELEGRAM_BOT_TOKEN
- bot HTTP API access token, requiredDATABASE_URL
- Postgres connection string in the following format: postgres://user:password@host:port/db
SQLITE_PATH
- path to SQLite databaseMQTT_CLIENT_ID
- Client ID to be used. Required for VerneMQ.Notes:
TELEGRAM_BOT_TOKEN
env is requiredDATABASE_URL
env is omitted, or a Postgres connection error occurred, SQLite will be usedSQLITE_PATH
env is omitted, mqtg.db
will be used by default as a SQLite database.env
file in the root of the project and insert your key/value environment variable pairs in the following format of KEY=VALUE
You can run mqtg-bot with environment variables:
TELEGRAM_BOT_TOKEN=... go run main.go
or if you've already created the .env
file:
go run main.go
docker run -e TELEGRAM_BOT_TOKEN=... -e DATABASE_URL=... --network=host owart/mqtg-bot
You will need Heroku CLI
# login into Heroku
heroku login
# create a new app
heroku create *YOUR_APP_NAME*
# add your new app into git remotes
heroku git:remote -a *YOUR_APP_NAME*
# add TELEGRAM_BOT_TOKEN environment
heroku config:set TELEGRAM_BOT_TOKEN=*BOT_ACCESS_TOKEN*
# set version of Go
heroku config:set GOVERSION=go1.15
# attach Postgres add-on
heroku addons:create heroku-postgresql:hobby-dev
# push master branch to Heroku
git push heroku master
# scale up your app
heroku ps:scale worker=1
Then just message /start
to your bot and follow the instructions to configure it.