New Telegram Binding - Tester and Feedback welcome

Hello, just want to throw in that I tried it a bit and it worked well.
(pressing the Enter-button after the Chat-IDs is tricky!).

image

Big thanks!!

2 Likes

As metioned above thatā€™s not the case beside the ā€œoldā€ telegram action which is deactivated.

Furthermore I dont get any messages from Telegram to OH.
I have configured the last message as an item and also see this item linked to the thing on PaperUI.
But no message comes through :frowning:

Thanks! One note in the documentation is an example:

rule "Send telegram with image without caption from image accessible by url"
when
    Item Light_GF_Living_Table changed
then
    val telegramAction = getActions("telegram","telegram:telegramBot:2b155b22")
    telegramAction.sendTelegramPhoto("http://www.openhab.org/assets/images/openhab-logo-top.png",
        null)
end

This example is for http://
and here the second parameter can be passed null
And can this be done to send files from the local network?

telegramAction.sendTelegramPhoto("file:///etc/openhab2/html/cam.jpg",null)

image
Thanks!

After I have removed the telegram binding from M5 and used the jar above from the post of @gitMiguel I can receive messages from Telegram.

I still get the messages:
2019-11-25 12:57:50.537 [WARN ] [ng.telegram.internal.TelegramHandler] - Telegram exception: GetUpdates failed with error_code 409 Conflict: terminated by other getUpdates request; make sure that only one bot instance is running

:grimacing:

I just found out that this item does work (please note the spaces at the brackets and =):
String TelegrMess "Telegram Message" (G_jdbc) { channel = "telegram:telegramBot:MYBOT:lastMessageText" }

but this does not (without the spaces):
String TelegrMess "Telegram Message" (G_jdbc) {channel="telegram:telegramBot:MYBOT:lastMessageText"}

Is this how it supposed to be?
On my other items I deleted all the spaces (I like it better), but this did never change the result.

You canā€™t use the channels to send messages. They are read-only. Sending is only possible via the actions.

These wrap files are the files from that Telegram library that we use for the binding.

You are asking about the local network, but the first example shows a http adress which is also reachable for the public and the second example is a path to a local file (not network). But yes, in the next release (or current master) you can use the same API to send files from an IP of your home network.

How many things did you configure for the Telegram Bot? Could it be that the JAR and the M5 installed binding is running in parallel? Do you see two bundles in bundles:list? Or do you use a second OH instance which e.g. runs one of the old prototypes which were posted here? The error message comes from the Telegram Server, so it detect that two clients are connected to the same token. Maybe there is still another thing in this json file?

I donā€™t think this is related to the Telegram Binding, but rather to the general syntax for items in OH.

I think you did not understand me, I apologize for my English.

rule "Send telegram with image without caption from image accessible by url"

without caption
When I pass the second parameter null - the result in the photo in the previous post.

Thanks, Alex,

last thing first:

This is unlikely, because the other items work that way.
However, I just found out, that itā€™s still not reliable, so I assume my massive errors in the log (using obviously 2 times the same token) are the root cause. So thatā€™s my major target.

When I check karaf, I just have one Telegram instance:
(I always make sure that I either run the official telegram binding from PaperUI (addons.cfg) OR the one in the addons folder.

openhab> bundle:list | grep elegr
314 x Active x  80 x 2.5.0.201911250709      x openHAB Add-ons :: Bundles :: Telegram Binding
openhab>

But now the wrap file is not there anymore - does this matter?

In the beginning I configured one, but deleted it right afterwards and created it with a new name.
I dont see any other conflicting Thing: Neither in PaperUI, nor in karaf.

The only thing I can imagine is, that with my previous Telegram action installation there is still a Zombie around. But:

  1. I deleted the Telegram action from the addons.cfg (and itā€™s not running according to PaperUI)
  2. I removed the telegram.cfg with the token / bot config from the service folder.

Another issue I have is that logging does not seem to work.

In Karaf I used:
log:set TRACE org.openhab.binding.telegram
But nothing is logged with DEBUG or TRACE level.

The result in org.ops4j.pax.logging.cfg looks like this:

log4j2.logger.org_openhab_binding_telegram.level = TRACE
log4j2.logger.org_openhab_binding_telegram.name = org.openhab.binding.telegram

But I donā€™t see anything in openhab.log beside INFO / WARN

EDIT:
I re-activated the Telegram action (after deactivation of the telegram binding) and configured it with another fake token, so that this is ā€œfreeā€ again.
After a restart the error of the conflict is still there.

I have no clue what to do next.


everything works.
It didnā€™t work for me until I deleted the telegam in the binding line from the file: /var/lib/opennab/config/org/openhab/addons.config
Check this.

hmmm, thanks - Thatā€™s what I do:
Either place the addon jar in /usr/share/openhab2/addons folder and remove telegram from the file you mentioned above.
Or the other way around.

/var/lib/opennab/config/org/openhab/addons.config

There should be no mention of telegram.

/usr/share/openhab2/addons

There should be a binding file.

Updated openHAB to openHAB 2.5.0 Build # 1764
telegram binding without errors were installed from PapaUI.

Exactly!

All,

I di not find where the conflict came from.
So I needed to create a new Bot with a new token to be successful.

Just in case someone experienced the same issue with the error 409

Hi!
How to place buttons not on one line, but on two or more? On the small screen, the button labels are cropped.

telegramAction.sendTelegramQuery("Selection", "Reply_Sel", "Button-1", "Button-2","Button-3","Button-4","Button-5")

Thanks!

Hi,

Iā€™m trying to setup message timeout and I have error.

First Iā€™m sending message:

telegramAction.sendTelegramQuery("Test question", "TEST", "Yes", "No", "30 min")

Message arrived on telegram and in log I have:

14:56:21.557 [DEBUG] [.binding.telegram.bot.TelegramActions] - Adding chatId 111111111, replyId TEST and messageId 1111

Then Iā€™m trying to send answer without click answer in telegram to suppress buttons.

telegramAction.sendTelegramAnswer("TEST", "Action timeout.")

14:56:47.939 [DEBUG] [.binding.telegram.bot.TelegramActions] - AnswerCallbackQuery for chatId 111111111 and replyId TEST is the callbackId 3650850320737827138
14:56:47.999 [WARN ] [.binding.telegram.bot.TelegramActions] - Failed to send telegram message: Bad Request: query is too old and response timeout expired or query ID is invalid

Is it correct behavior? It will be nice if I can suppress buttons without any action on telegram side.

Thanks

Yes, this is the behavior of the Telegram API and the last message you posted is actually from the Telegram Server and not from the binding.
If you call sendTelegramAnswer it will send an answerCallbackQuery which requires a callback_query_id. This id you only get if the user clicked a button and thus sends a CallbackQuery

Good idea. Maybe we can pass a two dimensional array of Strings here.

Need to change the binding code?

Yes, but only if you want to use multiple lines of buttons. I have something like that in mind (untested):

var List<String> firstLine = newArrayList("button1", "button2")
var List<String> secondLine = newArrayList("buttonA", "buttonB", "buttonC")
var List<List<String>> allButtons = newArrayList(firstLine, secondLine)
telegramAction.sendTelegramQuery("Selection", "Reply_Sel", allButtons)

Or we have to encode the position as a number as part of the button string. Is that what you meant with the ā€œ-1ā€, ā€œ-2ā€ postfix?