New Telegram Binding - Tester and Feedback welcome

I’m getting the same error message. Any reason or solution for that? The telgram bot so far is running. Means I see the “LastMessageText” from Telegram in my Thing.

Thanks

What OH version are you using? Could you please paste the code that you have added to the script?

Not to mention the maintenance of the jetty fork. These things rot fast.

Hi,
I’m using openHAB 2.4.0-1 (Release Build).

The code (chat-id edited):

rule "Nobody's at home"
when
	Time cron "0 51 06 ? * MON-FRI"
then
  val actions = getActions("telegram","telegram:telegramBot:[chat-id]")
  actions.sendTelegram("Smart@home", "Nobody's at home. Activate alarm?", "Reply_Alarm", "Yes", "No")
end

cheers, Nico

The code looks fine, but the required id here is not the chat id but the thing id. Please read this post how to find out the thing id. It’s usually a hexadecimal number.

ok? how to maintain that thing? I do not get any jetty related error (think so…)

you’re right. I’ve correted that but error remains the same :anguished:

2019-05-09 21:12:00.365 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Nobody's at home': 'sendTelegram' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'; line 15, column 3, length 102

Did you have the old telegram actions installed or a previous version of the new telegram binding?

Yes, the old action was still installed. I’ve uninstalled it, restarted, reinstalled the new action, restarted…but still same error.

ok, I did it once again. Seems that I have used the older org.openhab.binding.telegram-2.4.0-SNAPSHOT.jar. Now with the 5.2MB jar file I’m getting following error few times a second:

2019-05-09 22:13:54.357 [ERROR] [Telegram Bots Api                   ] - BOTSESSION

org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Error getting updates

	at org.telegram.telegrambots.meta.api.methods.updates.GetUpdates.deserializeResponse(GetUpdates.java:119) ~[289:org.openhab.binding.telegram:2.4.0.201903232311]

	at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.getUpdatesFromServer(DefaultBotSession.java:219) ~[289:org.openhab.binding.telegram:2.4.0.201903232311]

	at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.run(DefaultBotSession.java:160) [289:org.openhab.binding.telegram:2.4.0.201903232311]

Any idea what does it mean?

Did you get any errors when you enter
https://api.telegram.org/bot<YourBotToken>/getUpdates
into your browser? (this time really the bot token and not the thing id :wink: )

Don’t ask me why…I’ve repeated every single step. Suddenly I was not able to add the TelegramBot thing via PaperUI, only in Habmin…
But now it’s working :smiley:

Great, thanks a lot!

1 Like

@ZzetT @Belgadon
With the older version (from the Drive link), I have the same problem. Old action uninstalled. It seems that this time it only has problem with the action, but I couldn’t test it, because I can’t send a message…

The Drive link contains the newest version?.

Ok I have found that there is a newer version. I’m still having some errors…
Can someone show me, which versions should I install?

With the new version I get this error:

2019-05-23 13:12:06.321 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent STOPPING - org.openhab.binding.telegram

2019-05-23 13:12:06.358 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=129, service.bundleid=149, service.scope=bundle, component.name=org.openhab.binding.telegram.internal.TelegramHandlerFactory, component.id=41} - org.openhab.binding.telegram

2019-05-23 13:12:06.407 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=315, service.bundleid=149, service.scope=singleton} - org.openhab.binding.telegram

2019-05-23 13:12:06.463 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=313, service.bundleid=149, service.scope=singleton} - org.openhab.binding.telegram

2019-05-23 13:12:06.521 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent STOPPED - org.openhab.binding.telegram

2019-05-23 13:12:06.813 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent UNRESOLVED - org.openhab.binding.telegram

==> /var/log/openhab2/events.log <==

2019-05-23 13:12:06.082 [vent.ItemStateChangedEvent] - SensiboLastUpdate changed from 2019-05-23T13:12:05.871+0200 to 2019-05-23T13:12:06.065+0200

2019-05-23 13:12:06.387 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR) to UNINITIALIZED

2019-05-23 13:12:06.448 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-05-23 13:12:06.457 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR) to UNINITIALIZED

2019-05-23 13:12:06.478 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

==> /var/log/openhab2/openhab.log <==

2019-05-23 13:12:07.833 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent RESOLVED - org.openhab.binding.telegram

2019-05-23 13:12:07.869 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent [unknown:512] - org.openhab.binding.telegram

2019-05-23 13:12:07.956 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent STARTING - org.openhab.binding.telegram

2019-05-23 13:12:07.964 [DEBUG] [org.openhab.binding.telegram        ] - BundleEvent STARTED - org.openhab.binding.telegram

2019-05-23 13:12:07.983 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=620, service.bundleid=149, service.scope=bundle, component.name=org.openhab.binding.telegram.internal.TelegramHandlerFactory, component.id=424} - org.openhab.binding.telegram

2019-05-23 13:12:08.146 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=621, service.bundleid=149, service.scope=singleton} - org.openhab.binding.telegram

2019-05-23 13:12:08.237 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'chatIds': Can not set java.util.List field org.openhab.binding.telegram.internal.TelegramConfiguration.chatIds to java.math.BigDecimal

java.lang.IllegalArgumentException: Can not set java.util.List field org.openhab.binding.telegram.internal.TelegramConfiguration.chatIds to java.math.BigDecimal

	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:?]

	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:?]

	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:?]

	at java.lang.reflect.Field.set(Field.java:764) ~[?:?]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[38:org.apache.commons.lang:2.6.0]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[38:org.apache.commons.lang:2.6.0]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[38:org.apache.commons.lang:2.6.0]

	at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:102) [97:org.eclipse.smarthome.config.core:0.10.0.oh240]

	at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:85) [97:org.eclipse.smarthome.config.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:274) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:77) [149:org.openhab.binding.telegram:2.4.0.201903232311]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

2019-05-23 13:12:08.256 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.telegram.internal.TelegramHandler@da0cd1': null

java.lang.NullPointerException: null

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:94) ~[?:?]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

2019-05-23 13:12:08.273 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'telegram:telegramBot:bbf4922a': null

java.lang.NullPointerException: null

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:94) ~[?:?]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

2019-05-23 13:12:08.293 [DEBUG] [org.openhab.binding.telegram        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingActions}={service.id=622, service.bundleid=149, service.scope=singleton} - org.openhab.binding.telegram

2019-05-23 13:12:08.314 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'chatIds': Can not set java.util.List field org.openhab.binding.telegram.internal.TelegramConfiguration.chatIds to java.math.BigDecimal

java.lang.IllegalArgumentException: Can not set java.util.List field org.openhab.binding.telegram.internal.TelegramConfiguration.chatIds to java.math.BigDecimal

	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:?]

	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:?]

	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:?]

	at java.lang.reflect.Field.set(Field.java:764) ~[?:?]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[38:org.apache.commons.lang:2.6.0]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[38:org.apache.commons.lang:2.6.0]

	at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[38:org.apache.commons.lang:2.6.0]

	at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:102) [97:org.eclipse.smarthome.config.core:0.10.0.oh240]

	at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:85) [97:org.eclipse.smarthome.config.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:274) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:77) [149:org.openhab.binding.telegram:2.4.0.201903232311]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

2019-05-23 13:12:08.325 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.telegram.internal.TelegramHandler@9ed0bc': null

java.lang.NullPointerException: null

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:94) ~[?:?]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

2019-05-23 13:12:08.341 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'telegram:telegramBot:e86acc81': null

java.lang.NullPointerException: null

	at org.openhab.binding.telegram.internal.TelegramHandler.initialize(TelegramHandler.java:94) ~[?:?]

	at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

==> /var/log/openhab2/events.log <==

2019-05-23 13:12:08.210 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING

2019-05-23 13:12:08.258 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from INITIALIZING to ONLINE

2019-05-23 13:12:08.275 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from ONLINE to UNINITIALIZED (HANDLER_INITIALIZING_ERROR)

2019-05-23 13:12:08.312 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING

2019-05-23 13:12:08.325 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from INITIALIZING to ONLINE

2019-05-23 13:12:08.342 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from ONLINE to UNINITIALIZED (HANDLER_INITIALIZING_ERROR)

Ps.: Do I need the actions + binding right now? Which version supports sending messages also?

java.lang.IllegalArgumentException: Can not set java.util.List field org.openhab.binding.telegram.internal.TelegramConfiguration.chatIds to java.math.BigDecimal

Yes, this is a known “issue”. I guess you installed a previous version of that binding and this used a long value for the chat id. However, a long in Java can only contain 2^63-1 but according to the Telegram documentation if can be up to 2^64. Therefore, we changed the type to a String and this produces now an error, because the database contains the old long value.

I don’t know how such a migration scenarion should be handled, but in your case I suggest to search for the text “chatIds” in your openhab folder and change the value in the database from a long to a text (using an apostrophy).

Of course, this problem does not occour when somebody installs the latest version for the first time.

@ZzetT

Thanks! So the latest version is which is around 5MB?

Do I need to have the actions also installed?

Ps.: I have found it in the jsondb, added aposthropes around the chatId, but the same happens… However this issue is also still there when I want to add a new Thing. Can’t really set the chatId, because it says ‘Add or Search’ but only an empty list is shown in the drop-down menu, and also I don’t know how could I add a new chatId to this list.

No the binding is independent of the actions.

Yes this is a bit weird in the openhab ui, since it’s a list I think you have to just press enter or click again on the number shown in the box below to select it.

But can I also send messages with this version? I have seen somewhere that it has been integrated into the binding.

Ok, got over with the problems, now the bots are online! Thanks for your help!

However using your example, I can’t send Telegram message.
Error: Rule ‘Test switch’: Instance is not an TelegramActions class.

Rule:

rule "Test switch"
when
    Item Test_Switch received command ON
then
    val actions = getActions("telegram", "telegram:telegramBot:6952815a")
    actions.sendTelegram("bot2", "No one is at home, but some lights are still on. Do you want me to turn off the lights?", "Reply_Lights", "Yes", "No")
end

In sendTelegram action, what is the first parameter? Before it used to be name of the bot…

Yes you can also send messages with the binding only.

@ZzetT
So I can uninstall the actions! That’s great.

Can you have a look at my previous problem?

Also what if I just want to send a regular message, can I still use the sendTelegram action with only 2 parameter?

Ps.: I have found in the source code that I can use it with 2 parameters. But still get that error every time.

Error: Rule ‘Test switch’: Instance is not an TelegramActions class.

Yes, see also my post from 22 April.

Yes, the first parameter is still the bot name.

You can try to put the following line after getActions:

logWarn("myLog", actions)

to see what the object actually is.

From your pevious log:

2019-05-23 13:12:06.387 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR) to UNINITIALIZED

2019-05-23 13:12:06.448 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:e86acc81' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-05-23 13:12:06.457 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR) to UNINITIALIZED

2019-05-23 13:12:06.478 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:bbf4922a' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

it seems that you are running two bots at the same time (two different ids). And it seems that those ids are not the same as you used for getActions “telegram:telegramBot:6952815a”. Could you check that in the thing configuration?