Unable to receive Telegram Notification with Rule created with UI (OH3)

  • Platform information:
    • Hardware: MacBook Pro 15 Inch Mid 2010 8GB Ram
    • OS: High Sierra 10.13.6
    • Java Runtime Environment: 11
    • openHAB version: 3.0

Hello there, I have been trying to set up a rule to send me a message through TelegramBot whenever a Samsung TV is turned on.

I have used the UI to generate the rule

and the code generated is this

triggers:
  - id: "1"
    configuration:
      thingUID: samsungtv:tv:137420b8_f069_1fee_ccb5_0a29ff374650
      status: ONLINE
    type: core.ThingStatusUpdateTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: TelegramBot
      command: telegramAction.sendTelegram("TV Studio Accesa")
    type: core.ItemCommandAction

OpenHab does correcty ā€œreadā€ the status of the TV (I have been turning it on and off via its own remote while looking at the ā€œthingsā€ page), however the trigger chosen (Status) seems not to activate the rule.

I am a little confused by the literature. Where am I supposed to insert the

val telegramAction = getActions("telegram","telegram:telegramBot:<uid>")

to call up the rule actions as specified in the Telegram - Bindings documentation?

The BOT has been correctly activated and tested with success following the above documentation.

Please help!

My Telegram bot setup and ONLINE

You will need to change Jimmy to your bot

actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-2
           val telegramAction = getActions("telegram","telegram:telegramBot:Jimmy")
           telegramAction.sendTelegram("TV Studio Accesa")
    type: script.ScriptAction
1 Like

Dear James,

thanks for the help! The rule works flawlessly now!

1 Like

Hi,

on my side itā€™s not working I become message:

2021-01-03 18:04:15.639 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ā€˜Rule-System-Start-Komplettā€™ failed: null

What I making wrong? Some tips?

triggers:
  - id: "1"
    configuration:
      startlevel: 100
    type: core.SystemStartlevelTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: VAR_Heizperiode
      command: OFF
    type: core.ItemCommandAction
  - inputs: {}
    id: "3"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: val telegramAction =
        getActions("telegram","telegram:telegramBot:number")
        telegramAction.sendTelegram("OpenHAB neu gestartet!")
    type: script.ScriptAction

Telegram Bot as thing is online.

best regards,
Lars

Hi,
I make a mistake in the number of the bot. Correct it and it works.
Solution from denominator works fine.

best regards
Lars

Excellent!

Sorry Iā€™m confuse, is there a way to send a telegram message from the gui? Or i have to creat a script?
Sorry I just realize that your executing a script.
One more question. Can I use this bind with phyton or jacascript srcipt?

You need to have items for the binding to write to