Iβve been using Telegram binding succesfully for some months already. I can send commands from my smartphone and receive notifications from Openhab 2.5.8 by using a Telegram bot, which I configured in PaperUI.
However, since last update my messages to the bot are processed only for a while. Then, apparently after 15-30 minutes of restarting openhab service my messages are queued undefinitely and not processed any longer. I can see in my smartphone that my messages are delivered (double tick), but OH2 is simply not handling them. In fact, the corresponding lastMessageText channel of my Telegram bot is not updated (checked both in PaperUI and from Visual Studio Code). Of course my rules depending on that channel update are not triggered.
I read that after an OH2 update it is advisable to clean the cache, which I did by running:
openhab-cli clean-cache
and possibly restart OH2 a couple of times. Iβve tried that several times but to no avail.
I have found two ways of overcoming the problem.
Restarting openhab service: the message queue works normally (but again only for 15-30 minutes) and my pending messages are lostβ¦
Disabling and re-enabling Telegram thing in openhab: all pending messages are processed immediately and rules are triggered correctly for 15-30 minutes.
Two Chat Ids have been defined in the βChat Idsβ field.
My rule (ChatIdJavi has been abreviated):
val telegramActions = getActions("telegram","telegram:telegramBot:Tbot")
val Long ChatIdJavi = 14877...L
rule "Receive telegram DTenue"
when
Item telegram_telegramBot_Tbot_lastMessageText received update "DTenue"
then
knx_device_cc714aee_Despacho1.sendCommand(15)
telegramActions.sendTelegram(ChatIdJavi, "DTenue")
logInfo("telegram", "Escena DTenue - Javi")
end
openhab.log has no errors or warnings.
events.log is not being particularly useful either. All I can see when disabling (12:22:02) and re-enabling the bot thing is that my pending messages are all processed immediately (only DTenue message triggers a rule):
2020-09-18 12:22:02.201 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from ONLINE to UNINITIALIZED
2020-09-18 12:22:02.250 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2020-09-18 12:22:02.995 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNINITIALIZED (DISABLED) to INITIALIZING
2020-09-18 12:22:03.106 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from INITIALIZING to UNKNOWN
2020-09-18 12:22:03.483 [hingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNKNOWN to ONLINE
2020-09-18 12:22:03.550 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:03:49.000+0000 to 2020-09-18T10:14:45.000+0000
2020-09-18 12:22:03.562 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:14:45.000+0000 to 2020-09-18T10:16:34.000+0000
2020-09-18 12:22:03.565 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageText changed from A to B
2020-09-18 12:22:03.566 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:16:34.000+0000 to 2020-09-18T10:17:06.000+0000
2020-09-18 12:22:03.568 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageText changed from B to A
2020-09-18 12:22:03.569 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:17:06.000+0000 to 2020-09-18T10:17:10.000+0000
2020-09-18 12:22:03.570 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageText changed from A to H
2020-09-18 12:22:03.572 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:17:10.000+0000 to 2020-09-18T10:17:30.000+0000
2020-09-18 12:22:03.574 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageText changed from H to DTenue
2020-09-18 12:22:03.575 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:17:30.000+0000 to 2020-09-18T10:18:29.000+0000
2020-09-18 12:22:03.577 [vent.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T10:18:29.000+0000 to 2020-09-18T10:21:06.000+0000
2020-09-18 12:22:05.361 [ome.event.ItemCommandEvent] - Item 'knx_device_cc714aee_Despacho1' received command 15
2020-09-18 12:22:05.376 [ome.event.ItemCommandEvent] - Item 'knx_device_cc714aee_Despacho1' received command 15
2020-09-18 12:22:05.388 [nt.ItemStatePredictedEvent] - knx_device_cc714aee_Despacho1 predicted to become 15
2020-09-18 12:22:05.395 [nt.ItemStatePredictedEvent] - knx_device_cc714aee_Despacho1 predicted to become 15
2020-09-18 12:22:05.403 [vent.ItemStateChangedEvent] - knx_device_cc714aee_Despacho1 changed from 0 to 15
However, I cannot find any error or warning entry corresponding to the moment when the queue is stopped.
Thanks, Wolfgang, for answering so quickly! If you need any more informations, Iβd be glad to provide them.
With this info it is mostly guessing.
Get proper debug output first to find out if anything arrives on telegram and if the rule is triggered.
To find out, set proper Karaf log levels:
Thanks for pointing out log levels in Karaf. I have changed them as suggested but no much further information was thrown out, so I changed the log levels to TRACE:
This is the result of log:tail when sending DTenue from my smartphone shortly after OH2 restart (26 minutes after restart to be exact):
17:04:07.425 [INFO ] [smarthome.event.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T14:59:07.000+0000 to 2020-09-18T15:04:07.000+0000
17:04:07.429 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'knx_device_cc714aee_Despacho1' received command 15
17:04:07.446 [INFO ] [arthome.event.ItemStatePredictedEvent] - knx_device_cc714aee_Despacho1 predicted to become 15
17:04:07.458 [INFO ] [smarthome.event.ItemStateChangedEvent] - knx_device_cc714aee_Despacho1 changed from 0 to 15
17:04:07.511 [INFO ] [lipse.smarthome.model.script.telegram] - Escena DTenue - Javi
The scene is correctly set up.
However, 2 minutes later I send DTenue again, but his time the scene is not set up and no messages whatsoever are logged, not even in the 9 minutes period I waited for.
If I then disable and re-enable TBot thing from PaperUI, following messages are logged:
17:15:04.967 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from ONLINE to UNINITIALIZED
17:15:04.988 [DEBUG] [ing.telegram.internal.TelegramHandler] - Trying to dispose Telegram client
17:15:04.991 [DEBUG] [ing.telegram.internal.TelegramHandler] - Telegram client closed
17:15:05.008 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
17:15:05.523 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNINITIALIZED (DISABLED) to INITIALIZING
17:15:05.551 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from INITIALIZING to UNKNOWN
17:15:05.978 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'telegram:telegramBot:Tbot' changed from UNKNOWN to ONLINE
17:15:05.992 [INFO ] [smarthome.event.ItemStateChangedEvent] - telegram_telegramBot_Tbot_lastMessageDate changed from 2020-09-18T15:04:07.000+0000 to 2020-09-18T15:06:57.000+0000
17:15:05.995 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'knx_device_cc714aee_Despacho1' received command 15
17:15:06.018 [INFO ] [arthome.event.ItemStatePredictedEvent] - knx_device_cc714aee_Despacho1 predicted to become 15
17:15:06.027 [INFO ] [smarthome.event.ItemStateChangedEvent] - knx_device_cc714aee_Despacho1 changed from 0 to 15
17:15:06.340 [INFO ] [lipse.smarthome.model.script.telegram] - Escena DTenue - Javi
As you can see, in the log entry from 17:15:05.992 the lastMessageDate is set to 17:06:57, i.e. the time when I sent the second DTenue which was ignored by OH2. The scene is now correctly set up.
Additional info: OH2 2.5.8 is running on a Raspberry Pi 4 under Debian 10.4.
I can confirm that disabling and re-enabling the bot helps. Same situation here, it worked like a charm, out of a sudden no updates anymore in openHAB. After disabling/enabling I see in the logs that the telegram items have been updated.
In my case it seems more random, I need to do some other tests. For the makority of the time the message arrives to the item very quick, sometime it tooks 1 or 2 hours, sometime it never comes to the item. When it does not arrive at all, if I stop and start the thing everything start to work normally again.