Extended Motion Sensor Rule: any Suggestions?

I haven’t looked at your code closely yet, but in my much simpler system (I’ve only switches, no dimmers) I handle this with manual trigger detection and an override flag. If the light is changed manually, that light get’s excluded from all automations until the next time of day period (though that could be adjusted to some other event). In my Rules DSL version the override flag is an Item using Associated Items DP. In my JSR223 version I use metadata.

@openhabber, see [Deprecated] Design Pattern: Motion Sensor Timer for an example. With JSR223 I’ve submitted a module that should make managing these timers a bit simpler as well. See Timer Manager by rkoshak · Pull Request #233 · openhab-scripters/openhab-helper-libraries · GitHub.

In the OP you asked for something you just need to configure rather than needing to code from scratch. JSR223 is pretty much your only option for that right now which is why we are all pushing that as an approach.

I know you and Scott have seen this, I’m just posting this example for future readers.

from core.rules import rule
from core.triggers import when
from time import sleep
from core.metadata import get_key_value, set_metadata
from core.actions import PersistenceExtensions
from org.joda.time import DateTime

@rule("Cloudy Lights",
      description="Turns ON or OFF some lights when it is cloudy during the day",
      tags=["lights"])
@when("Item vIsCloudy changed")
@when("Item vTimeOfDay changed")
def cloudy_lights(event):
    if (items["vTimeOfDay"] != StringType("DAY") or
        isinstance(items["vIsCloudy"], UnDefType)):
        return

    if event.itemName == "vTimeOfDay":
        sleep(0.5)

    cloudy_lights.log.info("It is {} and cloudy changed: {}"
                           .format(items["vTimeOfDay"], items["vIsCloudy"]))

    for light in [light for light in ir.getItem("gLights_ON_WEATHER").members if get_key_value(light.name, "Flags", "override") != ON]:
#   for light in filter(lambda light: get_key_value(light.name, "Flags", "override") != "ON", ir.getItem("gLights_ON_WEATHER").members):
        if items[light.name] != items["vIsCloudy"]:
            events.sendCommand(light, items["vIsCloudy"])

@rule("Lights Override",
      description=("Sets the Override flag when a light is manually changed "
                   "during the day"),
      tags=["lights"])
@when("Member of gLights_ON_WEATHER changed")
def override_lights(event):
    sleep(0.5) # Give pesistence a chance to catch up

    # Wait a minute before reacting after vTimeOfDay changes, ignore all other
    # times of day.
    if (items["vTimeOfDay"] != StringType("DAY") or
        (PersistenceExtensions.lastUpdate(ir.getItem("vTimeOfDay"), "mapdb")
            .isAfter(DateTime.now().minusSeconds(10)))):
        return

    if (not PersistenceExtensions.lastUpdate(ir.getItem("vIsCloudy"), "mapdb")
            .isAfter(DateTime.now().minusSeconds(5))):
        override_lights.log.info("Manual light trigger detected, overriding the"
                                 " light for auto control for {}."
                                 .format(event.itemName)))
        set_metadata(event.itemName, "Flags", { "override" : "ON" },
                     overwrite=False)

@rule("Reset Override",
      description="Change override flag when time of day changes",
      tags=["lights"])
@when("Item vTimeOfDay changed")
def reset_overrides(event):
    for light in ir.getItem("gLights_ON_WEATHER").members:
        set_metadata(light.name, "Flags", { "override" : "OFF" },
                     overwrite=False)

The Rules DSL version is a combination of Design Pattern: State Machine Driven Groups and Design Pattern: Manual Trigger Detection.