Modelling a double switch and some semantic questions


I just upgraded to OH 3 and really like the new UI, thanks everyone involved for the great work!

I decided to start from scratch again with the setup and I’m running into some semantic problems I’m not sure how to solve correctly. Perhaps someone here can guide me…

  1. I’ve got z-wave switches, mounted behind the mechanical switch, I started out with category and semantic class “Lightbulb” but later I noticed there’s also a “Wallswitch” category and a “WallSwitch” semantic class. Does it matter? When would one pick one over the other?

  2. I’ve got a few double light switches, that control light sources in different rooms, for instance, in the room leading to the cellar there’s a double switch that controls the light in that room as well as the light in the cellar, I’m not able to “split” that thing in my model so now I have “Cellar” -> “Cellar Light Switch” -> two switch items for both rooms, semantically not correct, technically maybe. How am I intended to model this? Same goes for garden lights where a double switch controls driveway and terrace etc.

  3. Item naming. In OH2 I found that the best naming convention was to include the location in the label, so for instance “Bathroom Ceiling Lights” for the switch channel on the thing, if I remember correctly I did that for the iPhone app and the Alexa binding. Is it still advised to do this? The reason I’m asking is if I do get around to adding Alexa support I want to for instance be able to say “Alexa turn on the bathroom ceiling lights”, will it now be smart enough to extract that from the model hierarchy if the item is just labelled “switch”?


For 2. I realized you can just create a new “group” and add some of the items there. I tried using “Create Equipment from Thing” which merged the groups when done multiple times.

Not all walls witches control lights and not all lights are controlled by wall switches. The model gives you the flexibility to handle both situations. It doesn’t really matter what you choose so long as you are consistent.

Again, there’s is no real right or wrong way. You can’t have the same equipment or point in more than one location so I would do one of the following:

  • only add one of the two switches to the model and put it in the location where the light is.

  • model both switches as separate equipment and put them each in the different rooms.

I’d most likely choose the first one must of the time because I’d have modeled the Lights as the equipment and the switch’s as points on the equipment.

Thanks Rich,

I made them all lightbulbs for now, somehow it feels more natural even though technically they are switches. I also realized, like you said, that it doesn’t matter at the moment.

Being a developer I tend to over analyze these type of choices, and it’s not entirely clear how and where the model is used by the system apart from navigating the UI. I guess my initial worry was that if I get around to adding something like the Amazon Alexa binding in the future It’d come down to a choice between enabling “Alexa turn on the bathroom lights” vs “Alexa turn on the bathroom switch”.

Regarding item labelling, I read somewhere that the Alexa binding relies on the item labels so I guess I have to keep labelling my items with the complete location, i.e. “Second Floor Bathroom Lights”. It would have been nice to just name it “Lights” and put it in the “Bathroom” group in the “Second Floor” group. Putting the location in the label also makes it a whole lot easier to navigate the flat item listing.

By the way, a big thanks Rich for the javascript guides, I’ve successfully converted my old 1000 line .rules file into 12 rules entirely setup in the UI. :slight_smile: