There’s an api which returns an (json) array of short strings (each string with length of 2-15 chars) which can change in size. Typically the size varies between 0 and 10 entries (but not guaranteed).
The goal is to see all the values on the sitemap and also the size, the format does not matter at all (should not be ugly )
I tried quite some to solve the issue but each solution I find is not ideal. The problem is that just concatenating the array values, the resulting string is too long to just store it in a single item and display it on the sitemap, the sitemap would truncate or not show the string at all.
So I tried to split it up, each value of the array to a single item. However since the size of the array varies I could not find a way to dynamically create items or so. So right now I hardcoded 10 items, each one of them use the http binding to fetch which works but is not very nice.
The second problem is how to display it on the sitemap. So I thought to display the size of the array on root level and when clicking on it go to a subscreen to list the individual items. However since I hardcoded 10 items I cannot just use the Group element on the sitemap since the size would always be 10 then. So right now I use a different item to store the size of the 10 items who actually have a value (not null). But then since that’s a different item I cannot use Group also, so I need to manually enter all 10 items to the sitemap.
For the first part, you could work with a rule to assign different values to different items.
Iterate through the JSON.
Then you can work with the visibility property to show the item(s) or not. Which should cover your second question as well.
Alright then it seems like there is no better solution. I mean the current solution works but that’s just incredible cumbersome, what if the maximum count would go to 30, I would need to copy and paste 30 items, always increasing a number by one, that just feels wrong. Then next month it could increase to 35, I need to adjust my setup again? or I just think ahead now and create 100 items by copy paste…
why not? imagine an array of users (or smartphones or network devices or whatever) currently at your home, the api returns an array of strings. I’d like to see how many there are and then also the details which devices actually
BasicUI is, as it’s name implies, basic. It’s not that dynamic and it’s not that capable. But there is HABPanel, HABot, and the new OH 3 MainUI which support more dynamic UIs.