Time formating

whether it is possible to insert a single line item minutes and hours?

I don’t know of a way other than writing your own small bit of web code that you can interact with in a Webview widget. It would be nice to have a date/time picker UI widget.

Is there somewhere an example of using webview?
I do not understand the idea of using this item.

I google’d and found this. The point of Webview is to embed a web page into your sitemap for whatever purpose you have for it.

I did this widget,:

but the appearance is not the best
I have no idea how to improve it

You could possibly borrow some of the CSS/JS that the classic UI uses, but I imagine that would be pretty tedious to achieve.

The only other options I’m aware of are to look into alternative UIs, like this one:

or Android-based ones like this one:

I have another question about editing time from midnight :slight_smile:
I figured that he would use the “Select” to choose a particular time with the "mappings"
Is it possible to create such a file. “Ee.map” and use it as an option mappings?

In my (openhab2) items file, I have the following…

DateTime CurrDateTime “Today [%1$tA, %1$td.%1$tm.%1$tY %1$tT]” (Astro) { channel=“ntp:ntp:local:dateTime” }

The ntp ‘thing’ has been configured within Paper UI, with BST as its Timezone and ‘Europe/London’ for locale.

This displays the time in my custom sitemap as GMT, when I’d like it displayed as the current local time (BST - daylight saving).

In ‘Control’ of Paper UI it displays as the proper local BST time so I know it can be done, tho I can’t find a reference to see how it’s done.

Could anyone point me in the right direction, please?

@DSTM in the ntp binding I recently introduced another way, which gives much more flexibility over the formatting.
delete the current one, add it again (so it has the new string channel).
With the string channel you have full flexibility on how the time is formatted, including the timezone.

The ntp binding has two one channels:

dateTime which provides the data in a dateTime type
string which provides the data in a string type. The string channel can be configured with the formatting of the date & time. This also allows proper representation of timezones other than the java machine default one. See the java documentation for the detailed information on the formatting

thanks marcel, tho I deleted the ntp thing and added it again, and there’s no string channel…?

I’ve looked, and it’s as clear as mud. If I need to spend three weeks to try and understand how to format the right time, the problem is not me. It shouldn’t be necessary to know how to raise chickens to cook a chicken dinner,

(can you tell I have a strong dislike to the standard answer of RTFM for the most simple of questions? :P)

Hi Neil,
Yes, I forgot to add indeed also to update the ntp binding. I think you can do so by removing it and adding it again. (I do frequent update of all of the bindings, have never tried to do an individual one)

The hyperlink on ‘java documentation’ got lost in my copy paste… so here you go. I think that part is quite understandable. http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Ir’s a VERY simple question. If you don’t know the answer, there’s no need to post a reply. Or just say you don’t know.

There’s a lot of people around here posting “I don’t know, but I think you should know” answers to questions. It’s actually the opposite of what those people think it is. :wink:

PS: if you don’t know how the bindings are updated, why say to update the binding?

what I said was:
I do frequent update of all of the bindings, have never tried to do an individual one.
You don’t have the latest version of the binding, hence you did not see the new functionality. Did it occur to you that each of us have different use cases, different versions (off-line/online) hence stumble upon different issues. As said, I frequent update all of the bindings, hence in my case having outdated/old versions of bindings never happens.

I don’t know your exact setup, hence I can only give a hint as to how you update in your case a binding, search the forum and there are existing topics that go in more depth on how to update to the latest version of a binding.

I leave it to ‘update the binding and use the string channel’ as I specifically created that string channel to tackle the timezone issue you described.

OK, I have the updated binding, but I’m no wiser for how to actually get the correct local time outputted to my sitemap.

How do I get the right time, please?.

So now with the updated binding I can get:-

  1. the (not local) time marked as GMT
  2. the right time from the wrong timezone, which will not always be the right time.

But what I don’t seem to be able to get is the right local time.

And yet Paper UI gives the right time.

PS: and the right time from a string isn’t any use for using cron within rules, where I wish to set it up to work with the correct local time.

A system that schedules tasks/events based on the time that can’t actually tell the right time is pretty useless.

How can my system give me the right time, please???


The timzone is coming from dateTime channel comes from the JDK/JRE settings, maybe overriding that will fix your problem for the (cron) rules.

There are indeed some more fundamental issues with the time (which was the reason to actually develop the string channel output). e.g. Some more background in this and linked issues:

Why can’t it use whatever is used by Paper UI to display the right time from the ntp binding? Surely, it can’t be that hard to do as it’s already done within one part (Paper UI) of OpenHAB2?

I have to write the most stupid of rules to account for this issue, and then amend the rules every six months each time daylight saving time starts or ends - because everything else is using the correct local time except what provides the time to the OpenHAB system.

I’m stunned that such a basic part of an automation system doesn’t work correctly.

in code block

Number Minutes "minutes [%d]"
DateTime RunTime "run time [%1$tm/%1$td %1$tH:%1$tM]"

why do we need to write %1$t before m or H?

I guess this is just the syntax to tell the program that you want to get a time value string.
Maybe this helps a little: