@5iver, as I am building out my above first production use case I ran into two enhancements for Area Triggers and Actions:
- Anti-flapping support for lux item
As I have my lux item connected to an actual light sensor I typically see it change up and down around the threshold a number of times before it gets dark enough to be consistently below the threshold. This results in lights going on and off respectively. Anti-flapping solutions have been widely discussed (e.g. Design Pattern: Motion Sensor Timer). Since I found my lux item to flap over an extended amount of time (tens of minutes) I am suggesting a buffer based protection rather than a timer based one. A configurable threshold buffer (default 0) is added on either side of the threshold - only a breach of the threshold plus/minus the buffer triggers a lux event. If reading variations stay within 2x the buffer there is no flapping. A timer could be a nice complementary future addition (would allow to narrow the buffer as the timer runs). - Manual override
You implemented manual overrides by special casing state 99/100 and leaving a light in that state unchanged, which is very elegant due to its simplicity. However, I would like the user to be able to optionally pick any dimmer level and honor that as the override. This (along with any generic override use case) can simply be achieved by introducing an override item (similar to the lux item) - if set it overrides the usual brightness calculation. I also made the 99/100 override configurable with default to on for backwards compatibility when the 99/100 override is not the ideal solution (I think off would actually be a more intuitive default, where the user gets no override by default and can chose to turn on overrides using the 99/100 approach or an explicit override item. But that would of course break backwards compatibility - would you be open to that change?)
I will submit a PR for these two proposals shortly (I put them into a single PR hoping that would make it easier for you or do you prefer one PR per topic?). Note that I refactored light_action in the process to remove some duplicated code and added graceful handling when items are NULL (which I ran into at various times).
As a side note: I will also submit a PR to supply override items in OccupancyManager to work in conjunction with the Area Triggers and Actions overrides.
Let me know what you think!