Dining room ceiling light on wired-in dimmer. Then a motion sensor, and some rule-machine rules to turn on the dining room lights if somebody moves there, turn them off after a while of nobody moving.
Unintended consequences: Lights turn out while we're sitting down at dinner! (I guess nobody moved quite enough for a little while.)
I've sort-of fixed this by turning off the auto turn-off (so we have to remember to turn the lights off with the wall switch, even if they were turned on by the motion detector). Other possible fixes are more sensors (for better coverage of the whole room) and a longer motion timeout (so that the odds of sitting still that long if you're in the room are reduced). Obviously waving your arms energetically will at least temporarily fix the problem if it does happen
I'd like a more general solution -- specifically, I'd like the lights to turn off on motion timing out if and only if they were turned on by motion in the first place. So if I turn the lights on with the switch they stay on, but if they are turned on by the motion sensor they turn off when motion has stopped for a while. This needs to generalize to multiple lights and multiple switches, too.
Obviously there are eleventy-one different ways to write Rule Machine code for this, different options everywhere, etc. I'm not so much looking for specific rules to do it, as for how people are in general approaching this sort of problem. Local variables for each zone being controlled, or something?
How does this interact with things like a house-wide all lights off or all lights on function? (Like the old X-10 builtins; seems like a useful security feature, if I think there's an intruder I might well want to turn on every single light; if I know there's an intruder I might want to turn OFF every single light, figuring I know my house better than they do.) A security lights-out should override the motion sensor setups.