I’ll add that coders tend to have the biggest problem with the Rules DSL. Unfortunately, the Rules DSL (i.e. .rules files) requires the developer to bend to it’s will instead of bending to the developer’s will. And it doesn’t use and/or poorly supports many concepts experienced coders use as second nature like classes, functions, etc.
Non-coders have a much easier time as they don’t have to bend at all. They can learn it the Rules DSL way the first time and there is a simplicity and lack of complexity in Rules DSL which makes it relatively easy for non-coders to get started with.
If you find yourself struggling I strongly recommend looking at JSR223 where you can code Rules using a more robust programming language like Jython, JavaScript, or Groovy.
If you decide to stick it out, read the Design Pattern posting. Most of the common situations you might encounter are covered.
Sounds reasonable. You might be interested in Generic Presence Detection which takes your concept a couple of steps further to include aggregating multiple sensors for presence and anti-flapping so the house doesn’t go into “away mode” when you leave for just a couple of minutes to get the mail. All in 40 lines of code (including blank lines).
The Next Gen Rules Engine will support something like this. For the Rules DSL you will have to add an if statement to all your Rules to check for the Switch and return; if it’s ON instead of running the rest.
Honestly, I don’t really see that much benefit in having this master switch for all Rules. I’d implement something more targeted, like one for Lighting, one for HVAC, etc. But I gotta say I don’t do anything like this either. I’ve never had a case where I wanted to turn off the Rules where I wasn’t there actively developing them in which case a simple comment/uncomment sufficed.
I actually recommend not starting with that DP. Instead start with something like Associated Items DP or the Generic Presence Detection tutorial I linked to above. It’s easier to understand when you can see how Groups can be used to solve a “real” problem than what amounts to a reference guide which the Working with Groups in Rule DP is. The other important ones I’d point you to is the Time Of Day and Separation of Behaviors DPs.