Tool that auto-creates items file for a thing's channels

Hi all,

I need to give you some background first.

Here is my use case:
Whenever I install a binding that auto discovers things, I like to create an *.items file that contains all the possible items. I start with many items and once I get a better understanding about what they do, I remove some of the items again.

Is there any way (besides using Visual Studio) to create this file or the content automatically?

Let’s take a look at an example, here a Shelly device:
In this case I’d like to create 4 items.

PS: I started to build a small web application that allows me to select the Thing for which I want to create the items, but I’m confused on how to detect the item type. For example I see values like “Number:Time” which is not allowed for a *.items file. Fun fact: The REST API provides more channels than displayed via PaperUI (see below)

Thanks in advance

Stefan

You do NOT want to use Paper UI Simple Mode.

You could write a script that uses the REST API but, like Simple Mode, you would likely have unintuitive Item names.

PaperUi will show you the missing channels when you hit

Show more

on the upper right of your screenshot…

2 Likes

see my last screenshot :slight_smile:

Yes it is. See Units Of Measurement | openHAB

Click on “Show More” at the top right of the list of Channels.

There is no such tool. You would have to write it.

4 Likes

I love this forum and the guys who support :slight_smile: Thanks a lot, learned something new.

So far I’ve finalized my own tool, which runs inside openHAB as static html page.It even sets the labels correctly, see screenshot below.
Does it make sense to share it here?

Yes, please! Maybe in a github repository?

uhm… this goes beyond my expertise :wink: I know how to use it as an enduser (clone, create issues etc.) but I need to check how I can create my own repository. would you be willing to help? we can do it in German :wink:

Click on their icon & then the Message button to private message.
This is an English only forum.

@Bruce_Osborne relax :wink:

@Felix_Schneider give it a try: https://github.com/Stefan300381/openHAB_ItemCreator

3 Likes

looks good =)

2 Likes

btw: yesterday I fixed a bug

It looks like you are basing the Item names off the channel names. How would that work with a second Shelly? You cannot have 2 Items with the same name.

1 Like

I’ve modified the sample a bit so you can add a “leading” string to the item names. see screenshot. Taking a look at the example I think something like PLUG1_NETWORK_SSID is much better than something like: MIIO_GENERIC_0723B6D1_SSID. Do you have any other suggestion?

Btw: In regards to items names the documentation says

The only characters permitted in an Item name are letters, numbers and the underscore character. Names must not begin with numbers. Spaces and special characters are not permitted.

I tested it with bla, _bla, and 1bla and all of them worked like a charm.
You need to ignore the INFO lines as I was just testing something.

perhaps that is a recent change. I remember people (within the past year) having issues when starting with a number,

1 Like

There are many parts to openHAB. “Works like a charm” does not mean it works in say, every UI or rule system. Break the rules at your peril.

The Item naming requirements have been there since OH1.

1 Like

got it, but why does OH even load such an item and doesn’t throw an error?

I know I am a little late to the party but there is a HABApp feature which allows just that.
You even can use various fields from the thing as an input for the item name, label, etc…

Additionally you can even set the configuration parameter for all things, so it’s easy to share e.g. z-wave configurations.

It’s really neat - I recently bought 3 more PIR sensors and all I had to do was give them a proper thing name.
The rest happened automatically.

1 Like

Definitely, I had an idea very similar to this, And at the very least it give people something to spring board from, even if they don’t use it exactly as you designed.

Tried it out. It’s sexy as hell.

I was planning on writing something VERY close to this in python this weekend, to let me overhaul my item config. This is sooooo close.

js is not a language I work with (yet), I am going to play around with this this weekend tho. I personally will need to also add a leading string to the Label for my use. Dunno if that is something others would want/need. If I do make that change I’ll make it optional and submit a pull request.

Great work.

1 Like