Posibility to if/else display without a rule?

I have two items and want to show when a room is/was last occupied or was last occupied on a dashboard

  • “occupied”
  • “last occupied 10 mins ago”

Is there any way to do this without a rule and introducing a new String Item?

Contact     KNXMotionContactBathroomGuest               "[MAP(motion.map):%s]"                (gPersistMe, gMotionSensors, gBathroomGuestSensors)    ["Presence"]    {channel="knx:device:motion:BathroomGuest"}

DateTime    KNXMotionContactBathroomGuest_LastUpdate    "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]"    (gPersistMe, gMotionSensors, gBathroomGuestSensors)    ["Presence"]    {channel="knx:device:motion:BathroomGuest" [profile="timestamp-update"]}

I was imagining it might be possible with a map file but can’t see a nice way.

Hi Simon,

Does the last update from KNX give the last time there was a contact or just the last time the information was published by KNX?

Next question is more personal for me; why would you like to reduce the number of items and rules , e.g. not solve this with a rule?

You have a good point with your first question profile="timestamp-update"] would also be updated when the room becomes vacant.

And to your second question, just trying to learn more about OH3 and keep finding that there are more elegant ways of solving problems and wanted to check before bashing out yet-another-rule. :slight_smile:

That is a moving target and implies repeated re-evaluation (else it says 10 mins forever).
So it’s more complicated than first appears.
Doing calculations at the UI is one approach - so you’d need to identify what UI you want this to happen in.

The only option I would see, when not using rules is to play with the visabillity= option in the sitemaps file. Take a look at the Worx binding by Nibi79 and how he used 4 different lines to get an elegant solution

Switch item=LandroidAction label="Action" mappings=[START="Start"] visibility=[LandroidStatusCode==0, LandroidStatusCode==1]

And to your second question, just trying to learn more about OH3 and keep finding that there are more elegant ways of solving problems and wanted to check before bashing out yet-another-rule.

Hear hear!

I can’t speak to HABPanel but it’s pretty flexible so I bet you can calculate with date times in a widget for this.

In Sitemaps you are pretty much limited to the approach outlined by Richard, using visibility.

In MainUI Pages you have access to expressions and a date time library that you should be able to use to populate the text of a widget (see rossko57’s links). However, as rossko57 points out, the “X mins ago” will only be calculated when the page is first loaded. You’ll have to reload the page to force a recalculation of X.