New Telegram Binding - Tester and Feedback welcome

I have mentioned this before here, with the same bot…
And I think it is recommended for everyone, because you can’t get the chatId any other way if that API endpoint is empty…

Could it be empty because it was already consumed by the binding? Maybe you would see it when you stop the binding first, send your message and then open the link.

Of course, using the bot you mentioned is easy, but it’s not an official bot and we don’t know how long it will exist.

I noticed that you can just start a chat with your openHAB bot (send a random message) and in the log you will see an entry that the chat id is unknown and needs to be added to the config. I really love that “feature”!

Not really… it only worked a few times for me.
And if you use an already created group (which you’ll do if you want to deliver these automated messages to multiple people and not individually deliver - which doesn’t make sense if you have to make a decision in my opinion… Whose answer will be the correct answer?) it will never work…

IIRC I tried that, too. Yes it likely was consumed by the binding because I had another telegram user active that I kept sending the message to. It’s ages back that I had set that up, and it’s chatID is still valid. As I said the problem only became apparent when I wanted to add messaging to a second user.

Either way, if the JSON reponse is empty then there just is no other way of getting the chatID (at least none that I know of) and when I g**gled, I found several docs of other systems to also send to telegram that also recommend getting the chatID that way.
And there’s actually many more bots to offer the same functionality such as @myidbot. There’s even ones that don’t work, but you can use either of them.

FYI: OpenHab can make Telegram Phone Calls now! (with TTS Voice)
Nice!

3 Likes

Hi @JensH,

is there a chance to have a textual configuration for the thing itself?

Many thanks & KR,
Chris

I configured thing in PaperUI, because didn’t found syntax for textual configuration at the binding site.

But would be interested too :wink:

Thing telegram:telegramBot:gbot "Telegram" @ "Internet" [chatIds="xxxxx", botToken="yyyyy", parseMode="Markdown"]

and

String      Telegram_MessageText    "Last Message Text [%s]"                                                    { channel = "telegram:telegramBot:gbot:lastMessageText" }   
DateTime    Telegram_MessageDate    "Last Message Date [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]"                        { channel = "telegram:telegramBot:gbot:lastMessageDate" }   
String      Telegram_MessageName    "Last Message Name [%s]"                                                    { channel = "telegram:telegramBot:gbot:lastMessageName" }   
String      Telegram_MessageUser    "lastMessageUsername [%s]"                                                  { channel = "telegram:telegramBot:gbot:lastMessageUsername" }   
String      Telegram_ChatID         "Chat ID [%s]"                                                              { channel = "telegram:telegramBot:gbot:chatId" }    
String      Telegram_ReplyID        "Reply ID [%s]"                                                             { channel = "telegram:telegramBot:gbot:replyId" }
1 Like

Many thanks @Olymp - will give it a try in the afternoon :slightly_smiling_face:!

KR,
Chris

With more than one chat Id: Komma separated?

For me this worked with multiple chat Ids:

Thing telegram:telegramBot:bot1 "Telegram Bot" [ botToken="token", chatIds="123","456", parseMode="Markdown" ]

2 Likes

Thanks a lot.

If it works finde, ich hope I will remember to put Example in Binding-Documentation Site :slight_smile:

As far as i understand the binding compared to the action, i can only add one bot, right?
I could use one bot with multiple chatIds but that would send the message to both chats when just using telegramAction.sendTelegram("<message>")
So i need to use the chatId everytime i want to send a message to only one chat.

Is there any smarter way for this?
I already tried to create an val String bot1 = <chatID> but i´m not able to use it in telegramAction.sendTelegram(bot1, "<message>")
It was a lot easier to build a rule with sendTelegram actions compared to the new binding :frowning:

You can use a variable for chat I’d as long value.

 var long NameChatId = 12345L

Then use NameChatId as variable to send

is the L character required after the chatid?

edit: ahh it is.

Is there a way to add a port to the image URL?
I always get the following error message when using an image URL with a port:

2020-02-19 22:08:08.310 [WARN ] [binding.telegram.bot.TelegramActions] - Download from http://192.168.178.91:18188/ipcamera.jpg failed with exception: org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: bad response on HttpConnectionOverHTTP@b2d0d8::SocketChannelEndPoint@a92176{/192.168.178.91:18188<->/192.168.178.91:40426,OPEN,fill=-,flush=-,to=15/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@b2d0d8(l:/192.168.178.91:40426 <-> r:/192.168.178.91:18188,closed=false)=>HttpChannelOverHTTP@da3e61(exchange=HttpExchange@1ca6a0e req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@19cf9e0(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@bdc574{s=START}],recv=HttpReceiverOverHTTP@129c534(rsp=IDLE,failure=null)[HttpParser{s=CLOSE,0 of -1}]]

I am using the below rule:

rule "Gefrierschrank Timer"
when
    Item ug_tuer_gefrier_Timer received command OFF
then
        val telegramAction = getActions("telegram","telegram:telegramBot:abcd")
        logWarn("Gefrierschrank","Gefrierschrank seit 3 Minuten offen!")
        ug_tuer_gefrier_3min_offen.sendCommand(ON)
        telegramAction.sendTelegramPhoto("http://192.168.178.91:18188/ipcamera.jpg", "Gefrierschrank ist seit 3 min offen")
end

Thank you!

Hi, im using this binding for sending WeatherIcons with Description.
Now I’am wondering that using Markup or Html is not working in this additional Textes.
Is this not working in general from TelegramAPI for sending Photos or is it not implemented.
May someone check this?
Thanks

I updated to the latest version of the binding and now it is working properly.

Thanks guys, this is really cool that telegram binding!

Just started using it and I would like to use a triggeringItem.name when sending the text message.
Is this possible, cause I can´t find this in the binding description.
What would be the correct usage?

like:
val telegramAction = getActions(“telegram”,“telegram:telegramBot:xxxx”)
telegramAction.sendTelegram(“triggeringItem.name”)

Maybe it should be somehow like

telegramAction.sendTelegram("Movement triggered on", triggeringItem.name.toString)