How to display text from an item?

  • Platform information:

    • Hardware: _Raspberry Pi
    • OS: Raspbian + openHab
    • openHAB version: openHab 2
  • Issue of the topic:
    I have installed the “telegram” binding and use it to send alerts. That works fine! Now I want to display the text and the date/hour of the last telegram sent on the webpage default.sitemap. And that’s the problem.

in my items-file I have:

// Strings
String		LastTelegram		"[%s]"
String		LastTelegramTime
String		PlaceFiller
// -----------------------------------------------------------------------end of Strings

in my rules I have:

// Battery control
rule "control motion sensor Hall battery level"
when
	Time cron "0 0 11 ? 1/1 SAT#1 *"
then
	var myText = "Hall motion sensor battery level is: "+MotionHallBattery.state
	val telegramAction = getActions("telegram","telegram:telegramBot:db7f3715")
   	telegramAction.sendTelegram(myText)
	logInfo("Rules", "...Battery Telegram sent.")
end	

in my default.sitemap I have:

sitemap default label="at Home...."
{
	Frame label="Date, Time ..." {
		Text item=DateNow			label="Today: "
		Text item=Season			label="Season: "
		Text item=SunriseStartTime 	label="Sunrise: "
		Text item=SunsetStartTime 	label="Sunset: "
	}

	Frame label="Telegram..." {
		Text item=LastTelegram		label="last text sent: "
		Text item=LastTelegramTime	label="at: "
	}

Now I would like to display myText from the rules in the LastTelegram from the sitemap and the date/time of the telegram in LastTelegramTime. It doe not work… any Help is welcome!

Just add the value to the item

// Battery control
rule "control motion sensor Hall battery level"
when
	Time cron "0 0 11 ? 1/1 SAT#1 *"
then
	var myText = "Hall motion sensor battery level is: "+MotionHallBattery.state
        LastTelegram.postUpdate(myText)
	val telegramAction = getActions("telegram","telegram:telegramBot:db7f3715")
   	telegramAction.sendTelegram(myText)
	logInfo("Rules", "...Battery Telegram sent.")
end	
1 Like

I tried a lot of commands, but not this one! Works fine :+1:. Thank’s.