Telegram Bot Integration - themactep/thingino-firmware GitHub Wiki
Telegram Bot Integration
Thingino can communicate via Telegram to receive commands and send replies, which can be still images or video clips from the camera.
Configuration
Telegram Bot Integration can be configured via Settings --> Telegram Bot (config-telegrambot.html).
This requires at least a Telegram Bot token. How to obtain this token is described on the configuration page.
The configuration entered in the Telegram Bot Configuration page is stored int /etc/telegrambot.json.
The configuration contains a few preconfigured commands that the bot responds to, such as start, help or snap to take a still image.
The shell commands specified as actions for each command are run as root. Their (text-)output is returned in the telegram chat.
The shell command send2telegram, a shell script residing in /sbin/send2telegram can be used in actions to send still images (command /sbin/send2telegram -S) or short video clips (command /sbin/send2telegram -V) to a telegram chat.
send2telegram does not use the tokens and settings from the configuration page (stored in /etc/telegrambot.json) but from the telegram section in the configuration file /etc/send2.json.
Due to this the preconfigured commands snap to 'Snap a picture' with the action /sbin/send2telegram -S and clipto 'Record a clip' will not work without either setting the token in /etc/send2.json or extending the action command to provide the token via the command line parameter -t.
send2telegram also needs a channel to reply to, which can either be configured via /etc/send2.json or, according to the hint at the settings page can be given via the parameter -c from the variable $chat_id.
The later is required if the bot shall reply with the images or videos in the same chat where the commands are sent, which is usually desired.
⚠️This seems to be currently broken, see https://github.com/themactep/thingino-firmware/issues/1367, resulting in the $chat_id variable to not being set.
The fixed chat id for a telegram channel set in /etc/send2.json can be obtained e.g. from the Telegram web client.
When accessing a channel on the web client, the channel id can be found in the URL in the form https://web.telegram.org/k/#-12345678, where the number 12345678 is an example for a partial chat or channel id.
To be a valid channel id this number 12345678 must be prefixed with '-100' resulting in '-10012345678' as the entry for the channel setting in /etc/send2.json.
⚠️When updating the Telegram Bot Service Settings on the settings page, saving the changes and restarting the Telegram service via the button 'Restart Service' the settings are not taken into account. Instead a full restart of the camera is required for the settings to be applied. See https://github.com/themactep/thingino-firmware/issues/1367.
Commands and Actions for panning and tilting the camera
| Command | Description | Action |
|---|---|---|
| left | Pan the camera left | motors -x -100 -y 0 -d g; motors -p |
| righ | Pan the camera right | motors -x 100 -y 0 -d g; motors -p |
| up | Tilt the camera up | motors -x 0 -y 100 -d g; motors -p |
| donw | Tilt the camera down | motors -x 0 -y -100 -d g; motors -p |
| home | Home the camera | motors -d h; motors -p |