Motion driven rule, works mostly but fails when brightness is over 31

Try using the Expire binding for timer control, then checking the Dim value at timer expiration to conditionally turn light off or reset timer. Also see this thread – Automation/Orchestration Design Patterns