Error when system started in getActions method of telegram binding

  • Platform information:
    • Hardware: Raspberry Pi 4 Model B Rev 1.1
    • OS: Raspbian GNU/Linux 10 (buster) 10.7
    • Java Runtime Environment:
      openjdk version “11.0.9.1” 2020-11-06 LTS
      OpenJDK Runtime Environment Zulu11.43+100-CA (build 11.0.9.1+1-LTS)
      OpenJDK Client VM Zulu11.43+100-CA (build 11.0.9.1+1-LTS, mixed mode)
    • openHAB version: 3.0
  • Issue of the topic:

I have updated to OpenHab3 and I found this errors into log console:

2020-12-27 11:57:27.356 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'bot-1' failed: 'sendTelegram' is not a member of 'null'; line 14, column 9, length 40 in bot

In my rules I use a global var because I use this bot in other rules:

var bot_casa

rule "System Start Bot Rules"
    when
        System started 
    then
        logInfo("my.rules", "System Start -> Bot Rules")

        bot_casa = getActions("telegram","telegram:telegramBot:casa")
        bot_casa.sendTelegram('System Started!')
end

Before update it works fine, but now i don’t know why.

It’s possible that the instance of bot thing occur after I call getActions()?

Some idea or workarrond to solve this?

If your guess is correct, a Timer to wait even longer to access the action might work. If not there is something else going on.

Hello I have the same Problem, and find out at start up my rule returns an error

    2020-12-29 12:10:50.080 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model   'sendtelegramm.rules'
    2020-12-29 12:10:51.344 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'sendtelegramm.rules', using it anyway:
    The field Tmp_sendtelegrammRules.telegramAction refers to the missing type Object
    The field Tmp_sendtelegrammRules.telegramAction refers to the missing type Object
    The field Tmp_sendtelegrammRules.telegramAction refers to the missing type Object

When i reload my rule all will be fine, so it looks like the action fuction is not running at this poit

  import java.util.Date

val String filename = "sendtelegramm.rules"
val telegramAction = getActions("telegram","telegram:telegramBot:mybot")

/* Eine Telegram MSG wird verschickt*/
rule "SendTelegrammMsg"

when 

    Item TelegrammSendMsg changed

then
   
   val String Empf = transform("JSONPATH", "$.Receiver", TelegrammSendMsg.state.toString)
   val String Msg  = String::format( "%1$td.%1$tm %1$tH:%1$tM", new Date() )+" Uhr - "+transform("JSONPATH", "$.MSG", TelegrammSendMsg.state.toString)

    // Nur Admin   
    if ( Empf == "1" ){

       logInfo(filename, "Telegram Nachricht: " + Msg )
       telegramAction.sendTelegram( 1xxxxxxxxL, Msg)
       TelegrammSendMsg.postUpdate( '{"Receiver":0,"MSG":" "}' )
       }

Hi, I’m also experiencing this sort of problem. During startup these errors occur:

2021-02-03 06:47:21.717 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'event.rules', using it anyway:
The field Tmp_eventRules.telegramAction refers to the missing type Object
The field Tmp_eventRules.telegramAction refers to the missing type Object

My Telegram actions aren’t working until I reload a rule.
error:

2021-02-03 11:53:31.528 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'event-15' failed: null in event

Is there a workaround possible?

I still can’t find a workaround, I opened a bug report:

simple workaround so far: use a crontab task to move files from rules directory to another directory and back… simple but effective…

I was also wondering why my rule throws the error with null. A modification of the file and so the forced reload of the rule fixed it. So it is a openhab3 related problem that the “old” rules in the rules directory are not working properly after a restart? Is it only related to the telegram binding or are there also problems with other bindings?

I’m using Astro, GPSTracker, Homematic, ipcamera, Jablotron, Mail, MQTT, OpenWeatherMap, OpenWebNet and Telegram binding. So far only the Telegram binding has this issue…

No. It’s a timing issue. At the moment you ask the binding for Actions, it’s not ready. Later, if you ask again, it will be.
Reloading rules files is one way to ask again.

Whether the problem shows up for you depends on your configuration and hostng, because that affects when various openHAB parts get started and become ready. And of course, when you do ask for your getActions()

Hi rossko57,

so is there another way to fix this issue then?

I am using Pushover instead of Telegram, but I have the exact same problem.
After I restart the openhab-service, no pushover notification is working. But as soon as I reload the rules-file, with the pushover-action, it works fine.
(with “as soon as” I mean about 3 days after the restart so not immediately).

If you don’t already, get the Action at rule runtime within the body of the rule, instead of as a ‘global’ at file load time.

Oh I see. I will try that.
I indeed have the getAction() write into a global variable at the beginning.
thx for your help :+1:

More simple: use a crontab and not move the files, a touch works for me.

EDIT: example to touch all rules 3 minutes after a reboot (seems that the rule engine have to start complete before):

@reboot sleep 180 && /usr/bin/touch /srv/openhab-conf/rules/*
1 Like

Not working for me on Debian Linux… my file location differs…
For me it’s:

@reboot sleep 180 && /usr/bin/touch /etc/openhab/rules/*

maybe helpful for anyone else…

Ahh btw, to edit the crontab file type crontab -e to the console

cheers,
Dan

1 Like