- Set up Maker API on
hubitat.local
or useDEFAULT_HUB_IP
environment variable to specify the IP of your primary hub. - Configure mandatory environment variables:
MAKER_API_APP_ID
,MAKER_API_TOKEN
,BOT_TOKEN
.
- If you know the ID of your DM chat with your bot, you can add it as
CHAT_ID
variable. - If your primary hub is not using
hubitat.local
DNS entry, useDEFAULT_HUB_IP
to specify the ip.
- Deploy the Docker container.
- Start sending commands to your bot!
-
Device Commands:
/on [device name]
- Turns on a specified device./off [device name]
- Turns off a specified device./open [device name]
- Opens a specified device (e.g., shades)./close [device name]
- Closes a specified device./set_color [device name] [color]
- Sets the color of a compatible device./set_color_temperature [device name] [temperature]
- Sets the color temperature of a compatible device./set_level [device name] [level]
- Sets the level of a dimmable device./double_tap [device name]
- Executes a double tap action on a button device./push [device name]
- Executes a push action on a button device./hold [device name]
- Executes a hold action on a button device./release [device name]
- Executes a release action on a button device./get_open_sensors
- Lists all sensors that are currently open.
-
System Commands:
/cancel_alerts
- Cancels all alerts in HSM./update
- Updates all hubs for which Hub Information Drivers are exposed in the Maker API ofhubitat.local
./reboot [Hub Information Driver v3 instance name]
- Reboots a specified hub.
You can refer to devices in several ways:
- Full name: Use the complete device name.
- Example:
/on Kitchen Lights
- Example:
- Short name: Omit
Lights
orLight
if they are the last word in the name.- Example:
/off Kitchen
- Example:
- Abbreviation: Use the first letters of each word in the full name.
- Example:
/on kl
- Abbreviation conflicts can be resolved by specifying the first non-conflicting letter in the first non-conflicting word of the name:
- Let's assume you have three conflicting devices,
Main Bedroom Lights
,Main Backyard Lights
, andMain Bathroom Lights
. All three are abbreviated tombl
, which creates a conflict. - Use
mbel
forMain Bedroom Lights
ase
in the second word (Bedroom) is the first unique letter, distinguishing it fromMain Backyard Lights
andMain Bathroom Lights
. - Use
mbacl
forMain Backyard Lights
asc
in the second word (Backyard) is the first unique letter, distinguishing it fromMain Bathroom Lights
. Usingmbal
won't be enough, as it is still the same for bothMain Bathroom Lights
andMain Backyard Lights
. - Correspondingly,
Main Bathroom Lights
is uniquely abbreviated tombatl
, notmbal
.
- Let's assume you have three conflicting devices,
- Example:
- For hub updates: Hubitat version 2.3.9.175 or higher.
- Install the Maker API app on the
hubitat.local
hub. - Ensure Maker API control of HSM is allowed for
/cancel_alerts
. - Expose all needed devices in Maker API (including devices from other hubs via mesh).
- Ensure Hub Information Driver v3 is installed on every hub (via Hubitat Package Manager) and exposed in Maker API on
hubitat.local
(directly and via mesh). - Create a bot in Telegram using BotFather bot.
- (Optional) create commands in the bot using BotFather's
/setcommands
command. This is optional as you can send arbitrary commands by text without completion in the bot. - Configure environment variables:
- Mandatory:
MAKER_API_APP_ID
- The Maker API app ID.MAKER_API_TOKEN
- The Maker API token.BOT_TOKEN
- The Telegram bot token.
- Optional:
CHAT_ID
- The ID of your DM chat with the Bot (or other chat the bot is added to). If you use that variable, the bot will be able to proactively send information to the chat. If you don't use it, it will only reply to your messages. There are number of ways to find this ID, some of them are listed here.DEFAULT_HUB_IP
– The IP of the hub the Maker API app is installed on. Defaults to DNS hostname ofhubitat.local
.
- Deploy the Docker image:
- Load the Docker image:
docker load < tg-hubitat-bot-docker-image.tar
- Create and run the container:
docker run -d --name tg-hubitat-bot -e MAKER_API_APP_ID -e MAKER_API_TOKEN -e BOT_TOKEN tg-hubitat-bot
- Load the Docker image:
To add support for new device types:
- Update the
Device
sealed class inDevice.kt
to include the new device type. - Add the appropriate
supportedOps
for the new device type. - Define the appropriate
attributes
for the new device type. - If necessary, update the
DeviceManager
to handle any special cases for the new device type, including how to query and interpret the new attributes. - Test the new device type to ensure that all operations and attribute queries work as expected.
- Build the project using
./gradlew build
. - Create the Docker image using
./gradlew jibDockerBuild
- (Optional) Export the image to tar file using
./gradlew jibBuildTar