New Telegram Binding - Tester and Feedback welcome

Ok, I have restarted openHAB, the Things still online (no errors, seems to work as it should), but the same error happens…
What the first parameter in getActions should be?

I’m using OH 2.4 stable, maybe this can help…

Hi Alex,
I just remove the old telegram action and install the new action and binding in addon folder
I have OH-2.5.M1 , action.telegram is , binding is

I set the 4 items as described and they works (last messagge, date, name and username)

I am testing the rules

val actions = getActions("telegram","telegram:telegramBot:474f5df2")
	actions.sendTelegram("xxxxbot", "No one is at home, but some lights are still on. Do you want me to turn off the lights?", "Reply_Lights", "Yes", "No")

but I get the same error

Error during the execution of rule 'Nobody's at home': 'sendTelegram' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'

Can you help me?

my working reply to a question uses

   actions.sendTelegramAnswer("mybotname", telegramReplyId.state.toString, "Ok, *off*..") 

my working question uses

   actions.sendTelegram("mybotname", "Do you want Operate IPpower ?", "Reply_IP", "Yes", "No", "Maybe")

The version looks outdated. It should be

Please download the version mentioned in my post from 2nd April

So, what is the general idea here? There is no PR for this until know. We would like to replace all OH1 actions as soon as possible and this is one of the missing ones. Do you have any timeframe to get this merged? If it is not a simple action but more, code review will probably take some time.

Hey @J-N-K,

thanks for asking. From my point of view, the binding is almost ready. At least the readme needs some more information. In the last days/weeks I struggled a lot with the update/migration to the new bnd build system. I ran into the same issues as other users have stated in

And I agree that it is quite frustating that for 3rd party and non OSGi libraries it seems to be quite difficult to get it running or there seems to be non documented workarounds.

If I create a simple Eclipse Maven project that makes use of the TelegramBot library (without OH), the only thing I need to do is to add


to the pom.xml.

For my OH binding I also added:

    <feature name="openhab-binding-telegram" description="Telegram Binding" version="${project.version}">
        <feature prerequisite="true">wrap</feature>
        <bundle dependency="true">wrap:mvn:org.telegram/telegrambots/4.2$Bundle-Name=Telegram%20Bot%20Library&amp;Bundle-SymbolicName=org.telegram.telegrambots&amp;Bundle-Version=4.2</bundle>
       <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.telegram/${project.version}</bundle>

to the features.xml.

But then I get the following error after mvn clean install:

[WARNING] Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-telegram; type=karaf.feature; version=2.5.0.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-telegram)(type=karaf.feature)(version>=2.5.0.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-telegram/2.5.0.SNAPSHOT: missing requirement [openhab-binding-telegram/2.5.0.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.telegram; type=osgi.bundle; version="[,]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.telegram/ missing requirement [org.openhab.binding.telegram/] osgi.wiring.package; filter:="(osgi.wiring.package=org.telegram.telegrambots.meta)"]]

As far as I understand from the different forum threads, the last osgi.wiring.package means that a dependency is missing. So, I also added this to the pom.xml:


and this to the feature.xml:

<bundle dependency="true">wrap:mvn:org.telegram/telegrambots-meta/4.2$Bundle-Name=Telegram%20Bot%20Meta%20Library&amp;Bundle-SymbolicName=org.telegram.telegrambots-meta&amp;Bundle-Version=4.2</bundle>

Then the maven build is successful. However, I would like to know why because as mentioned above, it is not required in a simple non OH Maven project.

Anyway, when I try to run the app.bndrun and add the binding to the “Run Requirements” I end up with some more osgi errors like:

Resolution failed. Capabilities satisfying the following requirements could not be found:
⇒ osgi.identity: (osgi.identity=org.openhab.binding.telegram)
⇒ [org.openhab.binding.telegram version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.telegram.telegrambots))
[org.apache.aries.jpa.container version=2.7.0]
⇒ osgi.service: (objectClass=javax.persistence.spi.PersistenceProvider)
[org.openhab.binding.harmonyhub version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=com.digitaldan.harmony)(&(version>=1.1.0)(!(version>=2.0.0))))
[net.minidev.accessors-smart version=1.2.0]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.objectweb.asm)(&(version>=5.0.0)(!(version>=6.0.0))))
[org.openhab.binding.smartmeter version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=io.reactivex)(&(version>=2.2.0)(!(version>=3.0.0))))
[org.openhab.core.test version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit))
[org.openhab.transform.jinja version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=com.hubspot.jinjava))
[org.openhab.transform.bin2json version=]
⇒ osgi.wiring.package: (&(osgi.wiring.package=com.igormaznitsa.jbbp))

In some threads I also read that I have to add a dependency to that binding in pom.xml of the demo app. Is that still valid? I also read that I should add it to “Run Bundles”, but in it is not mentioined anymore. Is this still required? I don’t know how often I setup my build environment already because I saw some changes in the addons, distro or demo github project.

Sorry if I didn’t post these issues earlier, but I thought I can solve it myself. For me the new build environment seems to be more complex than the old one. Although, I have to say that with other bindings which don’t make use of of any dependencies like the astro binding I don’t have any problems to compile/run them.

You can find the current migration here:
But I don’t want to create a PR with something that is not working with the new build environment.

Please create the PR. I can have a look then and submit a PR to your branch to fix it. It is much more difficult the other way round.

Solved… thanks

Transitive dependencies are not resolved by Karaf feature files.

What happens is this:
When you install an addon, you basically instruct Karaf to install a “feature”. A feature must describe all dependencies and where to get those dependencies. Karaf will download those dependencies during the installation step. OSGi will notice if you forgot something, but Karaf has no clue how to resolve a missing dependency (no download location known).

And that’s because the entire demo app (“app.bndrun”) does not use Karaf. All the knowledge that you have put into the feature file is not accessible to the demo app. Usually bnd is smart enough to deduct all including transitive dependencies by looking at your pom.xml file (during the “resolve” step). But sometimes it needs a bit of help.

“mybotname” is what name? Where do you specify the name of your bot?

I have this version, the newest but the same error…

Where should I define this name?
I have tried the same binding on my test server, with no other bindings installed, latest snapshot, the same problem happens for me…

Ok, I have got it working somehow, however I still don’t know why I should state at sendTelegram in the first parameter the old actions Telegram bot name.

However I don’t know why but again ‘Instance is not a TelegramActions class’ error is appearing on the same rule where it before worked. So I might think this is an error. Also when I want to just a send a normal Telegram message, without answers, the same error happens.

Printing out the current actions value:

Starting test rule...

2019-05-29 23:48:57.174 [WARN ] [se.smarthome.model.script.Test.rules] -

2019-05-29 23:48:57.194 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test switch': Instance is not an TelegramActions class.

So I think this is clearly a bug in the binding.

Very unlikely.

Than I can’t think of what I’m missing. I have tried it on different setups, with the same result. And it worked for some minutes, without changing anything…

I’ll create a PR this week. Although it feels a bit weird because I can’t get it running with the latest OH environment and thus can also not really test it.

I agree, I already removed this locally because the bot name can be unambiguously identified via the thing id and it’s configuration.

That’s really strange. On the one hand, it seems that you get a real object of type TelegramActions but on the other hand the instanceof check fails.

The check for that is quite simple:

    public static boolean sendTelegram(@Nullable ThingActions actions, @Nullable String format,
            @Nullable Object... args) {
        if (actions instanceof TelegramActions) {
            return ((TelegramActions) actions).sendTelegram(format, args);
        } else {
            throw new IllegalArgumentException("Instance is not an TelegramActions class.");

I also don’t see why such a check should work once and then it doesn’t anymore.
I’m using the JAR in my productive environment which is based on OH2.4 stable.

1 Like

Yes I also saw this in the source code. Next thing what I will try I think is to remove this instance check and recompile the jar and see what happens then…

So what should be the bot name when sending a message (first parameter)? :slight_smile:

Ps.: Further investigation: I have 2 bots, maybe this can be a problem? If I change getActions from one bot to another, the object stays the same…


It’s just the name that you added to the thing configuration and that you used for the name of your bot similar to the bot-name/group name used for the old actions.

If you remove one, is it working then?

Do you really need two bots or are two different chats handled by one bot sufficient?

Thank you very much! Now I’m starting to get the idea how this binding works!

I will try it now. I just need two, because usually one is used for important messages, like alarm, and the other one is just for testing things and some not that important messages (like a summary at the end of the day, etc…)

It seems that I got it running! I don’t know what was wrong. I have removed one bot, nothing changed. Restarted openHAB, now it works normally, even when I added back my other bot. Thanks!

One last question. Can I add more than 2 replies to the question?

Great to hear that!

Yes, it’s a variable number of arguments.