Is there a “simple” expression that could be used to “hide” content for example on an oh-cell when the screen size is small to prevent overflows etc?
My use case would be with the following oh-cell
This displays perfectly on a larger screen, however on a device etc the result is less than pretty:
So My idea was to simply use the visible: ... expression to not display the extra information on small screens. Just don’t know what I could use in the expression or if this even at all possible.
You’re on OH4 so your widget expressions have access to the screen object:
In this case you probably just want visible to be some simple boolean involving the viewAreaWidth property.
visible: =(screen.viewAreaWidth >= 800)
If the problem really is between desktop and mobile devices, however, then the other option may just be to use the device object with has a desktop property that is true if the viewer agent is a desktop browser and false if it is a mobile browser.
Hi there,
unfortunatly, both expressions are not working for me to display widgets only on screens above a certain size. Can anybody confirm that “screen.viewAreaWidth” is actually working within the OpenHab App ?
If I simply try to display/read-out the value returned by this expression in the customer widget’s editor, a plausible value fitting to my Desktop screen (~3000) is shown, however opening the Main UI on the tablet/phone via the app consinstently returns a 0 and hence kind of explains why I am not succesful limiting the widget’s appearence to large screens.
Browser Main UI…number is always zero and the component with which I am testing (oh-clock card) and to which I applied the expression you stated is always hidden:
Are there any other settings that I am not aware of, in order to allow the screen.viewAreaWidth to be filled with a value, since I noticed that the value is always 0 (except in the custom widget preview).
Maybe share your YAML code in code fences?
Which page are you doing this on? I have seen some odd behavior on the Overview page. Maybe try on a different page to test?
EDIT: The following works for me on the Overview Page , though the layout of the oh-clock-card needs some work. I have tested in browser and using the Android APP:
I thought it worked, but no After reloading the page it vanishes always, doesn’t matter on which device or browser or OH android app…so if I add the expression “visible: =(screen.viewAreaWidth >= 360)” the widget never shows
component: widget:Schmendrax_Time
config:
text_header: --- hier kommt Uhr und Datum ---
visible: =(screen.viewAreaWidth >= 360)
K, I am on 4.0.3 Release Build…maybe that really is the problem. I will try again after the official update is coming and then will comment again whether that solved it
Thanks Mark !