MainUI location/devices switch with mappings (Garage up/stop/down)?

  • Platform information:

    • Hardware: QNAP VM
    • OS: Ubunto 18
    • Java Runtime Environment: Azul Zulu OpenJDK
    • openHAB version: 3.1
  • Issue of the topic:
    Dear all I am currently in migration process vom OH2.5 to OH3.1 . I still prefer to do my config in a textual style. Basic KNX connection works, .things file for KNX added and and working.
    I quite like the new MainUI and thought I could save myself creating sitemaps and HabPanel pages but I ran into (hopefully) a minor issue with my garagedoor. It is a dumb device with a button. First press and release the motor goes up, second push and release it stops , 3rd push and it goes down and so on.

As for now I have solved this in OH2.5 with using the mappings fucttion in the sitemap file

Switch item=EG_Garagentor_Auf_Zu  label="Garagentor Hoch/Runter/Stop" mappings=[ "ON"="Hoch/Stop/Runter"]

Now here comes the question. How could I mimic this behavior best in OH3.1 MainUI location and devices view without creating a complete new sitemap for all rooms. A simple button would be doing it but the switch is not the right approach here.

Current OH3.1 .items file which gives me the "standard “switch” but what I would need is more a “button” as this does not have a listening channell anyway.

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"}

Any idea/hint? Many thanks
bkumio

See Garagedoor. If that suits your needs you can just install it from the Marketplace (once you update to 3.2). Until then you can go to Developer Tools → Widgets, click the + to create a new widget and paste the YAML from that post to the code side. Save.

Now go to your Item(s), “Add Metadata” and “Default List Item Widget”. Select the widget you just create from the list and set the properties as desired. Now everywhere that Item appears in a card it will use that widget. If you modify the code of the widget back under Developer Tools → Widgets, it will automatically update it on every Item that is configured to use that widget.

If you only have the one widget, you can use that as an example. Essentially what you want is an oh-list-item with a command action to send ON to your Item.

One thing to note with the above widget, it combines the state of the garage door (i.e. OPEN/CLOSED) with the ability to send the ON command to the different Item that triggers the opener. So you can put it on one of those two Items and set the visibility of the other one to false so only the one Item with this widget gets shown in the cards.

Hi Rich,

this is super interesting. Thanks.

I have just added the widget and tried to start to configure it. Realized that I havent added my binary inputs to the things yet that contain the open/close state of the garage. So I guess I need to add first and bind that widget to this switch item instead. Plus configure it so that the other switch item is triggering once pressed that the garage moves…

Sounds promising to be able to use it “as-is”. Will let the community know once it works or perhaps reply with another question :slight_smile:

I guess this “config” needs to be done always in the GUI rather then directly within the .items file.

thanks again

You could do it in .items files but I wouldn’t recommend it.

You cannot define a custom widget through text files though. But you can apply a custom widget to an Item through .items files but the syntax is very error prone.

good news , this works like a charm! Also good to know that this will be part of OH3.2 although copy paste the code vs installation from marketplace will probably not make a big deal.

I am still a bit overwelmed with all the configuration options. But I put this for now into the “I need to get more OH3 experience” box :slight_smile:

Comming from KNX as I do this is a bit more difficult I believe. Its easy on the thing level . The actor is a thing and has got “n” channels . Each channel I could associate a 1:1 item to and thats it. If I got this right I could now setup virtual equipments and properties and points and each of it could be a member of the other…this confuses me. But I am sure I will find more posts on this and make myself more familar.

thanks again for your fast turnaroud. First milestone done.

bkumio

Don’t ignore the Getting Started Tutorial. For even more information about Items and the semantic model see A Deep Dive into the Semantic Model and see the Items docs for more about Groups Items | openHAB, Items | openHAB.

Actually your “deep dive explenation” is very insightfull. This will help me in making my decsions. I need to experiment with a couple aproaches. We should probalby copy/replace your post on the existing documentation with all the effort you did here. I see a lot of people struggeling and there is also no “right” way as you pointed out.

What I would apprechiate for future OH version is that the semantic model could be managed via a database with 1:n relations so I could decide on the individual names and the icons of the individual items for location(s)/Equipment(s)/Point(s)/Propert(ies). Preload the exising semantic model at installation and then leave it to the users to ammend if wanted. Just a thought.

As for KNX I need to try out too. At presence I have setup all my Actors as Things with the corresponding channels in the .things file. Then I created for each thing chanel a row in a .items file but directly using only equipment tags.
I can understand however the equipment and point approach for managing a HVAC room temperature where you have a current temperature, a set temperature, a status heating on/off and perhaps a humidity.

But to create a textual Lightbulb equipment group for each room ceiling light which then contains nothing else than a 1:1 member which is essential the “same” line but a Switch point is an “overkill”? Also when I was doing so I did not like the result in the Main Location UI where I had is displayed as 10+ groups with a individual heading of the room name and a sub icon of the light with the same ceiling name… Have I done something wrong here ? However doing it that way might helpwith the Sitemap setup for the Android Habdriod part?

coming form OH2.5 I have done the config in .items files. I may also try to skip this and use the “Create Equipment from Thing” and “Create Points from Thing” option. This might work also…
Questions over questions. I guess noting else helps than to continue to play with it and then decide what is best for my/everybodies individual requirements :slight_smile:

So thanks again for your good post. Happy to raise a CR for a dynamic relatationship DB semantic model approach if this is not already done by someone else?

M

Well, I wrote that too. But the deep dive doc is too deep for a Getting Started tutorial and at least for the time being there isn’t a good place to put it into the main docs.

It depends. What if you have one light that has three smart bulbs which are logically all the same Equipment. If you make that one an Equipment with Points/Properties as members and all your single bulbs are just Equipment then the two will appear differently and you’ll have to interact with them differently in the Overview Locations, Equipment and Properties tabs (e.g. the single bulbs won’t even appear in the Properties tab at all).

The important thing is to be consistent.

The Locations, Equipment, and Properties tabs are wholly driven by your semantic model. If you don’t like the way it appears you must change your semantic model approach so that it generates the groupings and categorizations that you want. Right now that is the only thing ion OH that is making heavy use of the semantic model so build your model with those tabs in mind, or don’t bother with the model at all and just hide those tabs.

The Sitemap doesn’t use the model at all.

Given that the semantic model is wholly implemented using Item tags and Item Group membership I don’t see how this idea is feasible. But maybe you have an idea for an approach.

However, it’s not really clear exactly what you are asking for. If your main concern is how these appear in the cards in the Location, Equipment and Properties tabs, then that is already possible. Create a custom list Item widget for each type of Item you want to customize (or install them from the Marketplace) and then when the Item is created add “Default List Item Widget” and choose the custom widget from the list.

Given that the semantic model is wholly implemented using Item tags and Item Group membership I don’t see how this idea is feasible. But maybe you have an idea for an approach.
However, it’s not really clear exactly what you are asking for. If your main concern is how these appear in the cards in the Location, Equipment and Properties tabs, then that is already possible. Create a custom list Item widget for each type of Item you want to customize (or install them from the Marketplace) and then when the Item is created add “Default List Item Widget” and choose the custom widget from the list.

I like the Idea of the semantic model. As a non-developer I just feel constraint confused with the missing rooms or equipment’s when I setup my house. Understand that Cards/Pages I can setup the way I want.

For example when I setup my floors I started with setting up a new item as a “location”. I then only have 2-3 options as “category” (groundfloor, first floor, attic) which make sense to choose from. But this confused my initially when your house has got a second floor. What should I now choose ? I Also would like to have a representative “icon” all the times of course. As well system offers you as sematic class to change from “location” to a “second floor” as location? But when I choose this what should I then select as a category?

Questions over questions :slight_smile: If you face this as a new user this is the first time you´re stuck with a: "hmmm ok , and now? " … I am sure I can find similar examples with the equipment’s and properties.

I don’t know how this is setup under the hood. But I would love to have a semantic admin page where I can alter the model including adding my custom icons. For example adding a 3rdFloor as a location or a 3rdFloor as a Category with even uploading an icon.svg.

I found the existing setup on : SemanticTagsGithub . E.g. there is a hierarchy already there. So instead of having these lists hardcoded I would like to have a “+” sign where I can add an equipment/location that does not exist (for me and my setup).

On the UI what would also perhaps help if you first select the Semantic Type (Location) . that the provided category options are filtered for “location types” only . Same when I say create Equipment. No need of displaying the locations .

Another a minor thing when I want to see what is “there” I cant see “all” options by pressing the arrow down. I always have to type one char and then a list is presented. But of course does not show all as its filtered by the char I have typed. Hope this is clearly described. Not important as I can look at the CSV file on Github, but may be as well a thing for newcomers.

I fiddled my way through, no worries :slight_smile: But as for next release when one developer is touching the semantic model I could offer to take a stupid “end Users view” and provide assistance/input/wireframes of potential way of changing this if this helps. Happy to do this as you guys povide so much goód stuff that I am happy to give something back. Count me in and contact me when you touch the semantic model code.

M

Category had nothing to do with the semantic model. It’s just a way to specify the icon used to represent that Item in the admin sections of MainUI. You can use anything you like. You can even download your own icons and use those (see the icons section of the Items doc page).

Since the icons are not part of the model I don’t see that happening. But there is a way to add custom icons, but not though the UI.

And again, to be clear, the category is just defining the icon. Nothing more.

That’s what the “Create equipment from thing” option does which is available from both the Model page as well as the Thing’s page.

You can also add a Location from the Model page.

It’s the big blue + icon at the bottom right.

I’m not really sure what you are looking at or doing and from what page because s9me of the things you are asking for are clearly there already. There already is a way to create, for example, a Location in the Model page. When I create a Location there, it does only list the Location tags and it shows all the Location tags.

Some if the things you are asking for are not technically feasible at this time like adding custom icons through the UI.

Maybe this is all mainly confusion about what the Category is. As I said, it’s not part of the model at all and all it does is change the icon used in the admin parts of MainUI. Nothing more. And you can add your own icons which is in the docs.

Thanks Rich for your patience in explaining this (again and again) . Have not forgotten about this topic, I was meantime experimenting.

On locations I do have for example two rooms which are not available from the existing locations on the semantic model . One is the guesttoilet for example another one is the heating room in my cellar. So in the beginning on my textual journey I was struggling what to do when the right room was missing. But now ended up with calling them all of them just a “location” or a room.
So my request (if needed at all) would be to have a possibility to add my (everyone´s individual) missing rooms and tag them to become a location category. But it looks like the on the UI it takes the Label name to create the locations interface which is fine.
Also may be the Semantic Model textual config having a separatea subdirectory containing .semantic file(s) for textual configurations to keep it physically separate. But this is perhaps just cosmetic. I managed to do this with a .items file just thought it would be nicer/ more obvious if the semantic model has got its own subdir

Then I struggled with creating the next level of the .items file on whether it is an equipment or a point. But ended up in some sort of mixed mode how it made sense (to me and my things) . Some are equipment’s with a couple of (set)points and some a points on its own or an equipment on its own.

my initial icon (category) problem somehow went away as later in the UI pages I anyway used the card properties itself or backgrounds. Perhaps we can rename the “category” to “DisplayIcon” … or remove it. I guess this is only used for the sitemaps ?

So yes the concept makes more sense to me now but I think it takes a while to deal with it as it is not a piece of cake… :astonished:

M

Given how the model is actually implemented, this is impossible. The model is just properties on items. The model isn’t separate from Items. It’s just item tags and Group membership.

and, like I said, the admin areas of MainUI. The name Category is a good over from PaperUI.

One very important thing to now though is that the model is optional. We can’t make changes it remove features needed by those users.