Need tips and advice for a blueprint For a "kill Switch" for motion sensor

Hi, sometimes my motion sensor turns on or off my light, but I would prefer it not to. So, I created a blueprint that turns off my motion sensor automation for an hour when I manually change the light after a specific automation trigger. However, it’s not perfect. Sometimes it disables automation even if I did not manually change the status of the light. I know I could use a timer too, but I don’t want to have to create a timer for every automation.

Here is my code. Any advice would be appreciated.

blueprint:
  name: Disable Automation After Light Change
  description: Disable automation for a period after a light change.
  domain: automation
  input:
    automation_entity:
      name: Automation Entity
      description: The automation entity to control.
      selector:
        entity:
          domain: automation

    light_entity:
      name: Light Entity
      description: The light entity to monitor for changes.
      selector:
        entity:
          domain:
            - light
            - switch
            - group

    disable_duration:
      name: Disable Duration
      description: Duration to disable the automation after the light change (in minutes).
      default: 5
      selector:
        number:
          min: 1
          max: 60
          unit_of_measurement: minutes

trigger:
  - platform: state
    entity_id: !input "light_entity"

variables:
  disable_duration: !input "disable_duration"
  automation_entity: !input "automation_entity"

condition:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: template
            value_template: "{{ trigger.to_state.context.parent_id == none }}"
          - condition: template
            value_template: "{{ trigger.to_state.context.user_id == none }}"
          - condition: template
            value_template: "{{ trigger.to_state.context.id != none }}"
          - condition: template
            value_template: >-
              {{ state_attr(automation_entity, 'last_triggered') is defined and now() - state_attr(automation_entity, 'last_triggered') < timedelta(minutes=disable_duration) }}

      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: template
                value_template: "{{ trigger.to_state.context.parent_id == none }}"
              - condition: template
                value_template: "{{ trigger.to_state.context.user_id != none }}"
              - condition: template
                value_template: "{{ trigger.to_state.context.id != none }}"
              - condition: template
                value_template: >-
                  {{ state_attr(automation_entity, 'last_triggered') is defined and now() - state_attr(automation_entity, 'last_triggered') < timedelta(minutes=disable_duration) }}

action:
  - service: automation.turn_off
    target:
      entity_id: !input "automation_entity"
    data:
      stop_actions: true
  - delay: "00:{{ '{:02}'.format(disable_duration) }}:00"
  - service: automation.turn_on
    target:
      entity_id: !input "automation_entity"

mode: restart

For info this is an exemple of an automation that I “kill”

alias: Mudroom - Light - Motion
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.presence_sensor_fp2_46ca_presence_sensor_3
    to: null
condition:
  - condition: state
    entity_id: group.couple
    state: home
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.presence_sensor_fp2_46ca_presence_sensor_3
            state: "off"
            for:
              hours: 0
              minutes: 5
              seconds: 0
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.60357018dc4f2261b9b1
            data: {}
      - conditions:
          - condition: state
            entity_id: binary_sensor.presence_sensor_fp2_46ca_presence_sensor_3
            state: "on"
            for:
              hours: 0
              minutes: 0
              seconds: 0
        sequence:
          - service: light.turn_on
            target:
              entity_id:
                - light.60357018dc4f2261b9b1
            data: {}
mode: single

Finally, here’s a reference for how I manage to determine if an entity is triggered manually or by an automation:

https://community.home-assistant.io/t/work-with-triggered-by-in-automations/400352/9

The or condition has no effect like that. It will only affect what is below it, and below it there is only 1 and statement to pick from.
If you want to or both of those and statements, the or has to be first.

You mean i should put it as a trigger ?

condition:
  - condition: or            # good
    conditions:
      - condition: and
...
      - condition: or        # This one doesn't do anything...
        conditions:
          - condition: and
...

The second or is not doing what you think it’s doing…

oh … Because I have it working an an other automation for only physical activation. but for that automation i need it to trigger fot physical activation AND ui activation

if you check this code i need to confirm that the light entity is NOT trigger by an automation. could i just change the condition to NOT instead ?

...
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.to_state.context.parent_id == none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.user_id == none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.id != none }}'
        sequence:
          - service: notify.notify
            data:
              title: Likely Physical switched
              message: 'ParentID: None || UserID: None || ID: CONTENT'
      - conditions:
          - condition: template
            value_template: '{{ trigger.to_state.context.parent_id != none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.user_id == none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.id != none }}'
        sequence:
          - service: notify.notify
            data:
              title: Likely Automation switched
              message: 'ParentID: CONTENT || UserID: None || ID: CONTENT'
      - conditions:
          - condition: template
            value_template: '{{ trigger.to_state.context.parent_id == none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.user_id != none }}'
          - condition: template
            value_template: '{{ trigger.to_state.context.id != none }}'
        sequence:
          - service: notify.notify
            data:
              title: Likely UI switched
              message: 'ParentID: None || UserID: CONTENT || ID: CONTENT'

You can try anything you like. I don’t really write code for people.

My point was that the 2nd ‘or’ is 'or’ing an ‘and’ statement to nothing, so the 2nd 'or 'statement isn’t doing anything.