openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 70 forks source link

class to make using item metadata easier #61

Closed mjcumming closed 5 years ago

mjcumming commented 5 years ago

Proposed class to make using item metadata easier. Class is designed to work with a single metadata namespace. Provides methods to read/write the Value for the namespace and the Configuration (key/value) pairs for the namespace.

Thoughts?

smhgit commented 5 years ago

@mjcumming

Have you thought of adding namespace manipulation functions to the class, such as:

set_namespace - change item namespace context
namespaces - list of all item namespaces
delete_namespace - delete existing namespace

This also means that constructor can have only item name

mjcumming commented 5 years ago

Yes, was thinking about how to best approach that.

In my use case, I am always interacting with an single namespace of an item. It keeps the complexity of working with metadata lower. Having to set the namespace context could be problematic. The methods could be modified to always require a namespace.

The existing class does allow for deletion (remove) of the namespace.

I can’t think of any use case where one would want to enumerate all of the namespaces of an item?

From: Eyalmailto:notifications@github.com Sent: Sunday, December 30, 2018 4:36 PM To: OH-Jython-Scripters/openhab2-jythonmailto:openhab2-jython@noreply.github.com Cc: Michael Cummingmailto:mike@4831.com; Mentionmailto:mention@noreply.github.com Subject: Re: [OH-Jython-Scripters/openhab2-jython] class to make using item metadata easier (#61)

@mjcumminghttps://github.com/mjcumming

Have you thought of adding namespace manipulation functions to the class, such as:

set_namespace - change item namespace context

namespaces - list of all item namespaces

delete_namespace - delete existing namespace

This also means that constructor can have only item name

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/OH-Jython-Scripters/openhab2-jython/pull/61#issuecomment-450591525, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABRMCAXARdyGNDlxznP5SYfQ12jRn45jks5u-UAFgaJpZM4Zkq0u.

smhgit commented 5 years ago

@mjcumming

I agree that there is no immediate use for namespace functionality, so it can be postponed until real need.

Just to clarify, you don't need a name space in each function, the set_namespace function was for that purpose, to switch namespace, the functions should continue to work as they are.

mjcumming commented 5 years ago

@openhab-5iver, this is ready to merge unless there are any concerns.

smhgit commented 5 years ago

Any plans to merge it?

5iver commented 5 years ago

@mjcumming, are you OK with me closing this, as it looks like everything is in #88?

mjcumming commented 5 years ago

It's been too long for me to remember the difference between then. My occupy code is this so it works for it's purpose .