DateTime format with OH3 items not working

Ok what I should have said was the original Item and my effort to get it to display properly did now work (see lower item in the screen pic) whereas the new item/widget had the Timestamp as its label and the raw unformatted data as its display value.
Gawd do I have to start fiddling with YAML code now… :scream: :confounded:
It simply doesn’t work like the Basic UI… the process to do something simple has become a herculean task of fiddling and fudging… I feel like taking out my old Vera box and dusting it off… :roll_eyes:

Of course it doesn’t it’s a wholly new UI with wholly different capabilities. But nothing is preventing you from continuing to use BasicUI as you always have.

You at least need to show it to me if I have any hope of knowing what you’ve done and therefore have any hope to help.

Hi Andrew, relieved to hear other folk are struggling with this too… there must be some bug/flaw in the structures of the new OH that are causing this retrograde step in achieving simple things. I’m exasperated tbh.

Hi, I appreciate you’re trying to help but I’m too exasperated and frustrated by it all now that I’ll try tomorrow with a clearer head.
I know nothing is preventing me from using the Basic UI but we’re all trying to adopt and learn and embrace the new OH so I don’t think one should be advised to go back to the old ways just because the new system isn’t delivering on basics. Yes the new UI has many capabilities and we’re all grappling with them but surely to gawd something like this should be straightforward to achieve. Thanks again anyway.

2 Likes

So wait… What? So a widget is the only place a state description will show???
While I have the two of you attention (Rich or Rossko), can either of you please post exactly what I’m suppose to type into the state description please.
here is old OH2 item

DateTime MyCivilDawn "Civil dawn start [%1$tl:%1$tM %1$tp]" <none> (gHome)

Do I use square brackets? single quotes? double quotes? or just

%1$tl:%1$tM %1$tp

Screenshot from 2021-12-15 20-05-33


I’m the last person to give any advice, especially with the forum heavyweights lurking, but I did stumble on a DateTime format that works for me.

%1$tm-%1$td %1$tH:%1$tM

It produces this on a UI page.
datetime format
The same on a widget;
datetime format2
And lastly the widget yaml.
datetime widget yaml

I like the idea of the month and date spelled out like some of y’all have had, but the above is literally all I know and it is mostly readable, so it is all I use.

Bob

No, thanks for jumping in Bob, I think this might be a buggy, I’ve been trying for way to long to get this. Here is your format in my item


here is resulting item

What I’m I doing wrong???

Hi Andrew, you’re doing exactly the same process as me, the pattern looks fine and neither of us can get this (stupid) thing to work. :rage:
The new UI may have a load of new capabilities but it’s falling flat on its face here trying to deliver something that should be (and was) straightforward to do… it would seem to me that there’s some design/coding flaw somewhere that has resulted in this silly situation. One shouldn’t have to start drilling into YAML code, gawd it’s either a UI or it isn’t!

Hi Bob, I tried your Pattern expression also but just as Andrew found out, it didn’t work for me either. It seems to me nobody knows if/when/how this thing works… :roll_eyes:

I have no idea why this would work for one person, but not another.

Sorry

It’s a brand new UI with way more features and way more capability than any UI for OH that has ever existed. To expect it to be as simple as sitemaps is unreasonable. That’s why BasicUI is still around and will likely remain around. Heck, thats why MainUI even has the ability to create sitemaps.

MainUI is not intended to be a replacement for BasicUI that everyone must migrate to. It’s there if you want to use it. If it’s too hard or complicated to use right now, don’t use it. There is nothing wrong with using BasicUI.

Yes, it should be. In my experience it actually is. So I need from you lot and lots more detail to figure out where it’s going wrong. Have you uncovered a bug? Is there a misunderstanding that can be addressed in the docs? Is there something special about DateTimes? :man_shrugging: I don’t have the information I need to tell at this point. I don’t even know enough to. try to reproduce what you are seeing on my system.

So yes, it’s more complicated. You must fiddle with some YAML so I can see what you have done. Or you must use BasicUI because I can’t help you.

In MainUI yes, that’s my experience. The State Description is unfortunately use in a lot of different ways so it has influence in a number of other areas. But in MainUI, the State Description is only used in a widget.

Just as you posted it. No square brackets, no quotes.

However, the screenshot of your widget code is cut off exactly where I need to see it. Please post the full YAML in code fences and not screen shots which are hard to work with.

You can find the full syntax Formatter (Java SE 11 & JDK 11 )

To get the month spelled out replace the %1$tm with %1$tB for the full month name or %1$tb for the abbreviated month. Your locale’s names for the months are used.

With the information I’ve gathered so far, what you’ve done is not different from what Andrew and Denis have done which is why I need more information. What they’ve described should have worked. It really is that simple and we need more information to understand why it’s not working.

Show your Default Standalone Widget. If you don’t have one, what happens if you create one like what Bob posted?

Look. It should work. It should be that simple. I need that YAML to see what’s going on. Day-to-day you don’t need to ever look at or mess with YAML.

It’s no different than requesting logs and the rules code from someone who is trying to make a rule work. If you don’t want to post some YAML and gather additional information for me so I can help, then please, give up. I can’t help you. No one can. Continue to use BasicUI.

Again, the YAML is for me. I’m the expert on this thread (which is unfortunate since I’m far from an expert on this stuff). I need this information. Nowhere have I ever said that you will have to deal with YAML to make this work. Help me help you!

Rich- Great reference ! thanks. I can now do more than one date-time format :smiley:

FWIW- I get the display state on the UI page for the item, but as you noted, not on the summary item page.

Also don’t know if this will help troubleshooting, but I just started adding DateTime metadata to channels about three months ago on 3.1 stable. I’m currently on 3.2M5, but also used 3.2M4 along the way.

Thanks

Bob

Comment: a lot of confusion stems from MainUI being dual-purpose. Both Admin and User functions. In OH2 terms, PaperUI and BasicUI rolled together.

In Admin areas, we would want to see raw states.

In user’facing areas, we would want to see prettified states.

By design, you could see either depending where you look in MainUI.

Hi Rich,
As shown in the screen shot below from a card display that I sent you last night, I didn’t go creating any new standalone widgets on a separate Pages setup. All I did was fiddle about randomly creating another item and adding a Metadata widget to it and messing with linking and unlinking… is this what you meant by adding Oh-stanalone widgets etc last night? Somehow mysteriously it worked (see screen shot) but I took it apart and haven’t been able to reproduce the temporary success since :grimacing: so there would’t be any YAML code available to me would there? Well I don’t see any option to view the code when I’m dealing with a Metadata pre-made widget. I only see the option to view YAML code when I experiment with Widgets in Pages layout rather than the normal UI location/equipment/properties cards. If one can do this, I don’t know how, sorry. So I’m not trying to be uncooperative and I can see you’re genuinely trying to help but we all seem to be stuck in a web of frustration…
Pattern stuff DOES normally work for the cards but there seems to an issue here where the Profile of Timestamp on the channel is stubbornly overriding & ignoring what the user really wants to see from having inserted a Pattern to present the raw data in the desired way. This is the nub of the problem.
Have you tried to reproduce what I did? My screenshots are clear enough. Do you have a simple door contact & use the magnet or some wires to close/open it and add a timestamp channel? I think if you actually try it you’ll better understand what we’re experiencing and what should appear be in those codes areas. Thanks again for you patience, I’m sure we’re driving you mad too … :upside_down_face:

Bizarre

Rich, some progress/insight on the issue but not solved.
I added a Metadata ‘Default List item widget’ of flavour ‘Default-oh-label-item’, there was no progress until I UNLINKED the entire ‘Raining_since’ item from the channel and suddenly the properly formatted time appeared!
However, it stays frozen like that despite further changes because it’s unlinked.

So the Pattern managed to do its function on the item display as soon as the item was unlinked. It’s useless like this of course, but it might shed some light on why the properly formatted time is ‘hidden’/‘overridden’ by the channel profile until the moment the link is gone. It somehow caches and converts the last instantaneous value.
Screen shots below.
Notice:
Pic 1, channel is now unlinked from item. Correct format evident on top of item header viewed from Model perspective.
Pics 2 &3, correctly formatted time appears on both the metadata widget AND the UI Card.

Progress-1

Progress-3

The channel linking process has a feature (in my view poorly designed) where the binding can ‘suggest’ - in practice, silently force - a suitable pattern into metadata.
That should happen only once, at linking time.
You should be able to hand-edit a more suitable pattern after that one-time action.

Clearly that can lead to an issue where a switch type channel is linked to a DateTime Item, and a ‘switch’ suitable pattern is forced on the DateTime.
Open issue -

Unrelated to that -
The timestamp profile itself had a weird bug where it kept forcing Item update if something else changed it - such as you might get when linking two timestamps to same Item.
That one at least has been fixed recently -

but I wonder if an unnoticed effect of that was also re-forcing target Item pattern.

EDIT - ah I was just reminded of a nasty consequence of the ‘link forcing a pattern’ strategy. A binding may also suggest ‘state option’ metadata. e.g. a motion sensor switch sets [ON = motion, OFF=idle]. That is really going to screw up when used with a DateTime. You might check your misbehaving Item(s) for that metadata, too.

And that metadata widget has a code tab. Clicking on the code tab shows some YAML. I need that. Especially if it’s not working. Looking at one that is working for you and one that is not would also be informative if you still have one that works.

If you have the metadata still on the Item, then yes, the YAML will still be there. If you deleted that metadata then yes, there will not be any.

  1. Navigate to the Item
  2. Click on “Add Metadata”
  3. Click on “Default Stand Alone Widget” or “Default List Item Widget”
  4. You now see a form where you can customize the widget that get’s shown in that context (stand alone on Pages and at the top of the Item’s page, list item is how it appears in the cards on the location page, for example). There will also be a “Code” tab in the upper right. Clicking on that will show the YAML for widget. A nice and concise version of what you did through the form on the “Design” tab.

Screen shots are not all that useful but the YAML is very informative.

If you don’t have a custom widget assigned to the Item, then that is likely one of the differences between the one that worked and the one that is not working.

This is an interesting statement. I know that Bindings can provide their own formatting for how Items are displayed, maybe the Profiles can too.

That could be a source of difference and perhaps even point to a bug in the Timestamp Profile. Though it works as expected for me.

Yes but there really isn’t enough detail or precision in the detail provided for me to do it. Everything I’ve tried works for me. That’s why I need all the details. This is the first mention of a Profile. Those sorts of details matter.

Not when you are responding from a phone and have presbyopia. Also, I often can’t copy and paste from a screen shot. That’s why I need the YAML.

Yes. I’ve a door contact. I linked a DateTime Item to it using the Timestamp on change Profile. I modified the State Description pattern to %1$tm-%1$td %1$tH:%1$tM and I see

No Default Widgets or anything like that.

As I’ve said, the straight forward approach works just fine for me. So I need to find out what’s different between your config and mine

This doesn’t make a whole lot of sense to me. It is true that some binding developers can specify their own state pattern for Items. And I think it may even override your State Description pattern (for which I’ve complained). But that would apply here. The Profile is completely transforming anything coming from the binding so all that should be lost.

Oh yes, now I see it. If the binding is forcing something like %s then you’re just gonna get the default date time formatting no matter what you do.

@denisdmenace, to get that, probably the easiest and most comprehensive thing to do would be to navigate to /var/lib/openhab/jsondb (assuming this is installed on Linux) and open the file with “Metadata” in the name. Post all the entries that are associated with the non-working Item. An entry will look something like:

  "stateDescription:FrontDoor_Lastchange": {
    "class": "org.openhab.core.items.Metadata",
    "value": {
      "key": {
        "segments": [
          "stateDescription",
          "FrontDoor_Lastchange"
        ],
        "uid": "stateDescription:FrontDoor_Lastchange"
      },
      "value": " ",
      "configuration": {
        "pattern": "%1$tm-%1$td %1$tH:%1$tM"
      }
    }
  },

I’ll want to see all the entries for that one Item. That will show us what you’ve applied as well as anything the binding may have applied.

Thanks for all your effort on this.
Ok I attach YAML code for the bits you want. You mentioned about working/not working. It has never ‘really’ worked except when the item is unlinked and thus that is only a frozen moment in time.
Also, I attach the jasondb stuff. In fact I’m on a Mac which is Unix, not Linux, and the file was nowhere like you mentioned…found them in the userdata/jasondb/ folder (directory in unix speak) and the one of interest was org.openhab.core.items.Metadata.json

The YAML code areas are almost empty. The widget one has effectively nothing.

Metadata State descr YAML

JSON State description & List widget Code: LINKED mode

Raining_since item code

Raining_since widget code

Do you need the actual code stuff as a copy paste inside code fences or are the screen shots ok for you?

That’s with it “working”, right? What does it look like after re-linking, using timestamp profile?