Light automation (presence) with LUX override and Movie mode - whats the best way to achieve this?

So, im looking to automate my living room lights, and im looking for some advice and help if anyone has achieved something similar. Ideally point me in a direction of a blueprint if any exists so i do not need to manually create this automation.

What i have:

  • Occupancy entity
  • Lights entity
  • Illumination entity (LUX level)
  • Input boolean (Movie mode) - toggled by a button
  • Media player entity (showing if im watching something or not on the TV)

What i want to happen:

  • Lights turn on/off based on occupancy (+ some small delay for off): 100% brightness
  • LUX level affects lights on/off (assuming occupancy is on):
    • if LUX above 50, lights do not turn on
    • if lights are on, and LUX level increases above 50, lights will turn off immediately (eg: someone opens the curtains)
    • if lights are off (due to LUX being too high), and LUX decreases below 50, lights turn on immediately (eg: closing curtains).
  • if/when movie mode is enabled (also assuming occupancy, and also affected by LUX level above):
    • by default, the lights are on at 50% brightness
    • if something is playing on media player, lights turn off
    • if something stops playing, lights go back to 50% brightness

Any help appreciated. I would prefer not to reinvent the wheel, so working with an existing blueprint would be ideal. Happy to have multiple automations to achieve this as well.