[SOLVED] Automate sitemap or dashboard creation

Tags: #<Tag:0x00007f5c9eea1288> #<Tag:0x00007f5c9eea0e50>

Hi there. I am struggling with a specific feature I would like to implement in my IoT project and I hoped you could help me at least ruling it out if unfeasible.
Given a few things and items already discovered via PaperUI, is there any way to generate a sitemap or dashboard WITHOUT having to deal with HabPanel or other tools? More to the point, lets say I poll a list of discovered things from OpenHAB through REST APIs: can I build a json or config file from that list, and then push it back to OpenHAB to automate the presentation process of my sensors network?
From my understanding, a representation for HabPanel’s dashboards exists in a habpanel.config file, but while it seems written in a json-like structure it is actually unparsable and I am not sure of the syntax to re-write it as one wishes.
Any help is appreciated.

You can definitely create, remove and modify sitemaps in automation, but I’d recommend doing it through scripted automation. I haven’t yet done it myself, but I expect the same can be done with Habpanel. What I’m curious about is what the API will look like for the new UI in OH3! @ysc?

never done it … but what about sitemap + VSCode addon?
it seems simple enough no?

just get the hang of how to build one

and with VSCode you have access to your items… from just typing the start of the item

Thank you, but the goal is to never even touch an editor/UI and have a functioning sitemap spoon-feeded to you by the system. I get it’s an odd request, but it’s what I must achieve.

You could certainly pull the list of items from the rest api and add it to the sitemap via script.

You just need name and type of item switch string etc.

If you don’t care about order then you can add a group to the sitemap and anything in the group would show.

i have above 400 items in my home, how whuld you filter out what you dont need
witout any UI/editor?

did you see the contorl tab in PAPERUI ?
its doing somthing like what you need

Thank @5iver and @Thedannymullen for the confirmations, I would have hoped for examples but I guess nobody has ever had to deal with an issue like this.
@Gad_Ofir I know what I asked sounds stupid and needlessly complicated. Sadly, that’s what I’ve been asked to assess, so if you have any input that does not involve using a feature from PaperUI I will gladly take into account your opinion. You are right about dealing with items though, that is an issue that must be considered.

1 Like

There is no api for creating sitemaps. There was a design and pull request on Eclipse Smarthome for a new API for sitemaps, but that is not being worked on right now. For openHAB 3 there are wishes to improve the API, but no actual work is being done right now. In the optimal outcome there will be a new API that makes it possible and that would also replace the HabPanel API. I personally would not want to develop something on the current HabPanel API as I hope it will be replaced with something more in line with the overall system. But as long as there are no actual work being done on it, that still might be a solution.

@5iver I’m not sure if he has any plans to change the API. See https://github.com/openhab/openhab-webui/issues/24 There is some work, you might be familiar with on core, to improve the API implementation https://github.com/openhab/openhab-core/issues/726

2 Likes

You posted in the #development category. Examples of DSL rules or scripted automation would be asked for in #setup-configuration-and-use:scripts-rules. The category of your post can be modified.

There actually is a sitemap that is automatically created for you. If you open https://path-to-openhab/basicui/app?sitemap=_default you will see the automatically created sitemap. All of your Things are listed. Clicking on one of the Things will open up a frame showing all the Channels that are linked to Items.

There are limitations. You can only get the default representation of the Item and it only works with Items linked to OH 2 add-ons. It’s essentially the same stuff you will see in the Control tab in PaperUI, only less useable (believe it or not).

The big problem with anything that automatically generates the UI is going to be that it will rarely actually be what you want nor will you find it useful. For example, all your Network binding online Channels will be Switches which, by default, will be represented using a toggle. But you can’t actually toggle the device online/offline, it’s a false control. You would actually want to represent those Items on your sitemap using Text instead of Switch.

1 Like

The only known attempt to expand the sitemap API is currently this: https://github.com/openhab/openhab-core/issues/594#issuecomment-549377670, but unfortunately it does seem stale at the moment.
It has been also discussed at length here: https://github.com/eclipse/smarthome/issues/5337

There was also a proposal for a generic storage solution for UI artifacts which has yet to be specified.

Beyond sitemaps, the new UI’s home page will ideally try to classify your “important” items in expandable cards according to the semantic tags you attached to them: see HABot Walkthrough (2/n): Semantic Tagging & Item Resolving for more info about this, it’s an HABot tutorial but the semantics are a core OH feature not tied to HABot specifically.
You would simply switch to one of the tabs and open a card to get a list of items relevant to a location (“kitchen”), equipment class (“window”), or property (“temperature”). The interesting thing is, the cards would be autogenerated based of the semantics - so you would automatically get them simply by defining your semantic model correctly - but there would also need a way to configure the rendering of the card headers, the controls inside them, their ordering etc. This is still to be specified (maybe in a specific namespace of item metadata), I still plan do make a proposal on GitHub on that before the end of the year.

2 Likes

@rlkoshak that could be what I was searching for. As soon as I get results I’ll close the thread.