In Sitemap, String in front of a Switch?

Hello openHAB friends,

I am Using a Raspberry Pi 3+ with openhabian. One is String where the up time is saved and the other one is a switch where the up time got resetted.
.itmes:

String   Wetterstation_Online               "up time [%s clock]"                    <time>
String   Wetterstation_Reset                "up time Reset"

.sitemap:

Text item=Wetterstation_Online 
Switch item=Wetterstation_Reset mappings=[Reset="Reset"]

Is it possible to get the up time in front of the Reset-Button? Like this:
uptime_reset

Greetings

One Item per sitemap line.

But - you can put Wetterstation_Online into your sitemap as a Switch, with the button mapping.

That just looks like what you want, but doesn’t act like you want. When you click reset, a string command "Reset" is sent to Wetterstation_Online.
Set autoupdate false for Wetterstation_Online so that the command does not overwrite your datetime.
Make a rule that listens for commands to Wetterstation_Online, and have it do what you want.
You’ll need to make sure that whatever usually populates Wetterstation_Online does so by updates and not commands.

Hey,
I got it, but when I write behind my Item {autoupdate="false"} it isn’t updating in the sitemap.

Reset_Uhr

.items:

String   Wetterstation_Online               "Online seit [%s Uhr]"           <time>

.rules:

rule "Wetterstation_online"

when
    Item Wetterstation_Online received command "Reset"
then
    Wetterstation_Online.sendCommand(Zeit.state.format("%1$td.%1$tm.%1$tY, %1$tH:%1$tM"))
    //Wetterstation_Online.postUpdate(now.toString("dd.MM.yyyy, HH:mm"))
end

.sitemap:

Switch item=Wetterstation_Online mappings=[Reset="Reset"]

I got a second “problem” with the current time. I get my time over the ntp-binding with a 30s refresh. It is possible to get the current update timestamp out of the the system time? I know there is a command new DateTimeType() or now.getHourOfDay, ..., but I dont know how to transform (dd:mm:yyyy, HH:MM) this in the current time.

Greeting

You’ll need to make sure that whatever usually populates Wetterstation_Online does so by updates and not commands.

If you can’t do that, you cannot do it all this way and you will need to make a third Item.

I do not know what you mean. Are you trying to put a clock on your sitemap?

Thanks, this works!

At the moment I write my date+time out of the ntp-bindings, which updating every 30s. When it is now 12:30 and 10s is writing the last ntp update into the item (As example 12:29 50s) because it is updating (as example at 20s and 50s per minute).
I search a function where I can write the current system date and time into my strings (not only for this)

My current sitemap clock got his data from the ntp-binding too, so it got refreshed after 30s. The problem of this is, when the system startup is at 1s of a minute, the next update is at 31s. There is a time different of 31s to the correct time.

myDateTimeTypeItem.postUpdate(new DateTimeType())

?

var String someVariable = now.toString(" dd/MM HH:mm")

?

1 Like

this is it! Thanks!