Dynamic channel state mappings

Hi all,

I’m working on a binding for an A/V receiver that has a set of inputs and I’d like to be able to map the inputs to the actual device names. I can, of course, include this data in the “thing-types” configuration, however that’s a static mapping for all things created by the binding… not everyone will have a Roku on input 1.

Is there a way, or perhaps should there be a way to configure value mappings for a channel on a per-thing basis? ChannelTypeProvider seems like the entry point for this sort of thing, but I’m not sure how best to do that on a per-thing basis… especially since it seems like it ought to be simple to configure. Ideally the ultimate solution would be a way to configure via the thing configuration or to provide the mapping programmatically (if, for example, a thing was able to determine this by communicating with the device itself).

Anyone have any thoughts? I’m happy to do some legwork but not really sure what the best approach might be.

1 Like

Replying to myself here… I think that I have an idea how to do this now having built a custom property “configurator” for another binding. Just need to find some time to play around with an implementation… probably something simple like text box with a comma separated list of input names.

Hi Bill,

Are you aware of the Dynamic State Description provided by the framework? You can implement a DynamicStateDescriptionProvider which allows you to modify the state options for a channel (see Kodi for an example). Or does it not fit for your purpose?

1 Like

I’m using it for a A/V receiver binding (nadreveiver) as well and it is working Very well!

Yes, I think that’s just what I’ve been looking for. I’m not sure how I missed that before.

Thanks for the tip!

Hi Marc,

Believe it or not, I was looking for this feature specifically to allow naming the inputs on my NAD T175 receiver (I have a fork of a NAD binding from famake: https://bitbucket.org/hww3/org.openhab.binding.nadreceiver). My receiver only has a serial port so I added a serial to ethernet bridge and modified that binding to support either. Also fixed a few other problems along the way.

What a small world!

You are welcome. Sounds great. I hope you brought not want to keep it private. Rather turn it back to the community and contribute to the official openHAB 2 Add-ons repository. Would be very much appreciated.