This is a pretty common use case now, many people have a motion sensor set to automatically turn the lights off after inactivity, but they want the manual wall switch to override that rule.
I think the most common way to do this is with webcore, which is a very sophisticated rules engine developed by the community. They actually have their own forum now.
@anon36505037 might be able to say if there’s an existing topic there on this use case.