screen.viewAreaWidth @OH4

I am still migrating my system from oh34 to oh40.
Now I’m facing problems with the screen.viewAreaWidth property at openhab4.
It is often not working properly working, especially for smaller screens. In this case it is simply set to undefined / nothing.

With oh34 its working.

Can somebody share this perception?

O.

I don’t use screen.viewAreaWidth much, but a quick test simulating several different mobile screens didn’t demonstrate any problems.

You’re going to need to see if you can narrow down/replicate the problem. Does this just happen with a browser (if so which do you use)? Does it happen only in the mobile APP (again, which one)?

Can you post the code of one of the widgets where it doesn’t work?

1 Like

thx for your support.

I prepared a page with following block

component: oh-label-item
config:
title: = (screen.viewAreaWidth)

The label is correctly showing the width.
But as soon as the width is getting lower then 600 the value gets undefined and the label is showing nothing.

Any hint?

Without more information (see other questions in my first post) this cannot be replicated.

I can confirm that there is a problem.
I started using this in my widgets:
visible: =(screen.viewAreaWidth >= 1000)

Then I recognized sometimes it works sometimes not.
So I testet it on the widget with:

component: oh-label-item
config:
title: = (screen.viewAreaWidth)

I see that sometimes I get the correct values for example 1660, sometimes I just get 0 even if it should be 1660. I have this problem on my desktop computer in Chrome, in Firefox and at my Android tablet.

The problems comes and goes with a simpel page refresh (F5).

The side I have the problem on is pretty complex. It looks for me like the variable screen is not set at the time the widget is build sometimes.

If I refresh the page I sometimes see the value printed at 0 and then just changing to 1660 before the widget is then shown on firefox and chrome.

So we are three users with the problem now.
Something needs to make sure that the widgets are not build before the variable is set.

Well then, it sounds like it might be worth filing an issue about.

for me with oh4.4 the issue seems to be resolved.