Ignoring motion sensor once I use the light switch

I have a sonoff R4 which I use with an Aqara motion sensor to turn off/on lights. My goal is to ignore the motion sensor automation if I use the manual switch (connected to the R4).

Something like: “if I use turn on the lights with switch, don’t turn them off after no-motion delay (say 3 minutes after undetected movement).”

The motion sensor behavior would go back to usual once I turn off the lights manually with the switch again…which maybe would turn them on again instantly after because of motion detected, I guess? Maybe I am missing some implications and conflicts, but I wanted to know if this possible

Here’s one way:

  1. Create a helper called something like input_boolean.switch_turned_on_manually
  2. Create a script (for the on button) to turn on both the light and the helper.
  3. Create another script (for the off button) to turn off both the light and the helper.
  4. Automate the button to use those scripts.
  5. Use a condition in the motion sensor automation to check: (a) input_boolean.switch_turned_on_manually is off and (b) the off script was run at least x seconds ago (to avoid the motion switching the light on per your last point).

I use this triggered template sensor to determine what turned the light on

- trigger:
    - platform: state
      entity_id: light.lichtkeuken
      to: "on"
  sensor:
    - name: "Keuken Licht On Context"
      unique_id: '018e8402-759b-761b-bf24-272b807826e6'
      state: >
          {% set c_id = trigger.to_state.context.id %}
          {% set c_parent = trigger.to_state.context.parent_id %}
          {% set c_user = trigger.to_state.context.user_id %}
          {% if c_id != none and c_parent == none and c_user == none %}
            physical
          {% elif c_id != none and c_parent == none and c_user != none %}
            dashboard_ui
          {% elif c_id != none and c_parent != none and c_user == none %}
            automation
          {% else %}
            unknown
          {% endif %}
1 Like