Help on developing a binding

Hi,
I would like to develop a binding for OH 2 that can accept a string as a parameter.
For example like the EXEC binding in OH1 that can accept a string that contains the command to be executed.
All the examples I have seen contain only channels and no other parameters.

My question are:

  1. how would I define this binding in the items file? From what I have understood, the binding configuration in OH2 accepts only the channel. So how can I write the item in the .item file with the string parameter? i.e. {channel=“newbinding:device:controller:item:channel” parameter1=“string”} ? will it work?
  2. Where will this string parameter be parsed (in which function) in my binding (I have started from the skeleton and the Astro binding)?

thanks

In OH 2 all the stuff that used to go between the { } is moved to Things. I would assume you would need to define that parameter in the Things file, not the Items file.

I don’t know coding of bindings so I can’t address 2.

Hi Rich,
so if I want to develop the EXEC binding in OH2, I will have to put the execution string in the things file?
This should go in the things file?:
exec="OFF:some command, ON:'some other\, more \'complex\' \\command\\ to execute', *:fallback command"

But this looks to me as an item configuration…
So what should go in the items file?

Yes, that is exactly where it goes.

The whole purpose for Things was to separate the binding configuration stuff from the Items to enable things like auto-discovery. In a purely OH 2 .items file, the only thing you will find between the { } for the Items is a channel="blah blah blah". All the stuff you have above goes in the .things file.

A Thing represents something in the real world (i.e. external to OH interacted with through a Binding).

A Channel represents one way to communicate with a Thing. There is one or more Channels per Thing and which channels are valid is defined by the binding.

An Item represents something that can be controlled or represented in OH in a standardized way. An Item gets bound to a Channel.

To take a real world example, here is one of my Network binding Things config:

network:device:richphone  [ hostname="192.168.1.103", port="0", retry="1", timeout="60000", use_system_ping="false", dhcplisten="false" ]

And the Item bound to the Online channel of that Thing:

Switch S_V_RichPhoneIP_Net "Moto X PE Network [%s]" { channel="network:device:richphone:online" }

In OH 2 the stuff that looks to you like Item configuration is now Thing configuration. The entire reason for Things is to separate binding specific stuff away from the Items.

The .items file maps Items to Channels and contains all the other stuff about an Item that OH cares about like label, icon, Item type, name, etc.