Cookbook for iterating over group members, showing results in UI table per item and as a whole

Hi there,

Using openhab 3.1. fresh installation, I’ve setup the first ~40 items from our smart home installation, mainly heating related stuff using HomematicIP, so far so good, and would like now to deep dive into some more customizing openhab for our purpose.

Looking therefore for some kind of cookbook to solve 3 tasks from my user story: “Show me a list of all items that run on battery and indicate a ‘low battery’ status if there is one 1) Show me somewhere in the pages a single indicator if at least one item has this problem and 2) also a full blown list where I can lookup which of the items needs a battery replacement. 3) And oh yes, please report the result from 1) at least once daily into a chat channel at a given time”.

So far my model is setup with all the locations (rooms, buildings etc.) and I created a group which contains the respective “low battery” points from thermometer equipments. I did some first automation tasks and are currently persisting all with InfluxDB, so the basic setup is up and running nicely.
I haven’t dived into UI deeply but it looks like something like a table is unfortunately not an out of the box widget? From my point of view I need to solve the following tasks:

  1. Create some kind of resuable code (I suppose) that is used in a schedule (see task 3) and also can be used for the UI. Not sure how it’s best to have some kind of “functions” implemented for this (actually I’m a developer guy…)
  2. Create/use some table like UI. It should have columns for item/equipment names (actually the label of the), the state (which can be textual or numerical depending on the type of the point). Make use of the function’s results from 1.
  3. Again UI, but single element that solves user story 2) and also makes use of results from 1.

The basic development model is clear to me, also how to iterate over a group and so an - at least as code snippets. But how to cut the story into tasks, that applies to openhab I’d highly appreciate for some “howto” help here. OH is such a huge monster to start with…

There are similar tasks that I’d also like to solve with a table like approach, so I think this would go serve quite nice as a recipe for me.

Thanks,
Sören

This one should be a good starting point

Also search for UiSemantics….

1 Like

Even better than the link @hmerk posted, Battery Level Status (installable from the Marketplace) can solve:

  • “Show me a list of all items that run on battery and indicate a ‘low battery’ status if there is one”
  • “1) Show me somewhere in the pages a single indicator if at least one item has this problem”
    -" 2) also a full blown list where I can lookup which of the items needs a battery replacement."

and Threshold Alert (also installable from the Marketplace) can solve

  • “please report the result from 1) at least once daily into a chat channel at a given time”.”

The only part you’d have to implement is the “into a chat channel” part.

If you don’t just install and use these, they can at least serve as a pretty close example.

That’s not how it works. The UI shows the states of Items. All the information you want therefore is represented as Items. So the only schedule that is needed is to look at the current state of the Items on a schedule and send the chat when necessary. That’s 100% rules. Everything else is just choosing how to represent the current states of the Items which is 100% UI.

Items are a currency of the realm. They are the main abstraction layer in OH. Everything you do in openHAB is going to be using and manipulating Items.

To my knowledge there is no table widget. But you can use a List widget and show different rows and you can configure each row to show different information in “cloumns”. This is best done using the repeater element.

As you can see in the Battery Widget I posted above, if all the batteries are above the threshold it just shows the header with the minimum battery level. Only if one or more batteries are below the threshold are they shown below, one row per battery. So you have one widget which does both jobs.

But if you really need a separate widget, just create a regular old label widget that shows the minimum battery level. Or use visibility to hide an element unless the min batter level is below a threshold. Or create a rule to update a Switch Item to ON when the min battery level is below a certain threshold.

1 Like

Indeed Rich, forgot about your Marketplace exsmples…

Hi @rlkoshak @hmerk,

thank you very much for putting me on track with the oh-repeater examples and also for pointing out the two widgets from the marketplace - appearantly I wasn’t even aware of the marketplace.
I think the two widgets from Rich will do the job for the moment, maybe a little adjustment to my needs, but as a learing example about developing widgets super-cool to start with - thanks a lot for your help!

Sören

Just to be clear, I linked to one UI Widget and to one Rule Template, not two UI Widgets.