Smart Auto/Manual Override Strategy for Automations with Self-Healing Timer

Hi everyone,

I wanted to share a robust Auto/Manual Override strategy that I designed for my roller shutters, screens, and lighting. It solves the classic smart-home frustration where a human manually adjusts a device, only for an automation to overwrite it a few minutes later.

This setup uses two simple concepts: Context-Aware Overrides and an Automatic Self-Healing Timer.

The Core Features:

  1. Zero Dashboard Clutter (Invisible Trigger): It uses Home Assistant’s built-in context.user_id. The system automatically detects if a device was moved by a human finger (app/wall switch) vs. an automation backend.
  2. True Manual Lock: The moment a human triggers the device, a dashboard dropdown (input_select) flips to "Manual", completely freezing all background automation logic (weather, sun, timers).
  3. Self-Healing Timer: It starts a physical 2-hour helper timer. When the timer expires, the system automatically switches back to "Auto" and immediately triggers a sync to calculate the correct state of the house based on current sensor values (sun position, wind, rain).
    4
    Step 1: Create the Helpers

Create an input_select and a timer via Settings -> Device & Services -> Helpers:

  • Dropdown (input_select.shutter_mode): Options: Auto, Manual
  • Timer (timer.shutter_manual_lock): Duration: 02:00:00

Step 2: The "Invisible Controller" Automation

This lightweight automation manages the manual lock state and the timer. It safely ignores any changes made by the system itself.

alias: "Mode Manager: Shutter Manual Lock"
description: "Flips state to Manual on human intervention and starts a 2-hour self-healing timer."
mode: restart
triggers:
  - trigger: state
    entity_id: cover.living_room_shutter
    id: shutter_moved
  - trigger: state
    entity_id: timer.shutter_manual_lock
    to: idle
    id: timer_expired
actions:
  - choose:
      # SITUATION 1: Shutter was moved manually by a USER
      - conditions:
          - condition: trigger
            id: shutter_moved
          - condition: template
            value_template: "{{ trigger.to_state.context.user_id is not none }}"
        sequence:
          - action: input_select.select_option
            data:
              option: Manual
            target:
              entity_id: input_select.shutter_mode
          - action: timer.start
            target:
              entity_id: timer.shutter_manual_lock

      # SITUATION 2: 2-Hour Timer Expired -> Return to Auto Mode
      - conditions:
          - condition: trigger
            id: timer_expired
        sequence:
          - action: input_select.select_option
            data:
              option: Auto
            target:
              entity_id: input_select.shutter_mode

Step 3: Protect your Main Automation

In your main shutter/lighting automation, add a global condition at the very top. Also, add a trigger that listens to the mode switching back to Auto so it instantly recovers its target position!

alias: "Main Shutter Logic"
triggers:
  - trigger: sun
    event: sunset
  # CRITICAL: Trigger immediately when mode restores to Auto to catch up on state changes!
  - trigger: state
    entity_id: input_select.shutter_mode
    to: Auto
conditions:
  # GLOBAL LOCK: Drop out immediately if human operator took control
  - condition: state
    entity_id: input_select.shutter_mode
    state: Auto
actions:
  - choose:
      # Your existing weather, sun, time logic options go here...

Why this approach :

  • No messy templates inside your device actions.
  • It survives Home Assistant restarts because it uses a physical timer entity instead of a script delay.
  • Highly scalable: You can group all your home's manual overrides into a single central "Interlock Manager" automation using a choose block for shutters, screens, and dimmers.

Let me know what you think or if you want to convert this into a blueprint!


And then sliders to adjust the length of the timer as well as drop-downs for permanent vs. temporary override etc...

using the same principle in my automation. plus: if double click of switch permanent disable

How do I differentiate between "an automation triggered the shutter", "a user triggered the shutter inside Home assistant Lovelace" and "a user used the manuell Control for the shutter"?

Hi! It is actually very simple. Home Assistant checks the "logbook" (the context object) of the trigger to see who or what started the chain:

  1. Automation: Home Assistant registers a parent_id (pointing to the automation), but no user profile is attached.
  2. Dashboard / App click: Home Assistant registers the unique user_id of the logged-in person who clicked the button.
  3. Physical wall switch: The motor suddenly starts moving without an HA user or an HA automation triggering it. In this case, both IDs are completely empty.

Tip: If you want your manual lock to trigger on all human input (both dashboard clicks and physical switches), you just need to check if it wasn't an automation: trigger.to_state.context.parent_id is none.

  1. Triggered by an Automation
condition: template
value_template: "{{ trigger.to_state.context.parent_id is not none }}"
  1. Triggered via Dashboard / App click
condition: template
value_template: "{{ trigger.to_state.context.user_id is not none and trigger.to_state.context.parent_id is none }}"
  1. Triggered via Physical Wall Switch
condition: template
value_template: "{{ trigger.to_state.context.user_id is none and trigger.to_state.context.parent_id is none }}"

If you want your manual lock to trigger on all human input (both dashboard clicks AND physical wall switches), you just need to check if it wasn't caused by an automation

condition: template
value_template: "{{ trigger.to_state.context.parent_id is none }}"

1 Like

Exactly! Those are great ideas for extending this into a full Blueprint.

Adding an input_number slider would make the timer duration completely customizable right from the dashboard. And a toggle for "Permanent vs. Temporary" override would give you total control for situations like a backyard party where you want the shutters to stay open all night without self-healing.

For my own setup, I kept it simple and rock-solid with a fixed 2-hour helper timer, but these additions would definitely make it a universal solution for the community!