/newbot
and follow the steps specified by the BotFather. This results in a token, this token (e.g. something like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
is required for defining a working telegram bot in fhem.
sudo apt-get install libjson-perl
) or the correct method for the underlying platform/system.Contacts
) and also internally in the module in a hashed list to allow the usage
of contact ids and also full names and usernames. Contact ids are made up from only digits, user names are prefixed with a @, group names are prefixed with a #.
All other names will be considered as full names of contacts. Here any spaces in the name need to be replaced by underscores (_).
Each contact is considered a triple of contact id, full name (spaces replaced by underscores) and username or groupname prefixed by @ respectively #.
The three parts are separated by a colon (:).
define <name> TelegramBot <token>
define teleBot TelegramBot 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
set <name> <what> [<value>]
message|msg|send [ @<peer1> ... @<peerN> ] <text>
set aTelegramBotDevice message @@someusername a message to be sent
set aTelegramBotDevice message @@someusername @1234567 a message to be sent to multiple receipients
set aTelegramBotDevice message @Ralf_Mustermann another message
set aTelegramBotDevice message @#justchatting Hello
set aTelegramBotDevice message @1234567 Bye
sendImage|image [ @<peer1> ... @<peerN>] <file> [<caption>]
sendMedia|sendDocument [ @<peer1> ... @<peerN>] <file>
sendVoice [ @<peer1> ... @<peerN>] <file>
replaceContacts <text>
reset
defaultPeer <name>
defaultPeerCopy <1 (default) or 0>
cmdKeyword <keyword>
ok fhem
then a message starting with this string will be executed as fhem command
(see also cmdTriggerOnly).ok fhem
a message of ok fhem attr telegram room IM
send to the bot would execute the command attr telegram room IM
and set a device called telegram into room IM.
The result of the cmd is sent to the requestor and in addition (if different) sent also as message to the defaultPeer (This can be controlled with the attribute defaultPeerCopy
).
shutdown
is not supported as a command (also in favorites) and will be rejected. This is needed to avoid reexecution of the shutdown command directly after restart (endless loop !).
cmdSentCommands <keyword>
last cmd
a message of last cmd
woud lead to a reply with the list of the last sent fhem commands will be sent back.cmdFavorites <keyword>
favorites
).
favorite
a message of favorite
to the bot will return a list of defined favorite commands and their index number. In the same case the message favorite <n>
(with n being a number) would execute the command that is the n-th command in the favorites list. The result of the command will be returned as in other command executions.
Please also consider cmdRestrictedPeer for restricting access to this feature!favorites <list of commands>
favorite
and this attribute is set to a value of
get lights status; /light=set lights on; /dark=set lights off; /heating=set heater;
get lights status
set lights on
set heater on
get lights status; /light=?set lights on; /dark=set lights off; ?set heater;
cmdRestrictedPeer <peername(s)>
cmdTriggerOnly <0 or 1>
ok fhem
and cmdTriggerOnly is set, then a message of ok fhem someMacro
would execute the fhem command trigger someMacro
.
cmdReturnEmptyResult <1 or 0>
pollingTimeout <number>
pollingVerbose <0_None 1_Digest 2_Log>
PollingErrCount
and PollingLastError
maxFileSize <number of bytes>
maxReturnSize <number of chars>
maxRetries <0,1,2,3,4,5>
saveStateOnContactChange <1 or 0>
allowUnknownContacts <1 or 0>
define notify_fhem_reload notify global:INITIALIZED set <telegrambot> message fhem started - just now
Send the following message as a command to the bot ok fhem { plotAsPng('SVG_FileLog_Aussen') }
assuming ok fhem
is the command keyword)
cmdSentCommands
is set to /History
. Then you can initiate the communication with the botfather, select the right bot and then with the command /setcommands
define one or more commands like
History-Show a history of the last 10 executed commands