Run automation only when there is a user or dimm switch device that turns on a light

Hello,

i tried to stop my automations from running when my motion sensor triggers my light in a automation.
But my dimmer switch and the UI (a user) should trigger my automation.
Only a automation should not trigger all others can trigger.

i tried it with this condition

             - condition: and
            conditions:
              - condition: trigger
                id: light_off
              - condition: template
                value_template: "{{ trigger.to_state.context.user_id is defined  }}"
              - condition: template
                value_template: "{{ trigger.to_state.context.id != none }}"
              - condition: template
                value_template: "{{ trigger.to_state.context.parent_id == none }}"
              - condition: template
                value_template: "{{ trigger.to_state.context.user_id != none }}"

but i have no luck, has perhaps someone a idea?

Thank you