HTML layouts in OH2

Hi everyone,

I just changed from 1.8 to OH2 and I am trying to set up the weather html layout.

In OH2 apparently there is not webapp folder, so how is it done then? Where do we have to move our layout?

I read some other topic where someone say it is on conf/html/ but in I am not able to make it work, and if this is the right place, the structure inside keeps being the same? (images folder, and layouts folder).

In other words, how can we have an HTML view for our weather?

Thanks for your help.

same for me. The wiki even says:

Using the layout file:
You must specify a locationId and a layout parameter, iconset is optional (default=colorful)
Either directly:
http://HOST:PORT/weather?locationId=home&layout=example&iconset=colorful
or in a sitemap:
Webview url="/weather?locationId=home&layout=example&iconset=colorful" height=7

(This does not work for OpenHAB2 and this WIKI needs an update for how to use this on OH2)

I get the error about the layout file not being found:

HTTP ERROR 500

Problem accessing /weather. Reason:

Server Error

Caused by:

javax.servlet.ServletException: File with weather layout ‘example.html’ does not exist, make sure it is in the layouts folder ./webapps/weather-data/layouts
at org.openhab.binding.weather.internal.gfx.WeatherServlet.doGet(WeatherServlet.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Powered by Jetty://

I run OH2 as a service with an installation via apt-get. So, my configurations live in “/etc/openhab2”, and the runtime is in “usr/share/openhab2”. Neither of those locations have a webapps folder, so I tried adding this to both locations with no success. As suggested, I also put the “weather-data” folder in “etc/openhab2/html”, but the error stays. Any ideas on the correct locations and the correct webview url?

You definitely want the weather.html file in the conf/html folder. In the sitemap try somethign like:

Webview url="/static/weather.html"

Or it might be url=http://localhost:8080/static/weather.html

Either way, I’m pretty sure that’s what I have done with my test bed setup of OH2

would be wonderful if you could take a look at how you set it up if you still have the system available. None one the suggestions you had solved the problem for me.

Thanks!

Hey, I have:
Webview url=“http://192.168.1.20:8080/static/Weather.html” height=11

But that isn’t viewable from a remote connection (I haven’t set up my.openhab) so it needs review.

Right. How did you set up the folder structure under /html? In the wiki for the weather binding, there is a zip which has “weather-data” as the top folder with “images” and “layouts” as the subfolders. None of them have a “weather.html” so that url is probably not going to work,

Here comes my try:

Just to be sure I copied the folders under /html/ and under /html/weather-data/

In the file README.TXT it says that the right way to make the call is:
http://YOUR_SERVER:8080/weather?locationId=...&layout=example&iconset=colorful

In my case this is what happens:

The binding says that the “example.html” file can not be found on /webapp/weather-data/layout (which is the old path for OH 1.8)

I tried what @pahansen wrote using the following ulr:

http://192.168.1.88:8080/static/example.html 

And this is what I get:

I can display the “example.html” but is not bound to any information.

First big question, is this even working in OH2.** Has somebody it working?**

Fair call, I didn’t use any css and just dumped the html file in the html folder. I don’t use this in my sitemap at the moment so never spent any time making it pretty.

Which means it never worked for you on OH2
?

My map.html file works/ed fine for my mqtt owntracks setup in OH2. I just assumed the weather html worked too, but don’t think I ever actually loaded it up, before deciding I wanted to start my weather items from scratch.

not sure if this is the right way, but I created an Issue just now: https://github.com/openhab/openhab/issues/4532

I’m guessing this needs fixing in the html layout files.

@tkuehne

Don’t you think this issue should be in OH2 or OH2-addons distro? Right now you created the issue in OH1 distro.

I believe I put this in the general openhab source issues. You are right, This might be more specifically addressed in the OH2 addons section. I guess the maintainers can move it accordingly.

openhab/openhab is the right place, because this is where code of the weather binding is located.

whew :wink:

the issue doesn’t generatea lot of interest though. Is the binding orphaned?

I put html to /conf/html folder, and included it in sitemap as:
Webview url="/static/example.html"
As far as i can see, the content is just static HTML, it does not replace dynamic content.

I experimented with this tonight and found that placing a “webapps” directory containing the “weather-data” directory under userdata gets the right weather values populating. eg.

%openhabhome%/userdata/webapps/weather-data/

The images aren’t being loaded, however. I guess that could be a proxy problem in OH2 ?

So, it turns out you can fix the image problems by dropping all the static content off in the conf/html directory and update the layout file with the correct paths:

/static/weather-data/layouts/example.css
/static/weather-data/layouts/example.js
/static/weather-data/images/${param:iconset}/${forecast(0):condition.commonId}.png
etc


It still dosn’t work for me - html layout is shown on sitemap but without item value. Can you explain your method once again ? What is the trick to get item values ?