Skip to content

Instantly share code, notes, and snippets.

@XtremeOwnageDotCom
Created January 8, 2025 01:27
Show Gist options
  • Save XtremeOwnageDotCom/baf81bf79ac67c3849cad2453a03793a to your computer and use it in GitHub Desktop.
Save XtremeOwnageDotCom/baf81bf79ac67c3849cad2453a03793a to your computer and use it in GitHub Desktop.
blueprint:
name: Advanced Automation Control with Device State Options
description: >
Enables or disables automations, optionally triggers scenes, and controls devices
based on the state of an input_boolean.
domain: automation
author: "XtremeOwnage (https://static.xtremeownage.com)"
homeassistant:
min_version: "2024.6.0"
input:
toggle_input:
name: Toggle Input
description: "Select the input_boolean to trigger the automation state change."
selector:
entity:
filter:
domain: input_boolean
automation_label:
name: Automation Label
description: "Select the label identifying automations to control."
selector:
label: {}
# condition_sensor:
# name: Condition Sensor
# description: "Optional sensor that must pass for the automation to run."
# selector:
# condition:
# default:
scene_control:
name: Scene Control
description: "Settings to control scenes triggered when turning on or off."
input:
scene_on:
name: Scene to Trigger (On)
description: "Optional scene to trigger when input_boolean is turned on."
selector:
entity:
filter:
domain: scene
default:
scene_off:
name: Scene to Trigger (Off)
description: "Optional scene to trigger when input_boolean is turned off."
selector:
entity:
filter:
domain: scene
default:
device_manipulation:
name: Device Manipulation
description: "Settings for controlling device behavior based on the input_boolean state."
input:
lights_behavior:
name: Lights Behavior
description: "Select the behavior for lights with the specified label."
default: "disabled"
selector:
select:
options:
- label: Disabled (Do Nothing)
value: "disabled"
- label: Sync State (Helper On = Entity On, Vise-Versa)
value: "sync"
- label: Invert State (Helper On = Entity Off, Vise-Versa)
value: "invert"
- label: Turn Off When Enabled.
value: "off"
- label: Turn On When Enabled.
value: "on"
switches_behavior:
name: Switches Behavior
description: "Select the behavior for switches with the specified label."
default: "disabled"
selector:
select:
options:
- label: Disabled (Do Nothing)
value: "disabled"
- label: Sync State (Helper On = Entity On, Vise-Versa)
value: "sync"
- label: Invert State (Helper On = Entity Off, Vise-Versa)
value: "invert"
- label: Turn Off When Enabled.
value: "off"
- label: Turn On When Enabled.
value: "on"
fans_behavior:
name: Fans Behavior
description: "Select the behavior for fans with the specified label."
default: "disabled"
selector:
select:
options:
- label: Disabled (Do Nothing)
value: "disabled"
- label: Sync State (Helper On = Entity On, Vise-Versa)
value: "sync"
- label: Invert State (Helper On = Entity Off, Vise-Versa)
value: "invert"
- label: Turn Off When Enabled.
value: "off"
- label: Turn On When Enabled.
value: "on"
auto_disable:
name: Automatic Disable
description: "Settings to automatically disable override."
input:
# New inputs for disabling override after interval or time
disable_after_hours_enabled:
name: Enable Override Auto-Disable (N Hours)
description: "Enable automatic disabling of the input after a set number of hours."
selector:
boolean:
disable_after_hours:
name: Disable Override After N Hours
description: "Specify the number of hours after which the input will be automatically disabled."
selector:
number:
min: 1
max: 24
default: 1
disable_after_time_enabled:
name: Enable Override Auto-Disable (Specific Time)
description: "Enable automatic disabling of the input at a specific time each day."
selector:
boolean:
disable_after_time:
name: Disable Override After Time
description: "Specify the time each day to automatically disable the input if enabled."
selector:
time:
variables:
#condition_sensor: !input condition_sensor
scene_on: !input scene_on
scene_off: !input scene_off
lights_behavior: !input lights_behavior
fans_behavior: !input fans_behavior
switches_behavior: !input switches_behavior
trigger:
- trigger: state
entity_id: !input toggle_input
from: "off"
to: "on"
id: "on"
- trigger: state
entity_id: !input toggle_input
from: "on"
to: "off"
id: "off"
# Auto-disable override after N hours
- trigger: time_pattern
hours: "/1"
id: "auto_disable_hours"
enabled: !input disable_after_hours_enabled
# Auto-disable override at specific time daily
- trigger: time
at: !input disable_after_time
id: "auto_disable_time"
enabled: !input disable_after_time_enabled
action:
- choose:
- conditions:
- condition: trigger
id: "on"
sequence:
- action: automation.turn_off
target:
label_id: !input automation_label
- choose:
conditions:
- "{{ not not scene_on }}"
sequence:
- action: scene.turn_on
target:
entity_id: !input scene_on
# Device behavior based on selected options for lights, switches, and fans
- choose:
- conditions:
- "{{ lights_behavior == 'sync' }}"
sequence:
- action: light.turn_on
target:
label_id: !input automation_label
- conditions:
- "{{ lights_behavior == 'invert' }}"
sequence:
- action: light.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ lights_behavior == 'off' }}"
sequence:
- action: light.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ lights_behavior == 'on' }}"
sequence:
- action: light.turn_on
target:
label_id: !input automation_label
- choose:
- conditions:
- "{{ switches_behavior == 'sync' }}"
sequence:
- action: switch.turn_on
target:
label_id: !input automation_label
- conditions:
- "{{ switches_behavior == 'invert' }}"
sequence:
- action: switch.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ switches_behavior == 'off' }}"
sequence:
- action: switch.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ switches_behavior == 'on' }}"
sequence:
- action: switch.turn_on
target:
label_id: !input automation_label
- choose:
- conditions:
- "{{ fans_behavior == 'sync' }}"
sequence:
- action: fan.turn_on
target:
label_id: !input automation_label
- conditions:
- "{{ fans_behavior == 'invert' }}"
sequence:
- action: fan.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ fans_behavior == 'off' }}"
sequence:
- action: fan.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ fans_behavior == 'on' }}"
sequence:
- action: fan.turn_on
target:
label_id: !input automation_label
- conditions:
- condition: trigger
id: "off"
sequence:
- action: automation.turn_on
target:
label_id: !input automation_label
- choose:
conditions:
- "{{ not not scene_off }}"
sequence:
- action: scene.turn_on
target:
entity_id: !input scene_off
# Handling lights, switches, and fans with OFF state behavior
- choose:
- conditions:
- '{{ lights_behavior == "sync" }}'
sequence:
- action: light.turn_off
target:
label_id: !input automation_label
- conditions:
- "{{ switches_behavior == 'invert' }}"
sequence:
- action: switch.turn_on
target:
label_id: !input automation_label
# Auto-disable logic.
- conditions:
- condition: or
conditions:
- condition: trigger
id: "auto_disable_hours"
- condition: trigger
id: "auto_disable_time"
- condition: state
entity_id: !input toggle_input
state: "on"
sequence:
- action: input_boolean.turn_off
target:
entity_id: !input toggle_input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment