All,
Raspi 3B+ on OH 2.5M6 (openhabian)
I am running Telegram Actions successful in my regular rules like:
val action = getActions("telegram","telegram:telegramBot:MyBot")
action.sendTelegram("Weihnachts-Licht wurde angeschaltet")
However, I am using Telegram to send messages to OH and would like to check, from which Chat / Bot this is coming from:
rule "Receive telegram"
when
Item TelegrMess received update or
Item TelegrMessYou received update
then
// depending on the triggering item, the appropriate Telegram Bot action is set
var itemName = triggeringItem.name.toString
var itemState = triggeringItem.state.toString
// MyBot
if(itemName == "TelegrMess") {
logInfo("telegram.rules", "TelegrMess - itemName: " + itemName)
logInfo("telegram.rules", "TelegrMess - itemState: " + itemState)
var action = getActions("telegram","telegram:telegramBot:MyBot")
}
// YourBot
else if(itemName == "TelegrMessYou") {
logInfo("telegram.rules", "TelegrMessYou - itemName: " + itemName)
logInfo("telegram.rules", "TelegrMessYou - itemState: " + itemState)
var action = getActions("telegram","telegram:telegramBot:YourBot")
}
logInfo("telegram.rules", "Telegram received from " + itemName +" >" + itemState + "<")
// Licht aus
if(itemState == "Licht aus") {
G_Lights.sendCommand(OFF)
logInfo("telegram.rules", "Lights were switched OFF")
action.sendTelegram("Das Licht wurde ausgeschaltet!")
}
...
But I get the following error, even though it’s working (lights are switched off):
2019-12-12 19:50:45.023 [INFO ] [marthome.model.script.telegram.rules] - TelegrMess - itemState: Licht aus
2019-12-12 19:50:45.049 [INFO ] [marthome.model.script.telegram.rules] - Telegram received from TelegrMess >Licht aus<
2019-12-12 19:50:45.070 [INFO ] [marthome.model.script.telegram.rules] - Lights were switched OFF
2019-12-12 19:50:45.078 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Receive telegram': The name 'action' cannot be resolved to an item or type; line 33, column 3, length 6
Any idea why this error is popping up?
The if else should make sure that just one definition of action will be set, right?