New Telegram Binding - Tester and Feedback welcome

Hi, yes it helps a little but the problem is not solved.
I have the same problem with normal messages without pictures, too.

On average, every third message isn’t send.

Thx!

That’s awesome. Is there any option to get an official release soon? :slight_smile:

Hey guys,

I know it’s long ago that I wrote something in that thread. But I had quite some trouble with the new build environment and also with the complexity of the underlying Telegram Bot Library. I also had the feeling that the library was not very stable and since it has many dependencies the resulting jar was huge (5-10MB) and also not so easy to debug. I therefore decided to switch to a different library from pengrad. The new binding is less than 1 MB and I hope it pays off.

You can download the new binding here: https://github.com/ZzetT/openhab2-addons/releases/download/2.5.0.M3_telegramBot/org.openhab.binding.telegram-2.5.0-SNAPSHOT.jar

I compiled it against the last milestone release OH-2.5.0.M3. It will probably not work with older versions. If you still have the old binding installed, I recommend to uninstall that first and restart OH to make sure that the old one is completly disconnected.

Please don’t forget to read the new README.md. I had to rename the API to send questions from sendTelegram() to sendTelegramQuery(), because it was ambiguous with the API to send a formatted message.
Also the botName was removed from the configuration because it’s not necessary anymore (you can still name the thing itself).
Now, it should also support multiple chats. For that, you don’t have to create multiple bots, but you can add the chat ids to the list of the thing and either send the message to all chats or to a particular chat. Just pass the chatId as a first argument.

Looking forward to your feedback!

6 Likes

Basically what changes are necessary in a setup if I upgrade to this version? Just replace sendTelegram with sendTelegramQuery when sending these questions?

Yes, and remove the bot name (first argument) from the sendTelegram[…] call.

After testing I have noticed that sendTelegramQuery (string, null, null) is working howerver the photo sending does not work. Nothing happens. The v1 action equivalent does work

code tried:
val telegramAction = getActions(“telegram”,“telegram:telegramBot:2b155b22”)
telegramAction.sendTelegramPhoto(“http://www.openhab.org/assets/images/openhab-logo-top.png”, “sent from openHAB”)

For me this works. I also tried it with your URL.

Could you check the logs for any errors?

For me it works better than before. Now the answers also arrive properly to openhab.

Sidenote, but I can’t get the ChatId of a Group where a bot is added. Any suggestions? I only get empty response (with status ok).

Ok, so if someone has the same problem, you can try this bot:

Just add it to a group chat and send /my_id to the chat. It will reply with the group chat id. You can remove this bot after this operation.

1 Like

Still having the

'sendTelegramQuery' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'

issues. I am using the latest version (3rd October 2019). Will try it out on a completely fresh installed system soon. I have no idea what I’m missing here.

This problem is still there:

'Send the prepared file': Instance is not an TelegramActions class.

I think this only appears if you restart the Telegram bundle.

Hey guys,
I wanted to test the new binding as I’m currently using the old action. Adding the bot via PaperUI doesnt somehow work, as it does not acceppt my chatIds. The value remaines “red” and I cannot save.


Tokens and chatids are not real ones

Secondly I’m not sure how to create a local telegram.things file. Can anyone share a sample to a thing file?

Also I have to admit I’m a bit puzzled on the naming conventions of chatId. I do have a bot with an ID. I have my own and my wifes ID, and I have a group ID, where we are all together.
I use my, my wifes and group ID to send messages to. Are these the 3 I have to set in “ChatIDs” thing?

Thanks for your help.
Best Sebastian

1 Like

Enter the chatIds one by one. If you enter one, hit the Enter key. Then it will get saved and you can enter more chatIds like this. This is a really ‘dumb’ way how the UI is designed in these cases…

1 Like

Thanks @rkrisi, this worked like charm, even though I feel a bit dump now :slight_smile:

1 Like

I didn’t add any new features, but in case you have problems with sending messages/files and don’t see anything in the log, I now forwarded the warnings/errors from the Telegram Library to the OH log.

This message is not affected by the above mentioned change, because it doesn’t come from the library. I couldn’t really reproduce it. In the worst case it could mean that getActions() returns a null which means that the thing id is invalid.

In addition, if your bot token is wrong, the OH thing will go offline now.

https://github.com/ZzetT/openhab2-addons/releases/download/2.5.0.M3_2_telegramBot/org.openhab.binding.telegram-2.5.0-SNAPSHOT.jar

Please make sure to always uninstall the old binding first. Just replacing the jar in the addons folder doesn’t work.

Thanks I’ll test this version soon.

You mean that deleting the file and copying the new one?

This binding is now merged and available in the latest snapshots…

Thank you @ZzetT and all others involved…

I really like the sendTelegramQuery and sendTelegramAnswer actions !

1 Like

Yes ! Applause :confetti_ball: : to @ZzetT, this has been a looong journey !

1 Like

Hey @ZzetT :slight_smile:

i played a bit with this binding and found two problems… I dont know if its a bug or i dont understand it right…

1. If i use telegramAction.sendTelegramQuery the bot sends the message (with the buttons) to my chat… so the last message in that chat is from the bot… but none of the channels lastMessageName and lastMessageUsername gets updated to the bots name.

2. If a user in that chat clicks on a button shouldn’t there also lastMessageName and lastMessageUsername get updated?

I’ve tested with both /setprivacy ENABLE/DISABLE
thanks
/Holger

Hey @kugelsicha,

thanks for testing the new binding!
Did you use the last provided jar (and uninstalled the old one first) or did you compile everything yourself?

The idea of the last message or last name channel is not that you see the messages that you sent from OH. It is more a “last received message”.

I assume that you also set a username (is optional for Telegram). There is indeed a little problem in the code, but not exactly what you described. The problem that I see is that the username is not the one from the user who clicked the button but the name of the bot itself. So, instead of
lastMessageUsername = update.callbackQuery().message().from().username();
it should be
lastMessageUsername = update.callbackQuery().from().username();
But the last Message name should be correct.
Can you confirm that?