[SOLVED] Design Pattern recommendation

Though I’m new to OpenHab I’m trying to develop an interface to a Mitsubishi heatpump. My home is equipped with (count them) 6 head units and 2 compressors. So any work on one has to be replicated 6 times.

Normally you develop a class that encapsulate all the logic for a single pump and insatiate 6 times.

What is the right design pattern for implementing such a thing in openHab?

Probably this one

Look at Design Pattern: DRY, How Not to Repeat Yourself in Rules DSL. This DP will provide a few more techniques to avoid the duplicated code.

In this particular case the Associated Items DP and How to Structure a Rule DP will probably be the most useful to you in this case. You will obviously need to create Items for all your devices, but you likely will only need one Rule.

The Working with Groups in Rules DP is at a bit lower level and is used by these other DPs.

I was struggling a bit with using group to manage dissimilar properties of the same object - they seem more suited to handling set of similar objects.

The “Associated Items” DP solved it for me.

Thanks all.