try to create a rule for Telegram binding on OH 2.5 to reply on ping in same chat, therfore I need to convert chatId to long, which seems I’m not able to.
item definition
String telegramChatId "Telegram ChatId" (gTST) {channel = "telegram:telegramBot:20c8999f:chatId"}
rule
rule "Telegram ping"
when
Item telegramMessage received update
then
if (telegramMessage.state == "ping") {
val telegramAction = getActions("telegram","telegram:telegramBot:20c8999f")
telegramAction.sendTelegram((telegramChatId.state as Number).longValue(), "pong")
// Could not cast 106878302 to java.lang.Number;
//telegramAction.sendTelegram((telegramChatId.state as DecimalType).longValue(), "pong")
// Could not cast 106878302 to org.eclipse.smarthome.core.library.types.DecimalType;
//telegramAction.sendTelegram(106878302L, "pong")
// works!
}
end
it doesn’t matter if I do as Number or as DecimalType, it just can’t cast it to that type.
what I’m doing wrong here?