How to store and use custom metadata for Items?

Hi there,

I’m currently trying to port my Domoticz home automation to OpenHab 2 and would like to make my setup more generic to ease maintenance.
In particular my needs would be to ideally have for my RollerShutters (actually my windows) metadata such as the window orientation for instance and other metadata to use in the rules. The goal being to open or close the roller shutters depending on the sun azimuth and elevation and other criteria I won’t detail there.

Much to my regret it doesn’t look like OpenHab support any kind of structure, class, object or map concepts I could leverage.

Except if I’m wrong, what would in OpenHab be the best way to store such metadata and leverage them in rules in an easy to maintain way?

Thank you in advance for your guidance. :slight_smile:

Have you looked at the REST API? Try installing restdocs for more information and a web interface for testing.

Yes I have installed REST API but how can this server my purpose without making it a pain to maintain?
I already used Domoticz’s REST API with python scripts and I was kind of hoping to be able to avoid that while switching to OH2.
Would you mind providing more detail about what you have in mind? What else would I need in addition the REST API to address my need in your opinion?

You Python script may be able to access the REST API to get the information. I know there are some persistence addons for short term data storage but I have not used them personally.

You may want to look at using Jython for your rules since you already know Python. It is basically a java implementation of Python 2. @5iver can provide more details.

In Rules DSL you would have to store this information in separate Items, global variables, or text files. Or, you can manage Item metadata like this using the REST API like Bruce points out.

If using Scripted Automation, you can access, create, change, etc. Item metadata directly in your Rules. You can define static Item metadata on your Items when using .items files or through the REST API. You can’t add Item metadata through PaperUI.


1 Like

Thank you for your help. I will try this approach and get back to you guys if needed :wink:

You need to look further then! Easy installation and configuration of Jython and the helper libraries…

Documentation for core.metadata…

An example with a script that sets Item metadata…

1 Like