Can a widget be a "member" of a Items group ? Or is there a simple alternative?

Dear All,

Im am migrating from OH2.5 to OH3.4 . Migration is very successful so far. But I am running into a issue where I need you steer/help.

Basically in 2.4 I have used sitemaps and mappings to have nice buttons to press.
garage

So far in OH3.4 I have successful, by textual configuration, managed the entire room pages with group memberships . E.g. when you press the Living Room card all the members of that room are listed.

I want to avoid using sitemaps again and stick with pages only in OH3.4 but as far as I can see from the documentation you can use the old mappings syntax still with sitemaps only ?

In particular we are talking for on garage door switch where I only want to have one Mapping button called “Hoch/Stopp/Runter” which is up/stop/down as the garage does not distinguish. The actual execution was managed by a rule execution.

Yes, I could add a dedicated garage Page and add all items like lights, backdoor and the garage door as individual label cells and then add a custom widget for the garage door too- But I quite like the automated group membership approach from my texual config as this is quite easy to manage and dynamic.

Questions :

  • Is there a way to add a widget as a group member being shown when selecting my room card (from marketplace) ?
  • Alternative , can I use the mappings feature in the *.items file to show a button instead of the switch slider
  • or is there a different way I was not aware of how to fix this ?

Interested how you have solved such a scenario. Looking forward for replies.

bkumio

You can change how an item is presented in the cards by setting the default standalone or listItem widget in the metadata settings of the item.

Just about everything you need is in the getting started tutorial: Pages - Item Widgets | openHAB and in the custom widgets pages that follows that one.

OH3 is different enough, that even if you are a veteran OH2 user, the getting started tutorial is strongly suggested.

2 Likes

I cannot stress @JustinG’s advice too strongly. Those users who have the most trouble with OH 3 are not new users, not even new users who don’t have basic technical skills. The users who have the most trouble are the people migrating from 2.5 without reading the Getting Started Tutorial.

1 Like

Thanks for the fast answers. Believe it or not but I have read the tutorial (more than one time). And yes probably old OH2 users like me do struggle a bit more trying to mimic old functionality. But I was willing to give it a try.

So after having read the tutorial plus some pro/cons about the textual vs. UI config from the forum I decided to continue with things/Items as textual files with a proper semantic model behind. E.g. I decided to throw away the sitemaps and focus on a MainUI with pages and widgets options.

This works actually very well. I am quite happy. I do have tabbed pages with a Tab for each flor level and each flor level contains a page with all rooms using one of the room widgets from the marketplace.
I have discovered that if I use the Group details action and subsequently as “group Popup Items” the corresponding “room” group I have created in the sematic model that it represents what I want to see.

So far so good. No my problem with the garage door as an example. I was looking to have have similar look and feel for a switch item with a button instead of the default slider. As an old OH2.4 user what comes to your mind is “mappings” but then you realize it still requires sitemaps which I don’t want to use anymore as I think the MainUI is quite good stuff.

My first intention was to create a dedicated page for the garage where I put in objects and another nice widget for garage I found in the marketplace. But I do have more than one room with such requirements and the usage of the sematic model group popup was doing all of that “automatically for me” rather than creating dedicated pages for each room.

But hence the question on if there is a option/way I haven’t thought off to have a simple “button” for a switch (instead of a slider) for a switch item that would do the trick whilst still using the semantic grouping model (if possible) to be able to use the group PopUp functionality?

(excuse the long answer , but I hope helped clarifying)

Also a “not currently” possible is fine . Perhaps we need a section “traps OH2 users are tapping into by default, and how to escape properly” :slight_smile:

cheers
bkumio

One thing that’s quite different form sitemaps is MainUI doesn’t really have a button as a part of a widget. Instead the whole widget is the button. So if you want a button, you will use an oh-label widget inside another widget and set the action to do what you want to do, or set the icon or the like. Pages - Custom Widgets | openHAB shows a little more complicated than probably what you are after but if you focus on the “Stop” part of the widget you’ll kind of see what I’m saying.

Ultimately, make the widget look like you want it, set the action and you’ve got a button. Again, there isn’t a concept of a button as a separate thing.

If I understand correctly, you are wanting to put this into the cards on the autogenerated parts of the Overview page. The way to do that is to set the “Default list item widget” Item metadata. So you can construct. a widget that looks and works how you want, set that as the default list item widget, and that widget will be used in the location/equipment/properties cards.

As for the pop-up, that’s just one of the many Actions that can be done when the widget is clicked on.

An example widget that I built for that may be the one on the marketplace that you are referring to (I think I’m the only one who has published garage door opener widgets on the marketplace. Garagedoor

In this case, the whole widget is the button which, when clicked sends a command to a Switch Item that triggers the garage door opener. The icon on the left and badge on the right is driven by a Contact sensor Item indicating the open/closed state of the door.

In fact, you don’t even really need an item for this. If the information is actually handled by the rule then you can use the widget actions to directly run the rule without any item event in between.

As Rich points out, it is the widget actions that are really the key here. There is an oh-button component that can be added to a custom widget but it just takes the same action options as any number of other components as well (oh-link, oh-icon, etc.). In this case you want tell whatever component you choose to either send a command to an item (the command action) or, as I recommended above, just start a rule (the rule action).

In the component docs, there’s a whole list of examples for each of the various actions:

If you really want to create something that looks just like the toggle item in the list but with a button, then you’ll either have to do a little search on the forums (there are examples where users have already created something very similar to this) or create it yourself. To do that, you’ll have to understand the basics of of the -item family of components, and their slots as well as the widget actions. None of that is too difficult and it’s going to come up sooner or later if you keep work on a your custom UI so it’s probably time well spent.

Thanks guys being so patient with me…

I will have a look into your suggestions and links , try a couple things out and I am sure I will get there with some time, Investigation and experimenting. I never had OH let me down in the past and already started with version 1.7 openhabian and my raspberry PI that time…

But have to admit that this version v3 is getting me a couple more grey hairs :slight_smile:

Best
Mario

Dear all a quick update which might be helpful for other OH2.4 users like myself and thanks again to @rlkoshak , @hmerk and @JustinG for pushing me into the right direction.

Remember I did ask for an option to use “mappings” in the new UI which is not possible unless you want to go back to sitemaps which I didn’t want to do as as was happy with the group action for each room to show up all members .

Here what I did not realized before. You can in the items metadata change the so called “default list item” with a widget of choice and this will replace/overwrite in fact the (textual) item configuration. Like my Garage Door is setup as a switch item. I have now used the garage door from marketplace but if not happy this can be also any kind of self-created widget code.
-----> This was not so clear to me in first place.

Additional things I have learnt at the same time is that you can also add in the channel section of the items configuration file a :", expire=“1s,command=OFF” . As my garage door only reacts to a on/off pushbutton I had to solve this with a rule in OH2.4 before

Questions to the experts. I want to stay with my textual config and managed to get the expire code already into the items file. How could I add the rest of the metadata of the default list item to the textual config?
But I guess due to potential the endless parameter(s) needed like items, command, labels, visibility etc. this is not recommended ?

Current items file

// Garagentor managed via extra widget and additional metadata to the item (Default list item widget and expire after one second (1s) to have a pushbutton)
Switch  EG_Garagentor_Auf_Zu            "Garagentor auf-stop-zu"        <garagedoor>    (EG_Garage)                         ["GarageDoor"]  {channel="knx:device:bridge:1_1_5_Schaltaktor:EG_Garagentor_Auf_Zu", expire="1s,command=OFF"}

P.S I have read the pages/items documentation page again and now I understand it better. I believe we can do better. I am not a real developer and have not yet created my own OH code but do have a github account . E.g. not familiar with committing changes. Is it enough if I edit the documentation page and give it a try ? How will it make to production? Sorry for the probably "stupid question.

Hopefully this is made clear in the Getting Started Tutorial. The users who have the most trouble with OH 3 are OH 2 users who skip the tutorial.

This was definitely supported in OH 2.5, but I think 2.4 supported it also. Though below a certain version, Expire had to be installed as a separate add-on.

Honestly, it’s not worth it. Your .items definitely is going to be thousand of characters long and it’s going to be a nightmare to maintain.

Item metadata and Items are managed separately so you can keep the Item definition in fights and done of the metadata managed.

But if you want to learn the hard way, add a default x widget to an item and click on the “code” tab. All Item metadata follows the same format.

It should be straight forward to translate the y’all you see in the code tab to the text format.

Not a stupid question. We have an extensive tutorial written to answer this.