Telegram formatted message variables?

Hello everyone, I am trying to get the telegram to notify me of the status of the lights and how many have been turned off or on.
I followed the example of the tutorial page, but only the state works.

And another question, which means 23.46 in the example?

Example from wiki page:
sendTelegram(“bot1”, “item Foo changed to %s and number is %.1f”, Foo.state.toString, 23.56)

My rule:
sendTelegram(“bot1”, “The state of the lights has changed to %s and they have turned off %d lights”, Lights.state.toString)

My item:
Group:Switch:OR(ON, OFF) Lights “All Lights [(%d)]”

In the example are two variables used and two values defined, in you exampe is only one defined.

You have to provide two values when setting up two wildcards.
I guess you want something like

sendTelegram("bot1", "The state of the lights has changed to %s and they have turned off %d lights", Lights.state.toString, Lights.members.filter[ m|m.state==ON ].size)

Ok!! I have set it and I will see if tomorrow works when dawn, since it is when my rule is activated.
Where can you see the class and use arguments like this to learn how to implement them?

Lights.members.filter[ m|m.state==ON ].size)

Searching in the forum would be a common way to get this sort of information (especially take a look at Tutorials & Examples…)
Another option is to use VSCode with openHAB plugin, this would give you full autocompletion. Most commands are more or less self explanatory.
As the rules engine has its own DSL, I doubt there is a reference which will cover the whole syntax, but XText and XTend was used to build the DSL, so these would be other keywords for searching.

Perfect, I want to learn more about the openhab code, the example that you gave me works perfectly.
Great software, great community, thank you very much

Hello and thanks for the help. Could benefit from it already.

I hope it’s not a problem that I link to this old post…

How would the line look like if I don’t want to see the number in the message but which concrete item is ON?

Greetings

Well, in fact, there is not “the” item which is ON, but a list of items which are ON. So you would have to build a string for that. Like this:

val strOnline = new StringBuilder
Lights.members.filter[ m|m.state==ON ].forEach[ i|
    strOnline.append(" "+i.name) 
]
sendTelegram("bot1", "These lights are ON:" + strOnline.toString)

Thank you very much.

That worked. Just replaced the “.name” with “.label”.

Have a nice day! Stay healthy!