Override automation based on context of lights


after hours of RTFM i got stuck. Hope you can help me out and point me into the right direction. I am trying to check within an automation if any of the (potentially affected) devices have been somewhat changed beforehand by another automation or user.

Use Case:
Jane enters a room, the lights are turned on automatically by an automation rule. She logs into Lovelace and dims the light. A couple of minutes later, she is moving which is picked up by the motion sensors and triggers the initial automation. This automation would reset all lights and thus “override” Jane’s custom setting.

My research brought me to the conclusion that having a condition that checks for ?.to_state.context.user_id, might be the right direction.

How can I check within an automation if any related light has been changed manually recently before I substantially turn/dim/change the lights via actions.

Automation YAML

alias: EG Wohnen - Licht an bei Bewegung (bei Tag)
description: ""
  - type: motion
    platform: device
    device_id: f98f0c92fc70451ca0b9406f27b24530
    entity_id: binary_sensor.bewegungsmelder_lautsprecher_occupancy
    domain: binary_sensor
  - type: motion
    platform: device
    device_id: 1c07b571a3b744440e1e924b6966bcfa
    entity_id: binary_sensor.bewegungsmelder_kuhlschrank_occupancy
    domain: binary_sensor
  - condition: state
    entity_id: input_boolean.kinomodus
    state: "off"
  - scene: scene.wohnzimmer_hell
  - service: automation.trigger
      entity_id: automation.wz_morgens_und_abends_kuchenlicht
      skip_condition: false
mode: single

No guarantees but try checking trigger.from_state.context.user_id (note the from_state as opposed to to_state).

FWIW, I do this a bit differently. Upon entering the room (shortly before sunset to sunrise) the light is automatically turned on to a specific brightness level. The level depends on the time of day (brighter in the evening and dimmer late at night). If the person manually changes the brightness level (using the physical switch, via the UI, or a voice command), the automation suspends all motion-related brightness adjustment for 20 minutes. So for 20 minutes the user’s preferred brightness level remains in effect.

The automation doesn’t concern itself with who did it. It simply detects the brightness was changed from its preset level and that’s sufficient for it to know someone performed an ‘override’ (and then leaves it at the new level for 20 minutes).