Printing item-values in a Telegram rule

Hello,
I have a question about the Rule-Based System in OpenHab in combination with the Telegram Action Addon.

I want to send a Telegram message with the current temperature of my solar system.

I’m basic in Programming and tried this following rule:

rule “Solar Systen”
when
Item KG_Solar_Kollektortemperatur changed
then
sendTelegram(“bot1”, "The temperature changed to: " +KG_Solar_Kollektortemperatur)
end

Where is my problem to “print” the Value in the telegram message?
Thanks for your help!

You’ll need to use the state of the Item…

sendTelegram("bot1", "The temperature changed to: " + KG_Solar_Kollektortemperatur.state.toString)

It helps a lot if you use code fences (#12).

Hi,
i tried this:

rule “Solar Systen”
when
Item KG_Solar_Kollektortemperatur changed
then
sendTelegram(“bot1”, "The temperature changed to: " + KG_Solar_Kollektortemperatur.state.toString)
end

But it doesn’t work. Are there different ways?

There are different ways for it not work, yes. You may have to help us out a bit.

Does your rules file load? Look in your openhab.log for a message about that.

Does your Item actually change state? Look in your events.log for a message about that.

Does your rule throw an error? Look in your openhab.log for that.

Have you installed the telegram action? It’s an add-on, and it needs configuring

If you add some logging, it will help troubleshoot whether the rule is triggering. Add this as the first line of the body of the rule (the ‘then’ part)…

logInfo("Solar System", "Rule triggered: KG_Solar_Kollektortemperatur.state: {}", KG_Solar_Kollektortemperatur.state)