Template file for items

Hello everybody,

is it possible to create a template file for items and basic groups and do the mapping afterwards in an other .items file?

This could be the template:

Group Multimediasystem
Switch TV_Power "TV Power" <switch> (Multimediasystem) { mqtt=">[MQRabbit:home/TV/power:command:ON:1], >[MQRabbit:home/TV/power:command:OFF:0]" }
String TV_Program "TV Program [%s]" (Multimediasystem) { mqtt="<[MQRabbit:home/TV/program:state:default]" }

Group Alarmsystem
Switch Alarmsystem_Status "Alarmsystem" <switch> (Alarmsystem) { mqtt=">[MQRabbit:home/alarmsystem:command:ON:1], >[MQRabbit:home/alarmsystem:command:OFF:0]" }
String Alarmsystem_Alarm "Alarm [%s]" <alarm> (Alarmsystem) { mqtt="<[MQRabbit:home/alarm:state:default]" }

And this the other .items file where the mapping happens:

Group Groundfloor
Group Multimediasystem (Groundfloor)
Group Alarmsystem (Groundfloor)

Like the separation from declaration and definition in classic c-programming.


I used this too. It is partly working. But if you change an item and the group definition is in the other file, not at every circumstance the group is correct at the end. some times you have to restart OH

I will now merge all my item-files to one. More reliable.

The big thing op wants to do that is not allowed is to split the definition of the same item (in this case his Groups) across multiple files. This is not allowed. The second time the same Item or Group is seen it will be treated as a duplicate.

Indeed, you can have an Item be a member of a Group defined in another file. And yes, the bug where changing group membership doesn’t always apply until you restart OH had not yet been fixed as far as I’m aware. I’m not certain putting everything in one file will about that bug though. If it does let us know.