Telegram - Setting Up Remote Control - Functionality

From Domoticz
Jump to navigation Jump to search

Telegram is capable of functioning not only as a notification system, but also as a bot which is able to interact fully with a Linux system. The Linux command-line client is supplied with a prototype bot which is written in Lua. Adding to the work of others (http://www.domoticz.com/forum/viewtopic.php?f=5&t=1985) this is now a full framework for interacting with Domoticz.

Follow the instructions on the wiki for installing Telgram, Installing Telegram Notification System, including the specific instructions for automation Telegram - Setting Up Remote Control - Foundations.

Once installed you can just switch any device on and off from any Telegram client:

You need get the case and the spelling of your device names right

Can't remember the name of your devices, no problem just type devices (once again you need to get the case of the letters and the spelling right):

That list is rather long and typing the whole device name is rather tedious / prone to error, so if you know the start of your device name then Telegram can return a shorter list of just those devices:

You can now use the number from the list to turn the device On or Off, but you could still use the name too.

Telegram will remember those numbers until you generate a new list and will tell you when you get it wrong:

On and Off are all very well, but to find out what else can be done type help:

Help will tell you all the commands, letting you know that some of the commands have been implemented in Lua and some as shell scripts.

Help followed by a command name will tell you just about that command.

Replacing devices with scenes gives you a list of all the scenes and the groups on your Domoticz system:

Now it is possible to turn groups on and off, activate scenes by turning them on:

If a scene turns things off, then saying On Scene Name will activate the scene and turn things off. For groups the wording is more logical.

The number list is remebered until a new list is generated by devices or scenes, and so entering a number outside the most recent list will result in an error:

Using Telegram in this way you have the total power of Lua combined with Domoticz's json api, so you could extend the bot to do literally anything Domoticz and Lua can do. Howewer, where Domoticz already has the capability such as groups and scenes then it is best to keep the configuration inside Domoticz making it generally available not just in Telegram.

Equally it is relatively easy to take existing Lua scripts and adapt them for use remotely by Telegram, so the Battery command is adapted from the Lua battery level check on the wiki - http://www.domoticz.com/wiki/Battery_level_check:

It is also easy to create bash scripts which can do anything from interacting directly with Domoticz to interacting with any other system accessible to bash scripts. This script just checks for the most recent version of Domoticz available:

This script checks your system status:

Scripts can need to be customised for your system such as the example temperature.sh, which will need the ids of your temperature sensors:

You can often do the same things with Lua or bash - so smiliesoverview use bash and Smiliesoverview uses Lua:

Of couse you are in fact not limited to bash and Lua, but can use anything on your system which can be executed by Lua use os.execute.

Telegram does not provide a sophisticated GUI, but is highly flexible and able to give sophisticated remote control with minimal communication bandwith.

Please have a look at this and add your own functions, please share them here or on the wiki.


To set this up see these pages below, you need to follow the foundations page, then you get some Lua functions and Bash scripts anyway, if you follow up on the other pages, then you can create your own.

The first step is to set up the Lua script and the initial scripts - Telegram - Setting Up Remote Control - Foundations.

Then it is easy to create some specific Lua functions based on the information on the this wiki - Telegram - Setting Up Remote Control - Lua Functions.

There are lots of Bash scripts on the Wiki which can be linked into Telegram - Telegram - Setting Up Remote Control - Bash Scripts.