Rule '...': null with Telegram Binding (2.5.10)

I’m getting the Message Rule … null wihtin a rule of the telegram binding. Either I’m blind or something is very strange because in my opionen, nothing is null.

Rules:

rule "TG Nachricht erhalten"
when
	Item telegramMessageText received update 
then
	if (telegramReplyId.state != NULL) {
		return;
	}
	val telegramAction = getActions("telegram","telegram:telegramBot:TelegramBot")
	val chatId = Long::parseLong(telegramChatId.state.toString)
	val text = telegramMessageText.state.toString

	if (text=="/start") {
		telegramAction.sendTelegramQuery(chatId, "Was möchtest du wissen", "startReply", "Fenster", "Anwesenheiten")
	} else {
		telegramAction.sendTelegram(chatId, "Echo: "+text)
	}
end

rule "TG Reply erhalten"
when
	Item telegramReplyId received update 
then
	logInfo("tg", "Start")
	if (telegramReplyId.state == NULL) {
	logInfo("tg", "Early Exist")
		return;
	}
	logInfo("tg", "Kein Early Exist")
	val telegramAction = getActions("telegram","telegram:telegramBot:TelegramBot")
	if (telegramAction === null) {
		logInfo("tg", "Action Null")
		return;
	}
	logInfo("tg", "Nach Action")
	logInfo("tg", telegramAction.toString)
	telegramAction.sendTelegramAnswer("startReply", "Antwort");
	logInfo("tg", "Ende")
end

I’m sending to the telegram bot “/start” and answer the reply. Then, the following log output happens:

2020-11-15 17:37:00.506 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Start
2020-11-15 17:37:00.517 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Early Exist
2020-11-15 17:37:01.679 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Start
2020-11-15 17:37:01.680 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Kein Early Exist
2020-11-15 17:37:01.680 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Nach Action
2020-11-15 17:37:01.680 [INFO ] [rg.eclipse.smarthome.model.script.tg] - org.openhab.binding.telegram.bot.TelegramActions@2c5d25ab
2020-11-15 17:37:01.964 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'TG Reply erhalten': null

As you can see, the last log messge (“Ende”) is never printed. But the line before get’s executed, as I recieve the answer. If I enable DEBUG for the telegram Binding, the log output changes to

2020-11-15 17:39:34.595 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Start
2020-11-15 17:39:34.596 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Early Exist
2020-11-15 17:39:34.711 [DEBUG] [binding.telegram.bot.TelegramActions] - Adding chatId MMMM, replyId startReply and messageId XXX
2020-11-15 17:39:35.761 [DEBUG] [ng.telegram.internal.TelegramHandler] - Received callbackId XXX for chatId MMMand replyId startReply
2020-11-15 17:39:35.767 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Start
2020-11-15 17:39:35.767 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Kein Early Exist
2020-11-15 17:39:35.767 [INFO ] [rg.eclipse.smarthome.model.script.tg] - Nach Action
2020-11-15 17:39:35.767 [INFO ] [rg.eclipse.smarthome.model.script.tg] - org.openhab.binding.telegram.bot.TelegramActions@2c5d25ab
2020-11-15 17:39:35.767 [DEBUG] [binding.telegram.bot.TelegramActions] - AnswerCallbackQuery for chatId MMM and replyId startReply is the callbackId XXX
2020-11-15 17:39:35.809 [DEBUG] [binding.telegram.bot.TelegramActions] - remove messageId NNN for chatId MMM and replyId startReply
2020-11-15 17:39:36.028 [DEBUG] [binding.telegram.bot.TelegramActions] - remove messageId null for chatId MMM and replyId startReply
2020-11-15 17:39:36.028 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'TG Reply erhalten': null

Any Idea what I can do?

Well the typical rubber duck debugging :slight_smile:

2020-11-15 17:39:36.028 [DEBUG] [binding.telegram.bot.TelegramActions] - remove messageId null for chatId MMM and replyId startReply

Here the message ID is null. I have to chatIds and I’m sending the Question to only one. But the answer is send by the action to both chatIds. (The two lines have two different chatIds). And in the telegram binding code, afterwards messageId.intValue() is called => NullPointerException