OH2 and Telegram Action - sendTelegram is not defined in

Hello,

i have a question how to install and use the telegram action under oh2. I have read some tutorials, but i have an issue that i did not found yet.

  • i have created a bot, communication between my android device has no problems
  • the getUpdate Method on the API of Telegram works
  • telegram action is installed with the PaperUI
  • telegram token, botname and chatID is configured in telegram.cfg unter directory services
  • rule is created with PaperUI, the only command is sendTelegram(“myBot”, “Test”)

telegram.cfg

telegram:bots=myBot
telegram:myBot.chatId=307xxxxxx
telegram:myBot.token=2252747xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

tried also without “telegram:”, no difference

Now the error message(s):

22:12:34.323 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: IDLE
22:12:34.347 [INFO ] [smarthome.event.RuleUpdatedEvent ] - Rule ‘rule_1’ has been updated.
22:12:41.744 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: RUNNING
22:12:42.162 [WARN ] [cript.internal.ScriptModuleActivator] - Found wrong classloader: To prevent class loading problems use this directive: -Dorg.osgi.framework.bundle.parent=ext
22:12:42.264 [ERROR] [cript.internal.ScriptModuleActivator] - Exception while importing scope: java.lang.ClassNotFoundException: org.eclipse.smarthome.core.library.types.OpenClosedType cannot be found by com.eclipsesource.jaxrs.publisher_5.3.1.201602281253
22:12:42.270 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendTelegram” is not defined in at line number 1
22:12:42.271 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: IDLE
22:13:06.827 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: RUNNING
22:13:06.828 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendTelegram” is not defined in at line number 1
22:13:06.828 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: IDLE
22:13:48.245 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: RUNNING
22:13:48.247 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendTelegram” is not defined in at line number 1
22:13:48.250 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_1 updated: IDLE

Can someone help me?

At first sight your Telegram configuration looks good, you should also post your ‘rule_1’ so people can have a look and try to help.

I have created the rule with the paperUI, how can i get the generated Text from the DB? I have no rules-file so far.
But however, the rule is only a test rule to make the telegram action fly. if i press “play” in the paperUI, the log looks like before.
the only script command in die rule is sendTelegram(“myBot”, “Test”). For me it looks like the rule extension doesn’t know that the telegram action is installed. Must i do something in the addons.cfg?

In your telegram.cfg file you should put your config without telegram:.

Good point on the addons.cfg file, you should add telegram to the action part:

action = telegram

Restart openHAB to see if this works.

ok, now the sendTelegram works, but … action = telegram in addons.cfg and without telegram in telegram.cfg was not successfull.
Here are my experience for the next beginners like me :wink:

  1. I have deleted the rule, that i created with the paperui (with smarthome:removeRule )
  2. Then i create a telegram.rules file in the rules folder
  3. I put a comment (little description) and a simple rule definition with sendTelegram command

Result: The Error “sendTelegram” is not defined was no longer in the log, but i got
Configuration model ‘telegram.rules’ is either empty or cannot be parsed correctly!

The file was not empty, so i searched for parsing error … the end of the story … the first line of the rules file must be a statement, no comment and no space line. oh2 won’t read the file and logs it as warning, if the is some comment at the beginning … that is a bug for me :unamused:

Next thing: the rule works now, but i can’t see the rule in paperui or when i am using the command smarthome:automation listRules … next Bug?

I think, that smarthome:automation listRules just rules displays, which are created by PaperUI. Im not quite sure, if it is a bug, or should act like this.