rule "Telegram wenn my mobile is connected to wifi"
when
Item Presence_mobile_tsch changed to OFF
then
sendTelegram("my-bot", "tsch mobile is now offline.")
end
Now I would like to send the lastseen date and time via Telegram too.
What would be the correct syntax to achieve this?
sendTelegram("my-bot", "tsch mobile is now offline. Presence last seen: " + String::format("%1$tm-%1$td-%1$tY %1$tI:%1$tM.%1$tS %1$tp", (new DateTimeType).zonedDateTime))
Thanks a lot Scott for your quick reply.
This works perfectly.
Can you help me with another problem I’m struggeling with namely sending the actual weather condition from my place using openweathermap?
The binding is allready up and running and I display the current weather in Basic UI and on my mobile.
What syntax must I use to send the current weather condition via telegram?
Would the following trigger be correct, to send a message only when the condition is “RAIN”?
when
Item localCurrentCondition changed to rain
then
sendTelegram…
I’m absolutely lost with the syntax for this kind of commands and the documentation seems to complicated for me as non programmer.
rule "Send Telegram when it rains"
when
Item localCurrentCondition changed
then
if (localCurrentCondition.state.toString.contains("rain")) {
sendTelegram("my-bot", "Current condition: " + localCurrentCondition.state.toString)
}
end
With your example I’n now able to check the state of an item and know what the syntax for sending states via telegram (the “+” was my “missing link”).
Can I send german states instead of english language too?
Where can I find additional information about the possible states for different items (to use them as trigger) and examples for rules to learn from?
You really helped me a lot moving forward with rules.
Yes. You set the language in the OpenWeatherMap Account Thing.
You’ll find this information in the documentation and forum. There are also some tutorials in YouTube. The rules DSL is very limited and confusing to use though. Scripted automation is where things are headed. It allows you to use real scripting languages and Jython is by far the most most advanced.