Store a configurable custom value with an item

A few days ago I posted a description of my recently configured heating switch. I would like to extend that to multiple switches with a different mapping each.

Is there a way to configure the mapping on a by switch basis? Storing the name of the mapping as part of the item would help.

This is exactly what item metadata is for. In addition to all the standard metadata namespaces that you see when you click on the Add Metadata button in the item details page, at the bottom of that list is an option to add your own custom metadata namespace. So, you can create your own namespace such as HeatingSwitch and store that extra information there either as a single value, or as a more complex yaml (and therefore, JSON) configuration.

Checking your heating switch post quickly, however, there’s one problem with this approach. It used to be the case, if I recall, that the rulsDSL did not have access to item metadata. I don’t know if that’s been changed. But to use the item metadata you may have to move your switch function to one of the more modern and capable scripting languages like JRuby or Javascript.

Thanks, I would hate to move away from the DSL because I like it. But it is of course an option.

Ah, semantic actions might do it.