Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Created January 11, 2025 10:13
Show Gist options
  • Save Blackshome/993beed8b1c6ea29613b67f54d592456 to your computer and use it in GitHub Desktop.
Save Blackshome/993beed8b1c6ea29613b67f54d592456 to your computer and use it in GitHub Desktop.
manual-control-status-tracker.yaml
blueprint:
name: Manual Control Status Tracker
description: >
# ⏹️ Manual Control Status Tracker
**Version: 1.0**
🤔🔛 Who's in Control: Track the Entity, Know the Source.
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) 🙂
<details>
<summary><b>The Automation Process:</b> 👈</summary>
- **Actions:**
- Tracks if an entity is manually turned ON and OFF, updating the toggle helper to reflect the control method.
- If the entity is turned ON by an automation, the toggle helper remains unchanged.
- **Auto OFF Options:**
- Automatically turns off the target entity and toggle helper.
- Automatically turns off the toggle helper.
</details>
Need help?
- FAQ: [Click Here](https://community.home-assistant.io/t/826502/2)
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/826502)
domain: automation
input:
target_entities:
name: Target Entities To Track
description: >
Select the entities to monitor and determine if they are manually turned ON or OFF.
These entities will be tracked specifically for manual ON and OFF actions, distinguishing them from automation-driven changes.
These entities are typically lights or switches used in my other blueprints, allowing you to maintain manual control when turning them on manually.
selector:
entity:
multiple: true
filter:
domain:
- light
- switch
manual_tracking:
name: Manual Control Status - Toggle Helper
description: >
Select the entity to update when the target entity is manually turned ON or OFF, reflecting the manual control state.
This entity is typically a toggle helper, which you use in the bypass of my other blueprint in Option 3.
default: []
selector:
entity:
filter:
domain:
- input_boolean
include_auto_off:
name: Auto OFF Option (Optional)
description: >
Select if you would like to use the auto off option.
default: disable_auto_off
selector:
select:
options:
- label: Enable Auto OFF - Target Entity & Toggle Helper
value: "enable_all_auto_off"
- label: Enable Auto OFF - Toggle Helper
value: "enable_manual_tracking_auto_off"
- label: Disable Auto OFF
value: "disable_auto_off"
time_delay:
name: Auto OFF - Time Delay
description: >
The time delay determines how long the entities will remain ON.
default: 10
selector:
number:
min: 0
max: 60
step: 0.5
unit_of_measurement: minutes
mode: restart
max_exceeded: silent
variables:
target_entities: !input target_entities
manual_tracking: !input manual_tracking
include_auto_off: !input include_auto_off
time_delay: !input time_delay
target_entities_on: >
{{ expand(target_entities)
| selectattr('state', 'eq', 'on')
| map(attribute='entity_id')
| list }}
triggers:
- trigger: state
entity_id: !input target_entities
from: "off"
to: "on"
id: "t1"
- trigger: state
entity_id: !input target_entities
from: "on"
to: "off"
id: "t2"
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger from off to on manualy
conditions:
- condition: template
value_template: "{{ trigger.id == 't1' and trigger.to_state.context.parent_id is none }}"
- condition: and # trigger from on to off manualy
conditions:
- condition: template
value_template: "{{ trigger.id == 't2' and trigger.to_state.context.parent_id is none }}"
action:
- choose:
- conditions:
- condition: trigger
id: 't1'
sequence:
- action: homeassistant.turn_on
target:
entity_id: !input manual_tracking
- choose:
- conditions:
- "{{ include_auto_off == 'enable_all_auto_off' }}"
sequence:
- delay:
minutes: !input time_delay
- action: homeassistant.turn_off
target:
entity_id: "{{ target_entities_on }}"
- action: homeassistant.turn_off
target:
entity_id: !input manual_tracking
- conditions:
- "{{ include_auto_off == 'enable_manual_tracking_auto_off' }}"
sequence:
- delay:
minutes: !input time_delay
- action: homeassistant.turn_off
target:
entity_id: !input manual_tracking
- conditions:
- condition: trigger
id: 't2'
sequence:
- action: homeassistant.turn_off
target:
entity_id: !input manual_tracking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment