[SOLVED] Multiple lines in one telegram message?

Hello Everybody,

i’m looking for an solution to reduce 3 messages into 1 message

here is an example what it looks at the moment.

Thats is my code at the moment

then
    sendTelegram("bot1","Temperatur Wohnzimmer %s", Act_Temp_WoZi.state)
    sendTelegram("bot1","Iphone Ronny %s", Iphone_R.state)
    sendTelegram("bot1","Iphone Meli  %s", Iphone_M.state)
end

so is it possible to get 1 Message with one information at a line instead of 3 messages ?

Thanks and Regards

Hi,

you can use the StringBuilder class to create a message object before you call sendTelegram

    val StringBuilder TelegramMessage = new StringBuilder
    TelegramMessage.append("whatever you want to put here")
    TelegramMessage.append(Iphone_R.state)

    sendTelegram("bot1","Iphone Meli  %s", TelegramMessage.toString)

Put “\n” inside your string if you want a new line.

"This is the first line.\n\n" + "One blank line above.\nRonny Iphone:" + Iphone_M.state.toString

Edit. I took the liberty to enhance topics title a bit.

2 Likes

thanks to both of you, now it works so far, i’m just looking around if there a possibility to format the text, so that result of the state or temps are in one row one under the next.

image

You mean like this:

Wohnzimmer
20.30

?

no more Like this

Wohnzimmer Ist      xx.xx
Wohnzimmer Soll     xx.xx
Iphone 1            On
Iphone 2            Off

Does telegram support html in messages? That way you could structure a table with html tags.

Hey, i have to take a look for this, but i’m sure i read something about that

You can’t do tables with html tags:

So html is out but I saw markdown support listed in that api reference. Does anybody know if the telegram action supports it?

yesterday I found this post New Telegram Action I will give this a try today evening. there is an edited version of telegramm.

Okay so after give this snapshot a try, it works so far I have tried it with Bold and Italic.

so anyone have an idea how to try and get the text formatted ?

16

Here’s markdown cheatsheet to get you going.

Hi there,

I’ve tried this, but did not get telegram running with any Markdown or HTML configuration. As it looks like, the latest version of Telegram Actions (1.13.0) in the repository openhab-addons-2.4.0 does not contain any of the mentioned configurational things.

Any idea? (I really don’t want to use any snapshot, as it looks like, that the change already exists).

you need to use this snapshot for telegram, from this post, and rename the *.pdf to *.jar and but this in your add-on folder. New Telegram Action

that you have to adjust your telegram.cfg like this

telegram.bot2.parseMode=Markdown

Cheers Ronny