New Telegram Action

1 Like

can we use mapping for mapping Contact & Switch items in the telegram messages ?

here

var String wetter = transform(“MAP”,“weather_de.map”,wuToday.state.toString)

Hi,
Any way to send emoticons?
It seems that to send just the related utf-8 unicode does not work
i.e for smile face : sendTelegram(“bot1”,"\xF0\x9F\x98\x81") doesn’t work

Any suggestion?

The suggestions here might help:

Please let us know if any work!

Dont’know how to implement in Openhab rule …can you help me?

Not tested, but does this work?

var int[] codepoints = {0xF09F, 0x9891}
var String s = new String(codepoints, 0, codepoints.length)

I past and copy above var and put the following action:

sendTelegram(“bot1”, s)

but soesn’t work

Any help?

I successfully used two escaped 16bit chars (UTF-16).
Here is a nice database to look them up (use the “Java Escape” string).

sendTelegram("bot1","\ud83d\ude04")
2 Likes

Thanks it works !!

From externally one can send so the picture by Telegram

sendTelegramPhoto(“Openhabbot”,“http://www.selfhost.eu/msubmenu=jpg”,null, “admin”, “pass”)

How is the code when I have the image in the tmp directory of Raspi /tmp/1.jpg?
or
var String IP_Cam_Garage_URL = ‘file:///tmp/1.jpg’?
Designer no accept
sendTelegramPhoto(“Openhabbot”,(IP_Cam_Garage_URL)) :frowning:

Assuming IP_Cam_Garage_URL is a String item, try

sendTelegramPhoto("Openhabbot", IP_Cam_Garage_URL.state.toString) 

no works :frowning:

Telegram API allows to send bold and italics with and , but actual OpenHAB Action does not seem to support it. I see there have been no activity on this thread for a long time now, so I guess the development is dead, but just wanted to point it out as a feature request in case it will be any future action update

Hello Carlos!

I’m like you are waiting for the support of formatted text in OpenHAB Telegram Action (my pull request doesn’t accepted - https://github.com/openhab/openhab1-addons/pull/5490), so I manually compiled Telegram Action with Markdown formatting support (you can read about Markdown here https://core.telegram.org/bots/api#formatting-options). So you need to delete installed Telegram action from Paper UI, then download my file, rename it from pdf to jar, then put it to /usr/share/openhab2/addons. Enjoy :slight_smile:

UPDATE: I’m deleted my custom jar file, because it’s generate a error, if your telegram message have an alone _ or * symbol.

Be patient. You only submitted it 15 hours ago. This is a community driven project, running on volunteers.

I know about that, I’m patient my friend, just want to help.

So, here another version of my custom Telegram Action build.

If you want to enable text formatting just install my jar file and add to telegram.cfg new string for each bot:

bot_name.parseMode=Markdown

Option key is simple: Markdown for Markdown mode or HTML for HTML mode. If formatting don’t needed - leave option blank or delete it (don’t forget that OpenHAB stores option in own database and you need to clean it).

org.openhab.action.telegram-1.12.0-SNAPSHOT.pdf (11.9 KB)

If you enabled Markdown mode and your telegram messages have a Markdown formatting mode symbols, like _ or * - server returns error “Bad request”, because its think, that you forget to close Markdown tag. Its a normal api behavior.

That’s great morchee, thank you very much for your contribution!!!

Regarding the _ or * “Bad request”… wouldn’t be possible just to remove them if you detect they are “odd” (unbalanced) before sending the message to the API?

And now taking advantage that is Chrismas again :wink: I imagine it is not possible as Actions are “one-way-only” and can’t trigger a rule, but… would it be possible to receive text from the bot in any way and leave it in a variable or an item? just imagine how nice would be to be able to send commands to the house by texting. For instance, imagine receive a Telegram message whenever you are leaving home saying “You left the heating on, would you like to set it to Eco temperature? [y/n]” and be able to answer “Y” and fire a rule consequently

You should start a new thread for this and delete this post.
Please also attach a debug log to the new post.