OpenHAB3 - Question about rule actions of bindings (specifically Telegram)

Hi,
when migrating my OpenHAB2 system to a fresh and all new OpenHAB3 installation, I ran across an issue with my Telegram bot that is supposed to send messages in certain cases.

In OpenHAB2 I had textual rules containing a line like this
val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_HTML")
and later this
telegramAction.sendTelegram("some text %s", triggeringItem.name)
to send messages.

As I tried to implement a similar rule in OpenHAB3 I noticed that the rules assistant doesn’t provide access to the telegram action.

So just for my understanding. Is it correct that I now only have the option either to write a script function for this or I stay with the text bases DSL rules?

Thanks a lot in advance

Telegram worked fine for me in OH3 with DSL, now converted everything into ECMA though, the code for DSL would be:

val telegramAction = getActions(“telegram”,“telegram:telegramBot:BOT”)
telegramAction.sendTelegram(“MSG”)

For ECMA:

var telegramAction = actions.get("telegram","telegram:telegramBot:telegram");
telegramAction.sendTelegram("Message");

Hope it helps.

3 Likes

You can still use the old DSL also just create a script in the ui.

Example code

triggers:
  - id: "1"
    configuration:
      itemName: Kettle_BoiltheKettle
      command: OFF
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-2
           val telegramAction = getActions("telegram","telegram:telegramBot:Jimmy")
           telegramAction.sendTelegram("Kettle has Boiled")
    type: script.ScriptAction

Thanks folks, I’ll try.

In my point of view this is far too complicated for an non-technical user. So no wonder that this kind of software will take a few more years until end-user can adopt it.

I had the hope that the new rule editor would be much more capable.

There’s always a next release.

1 Like

If you want to do it with the rule editor create a new rule and trigger

Add trigger then add action

for action select execute a given script then add a new DSL script.

Add the two lines into script and SAVE.

If you want a wisiwig editor there are commercial products available now. To put in more options will confuse people and wall in the current features. All of the things I have posted are available in the docs. I think you can achieve greatness if you put in a little effort.

@denominator Thanks for pointing out. As said earlier I have already an OpenHAB 2 system with DSL scripts. Groups and triggering items are used a lot. It would have been nice to have at least these actions and triggering items available in these new, very much promoted, editors.

Your approach is for sure a solution, but adds a bit unecessary comlexity as I would have to maintain 2 scripts instead of one when sticking with rules DSL.

May be this will possible in the future and it would be very helpful for average user adoption, but currently it’s unfortunately (still?) not possible.

Thanks a lot for all you fast and very helpful replies.

1 Like