Binding development - item metadata / parameters

Hi,

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:

  1. dimmer
  2. relaistimer

Now I would like to define items like this:

Switch myDimmer { channel=“bindingname:module1:dimmer [ ramp=3s ]” }
Switch myRelaistimer1 { channel=“bindingname:module1:relaistimer [ duration=5m ]” }
Switch myRelaistimer2 { channel=“bindingname:module1:relaistimer [ duration=30s ]” }

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).

Any help would be very appreciated!

You could use a ThingAction from a rule instead of item link parameters.

Thanks for your feedback, I will give it a try.

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:

  1. 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.

  2. 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.

  3. For which purpose and how should item metdata definition be used?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.