Hi, I’m trying to replace OH1 telegram.action by OH2.5 telegram.binding but it fails.
Using OH 2.5 Binding Actions dosn’t work as expected.
Using telegram for example in weather rules fail on using humidity in percent. The ‘%’ in a message will fail this. telegramAction.sendTelegram(<ChatID>, "test: % text") leads into this Error: 2020-01-18 14:20:52.481 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Weather Conditions': Conversion = e, Flags =
Trying to escape the ‘%’ by ‘’ get teh following Error: telegramAction.sendTelegram(<ChatID>, "test: \% text") -> 2020-01-18 14:32:59.563 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'weather.rules' has errors, therefore ignoring it: [33,52]: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
Sending a double % will result into the expected message: telegramAction.sendTelegram(<ChatID>, "test: %% text") -> “test: % text” in telegram.
Using sendTelegram without extra arguments after message must not perform a parameter parsing.
@Olymp Yes it works fine with SendTelegram but using it together with sending Photo by sendTelegramPhoto you must use only two signs.
So depending on send method you have to use different workarounds.
Note that the issue as written refers to the installation of a new version of the binding as the cause of the problem. However, I think that the problem might also occur whenever a binding is disposed/initialized (which can occur under other conditions than installing a new version of the binding).
Thanks for the quick reply. I didn’t change anything regarding the binding. It just stops working after some time. Is there a workarround for this problem? Or can I maybe enable a debug log to see what causes this problem?
I have been struggling with sending messages to a second user because I failed to get the chatID for him. The JSON response on the link in the binding docs https://api.telegram.org/bot/getUpdates was empty.
The simple alternative (and probably better recommendation for a beginner) is to start a chat with any of the bots such as @get_id_bot that respond with your chatID. I suggest to change the documentation.
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.