Default dynamic properties in xml config files

Hello,

I am working on a binding, and I would like to create an xml configuration file that has dynamic default property values.

Specifically, I would like to have a configuration parameter “filename” , and i would like the filename to be the thing UID.

Is there a way to accomplish this?

Thanks

I don‘t understand what you are trying to achieve. Can you shortly describe what the binding does and why there should be a config parameter that is the thing UID?

Hello @J-N-K , thanks for looking at this!

I am trying to prepare the following binding for a PR:

https://github.com/themillhousegroup/openhab2-addons

This is a binding to control Broadlink devices.

Some broadlink devices are actually IR blasters. Their configuration includes a file that contains IR codes that can be sent to remote control devices.

In the last PR request for this binding, the following was requested (https://github.com/openhab/openhab-addons/pull/11049):

Also consider what happens if someone has multiple things, hence the suggestion to use the Unique ID of the thing in the filename or a sub folder, whatever makes sense.

So the idea is that on thing discovery or configuration, the default name of the file that contains IR commands is the thing UID. but for that, i would need to define this in:

Currently the default file name is set statically as “broadlink.map”. I would like for de default file name to be “thingUID.map”

Hopefully that makes more sense?

Thanks!

Why don‘t you make the parameter optional and if it is not set generate a default file name in the thing handler? You can easily get the thing UID there - there is even a method in core that allows to encode a UID in a way that it can be used as a file ame (the : is not allowed on Windows systems).

Hey @J-N-K ,

Yes, that sounds like it is a great idea,. I just got curious to see if i could expose thing attributes in the config.xml files, since it sounds like a very easy way to do it.

Sorry if this is too basic, but i am just learning the ropes. You point me to the right direction though, appreciate it!

Hey again @J-N-K ,

Do you happen to remember the name of method that encodes the thing UID to a compliant file name string? I have been looking for a bit, and see a number of methods that return the UID as string or convert to string, but nothing that would specifically state encoding using OS safe characters.

Thanks