I am trying to develop a new binding and I am wondering what would be the correct/best way to accomplish the following task:
A device is able to dim lights with a given ramp (“acceleration of dimming”). Furthermore the device has a function to switch off a relais after a given period of time (after switching the relais on).
So I’ve defined a thing with - among others - the following channels:
I’ve found documentation of item metadata definition (https://www.openhab.org/docs/concepts/items.html) but I have no clue, if this is the right way to accomplish above task and how to access the metadata from my binding / ThingHandler.handleCommand().
I have used channel configuration before but in this case I need to be able to configure the item/channel-linking not the channel itself (see myRelaistimer1 and myRelaistimer2).
But I think I have still problems to get the concepts right. From the documentation:
Things are the entities that can physically be added to a system and which can potentially provide many functionalities in one.
Channels represent the different functions the Thing provides
Items represent functionality that is used by the application
Action: Quite often the device or service you expose via openHAB Things allows certain actions to be performed.
Questions that come to mind:
What’s the difference between channels and actions? For me it looks like actions (ThingActions) reveal functionalities encapsulated in a thing (handler) to be used by rules - without the need to go through items/channels. So actions trigger functions of a thing. But if I use actions and rules in the example above - leading to a “dump” switch item with no channel binding if i understood it correctly - in my opinion it would - contrary to their conceptual design - “decouple” items and channels and “break” encapsulation of the thing’s (thing handler’s) functionality.
Shouldn’t dimmer and relaistimer from the example in the first post not be modelled as channels - with the ability to provide the parameters needed by the things functionality/channel at item definition level - preserving encapsulation of responsibilities? From my understanding: Item gets switched on/off in the application, event is send (with the parameter/payload defined in the items file) through a channel to the thing where it is transformed by ThingHandler to a command send to the (physical or logical) device.
For which purpose and how should item metdata definition be used?