Last year I made a small experiment with resulted in a post on with same title on Eclipse SmartHome forums. Since we’re now, openhab-core took place of ESH framework part, and OH3 is around the corner, I would like to bring the issue back to you and revisit it.
Making long story short - over Christmas 2018 I did an exercise with a non-core Type
necessary for one of “my” bindings. Because BACnet is quite extensive on the type and command layer and some structures can not be mapped to openHAB I wanted to see if I will be able to supply a List
or Calendar
object which exists there. It is currently not possible due to reason listed below.
On the command level - BACnet supports prioritization of commands meaning that beside ON
or OFF
value there is an additional piece of information (1..16
). Obviously I could try to create 15 item types with additional property on the each and every commandable channel for every BACnet point but as you can imagine, this would result in a mess of unbelievable scale. This also falls close to a toggle command and other binding-specific commands reached in Profile types topic which eventually reached also to the command kinds.
I narrowed the issue to one element which currently locks extensibility of that part of framework and it is the TypeParser
.
Currently org.openhab.core.types.TypeParser
is a static helper class with documentation stating that “This is a helper class that helps parsing a string into an openHAB type”. I traced usage of it and currently there are ~60 calls of it, mainly from openhab-core and several bindings (modbus, mqtt, oceanic, smartmeter, neeo, openhabcloud, rules, persistence, rest).
It is not a huge amount of calls to be fair and it is manageable to clarify these. It is also possible to at least provide non-invasive way for provisioning of new types by keeping signature of TypeParser
but delegating actual parsing logic to OSGi service layer.
The big question is, what is the @architecture-council look on that. There is limited use of new types, yet currently framework part is locked down. As per Kai answer in origin thread:
When the type system had been introduced 9 years ago, its originally idea was to be extensible.
But due to many different reasons, this never worked out and the type system since then became a static part of the core framework and is not meant to be extended.
Sadly I need this part in order to get proper support for BACnet. I failed to get it onto openHAB 2.x a while ago, the 1.x binding is stuck on basic elements (binary, analog, multistate inputs and outputs) while I been asked several times about support for complex objects.
I know that many things rely on existing types and I acknowledge that a new third party type won’t be handled equally as a core one. At the same time I don’t want to open a Pandora box where every binding brings its own types.
I appreciate your feedback and input to further discussion.