openhab / org.openhab.ui.habpanel

OUTDATED repo - HABPanel has moved to the openhab-webui repo!
https://github.com/openhab/openhab-webui
Eclipse Public License 1.0
97 stars 93 forks source link

Parsing DateTime data to dummy widget #4

Closed ghost closed 7 years ago

ghost commented 7 years ago

Problem parsing Date & Time data to the dummy widget.

Please refer to the following forum post:

https://community.openhab.org/t/habpanel-bundle-proof-of-concept-aka-panel-ui/12981/35

ghys commented 7 years ago

Done with a caveat: you cannot use the server-provided pattern for DateTime items, and the format is different - see https://docs.angularjs.org/api/ng/filter/date for a reference.

ghost commented 7 years ago

I am still having difficulty getting the time format to change. Is the problem anything to do with the fact that I have a JAR file in my addons and the latest code in my conf\html directory?

Ideally, I would like to just use the 'shortTime' format and have tried multiple options without success.

Could you possibly give me an example of exactly what I should type into the format field in the dummy widget.

Thanks in advance. Mike

ghys commented 7 years ago

Below is a comparison, the first widget is the raw value and the second one is what I get when I put 'HH:mm' as a format: image 'shortTime' is also a valid option but since there's no good way of configuring AngularJS locales in a generic way, it'll use a US English format (12h)

Did you update the latest sources and run from your static install in server:8080/static/habpanel and not server:8080/panelui/?

ghost commented 7 years ago

Yes, definitely running from the latest source, I just downloaded the master again and copied over the old code. Also definitely running from the static install.

This is what I am seeing:

capture

ghost commented 7 years ago

Just noticed something else, the icons seem to be broken.

capture

They are still there but now very small.

p.s. the icons seem to be broken on the slider to.

I might try a fresh install rather than copy over the old. Will report back shortly.

ghost commented 7 years ago

I just deleted the habpanel directory and reinstalled. Same issues as the above two posts are still there.

ghost commented 7 years ago

This might help with the icon issue.

For both the slider and the dummy widget , if I click the 'center backdrop horizontally' the icons return on both widgets. In the case of the slider the icon disappears when I un-click that option.

ghys commented 7 years ago

Don't put quotes around the format, it's simply:

HH:mm

The icons are a result of an unfortunate CSS change, I'll look into it.

ghost commented 7 years ago

I tried that....

capture

capture

ghys commented 7 years ago

Strange... is your item a DateTimeItem? You can check by navigating to http://server:port/rest/items and looking for your item's name, the type must be DateTimeItem.

{"link":"http://localhost:8000/rest/items/astro_sun_local_rise_start","state":"2016-08-29T06:50:00.000+0200","stateDescription":{"pattern":"%1$tF %1$tR","readOnly":true,"options":[]},"type":"DateTimeItem","name":"astro_sun_local_rise_start","label":"Start time","tags":[],"groupNames":[]}

ghost commented 7 years ago

Here's what I got from the REST API, hope this give some clues to the issue.

{ "link": "http://192.168.1.240:8080/rest/items/Sunrise_Time", "state": "2016-08-29T07:04:00.000+1200", "stateDescription": { "pattern": "%1$tH:%1$tM", "readOnly": false, "options": [] }, "type": "DateTime", "name": "Sunrise_Time", "label": "Sunrise", "category": "sunrise", "tags": [], "groupNames": [ "Weather" ] }

ghost commented 7 years ago

I will go and try to change it to DateTimeItem and advise

ghost commented 7 years ago

Following is my item definition:

DateTime Sunrise_Time "Sunrise [%1$tH:%1$tM]" (Weather) { channel = "astro:sun:local:rise#start" }

It does not appear that I can change it to DateTimeItem in either the Paper UI or OH2 Designer.

ghys commented 7 years ago

Huh. All my items are suffixed with 'Item' and it looks like yours are not, maybe this changed at some point in ESH/openHAB and we have different versions (mine is from last month). Anyways, let's check for both types. Please try with this latest change. We're getting there ;)

ghost commented 7 years ago

That's all fixed now. Thank you!

ghys commented 7 years ago

At last! Thanks!