Created
March 1, 2024 13:17
-
-
Save Blackshome/5aac0fe94d23a71154aee5ba8d1375bc to your computer and use it in GitHub Desktop.
closet-pantry-cupboard-lighting.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Closet, Pantry, and Cupboard Lighting | |
description: > | |
# 🚪 Closet, Pantry, and Cupboard Lighting | |
**Version: 1.0** | |
'Open Sesame'🪄 Lighting Magic! 💡🚪 | |
**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> - Click here to expand</summary> | |
- **Trigger:** | |
- The trigger sensor is specifically designed to integrate seamlessly with a door contact sensor but you can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/) to trigger the automation. | |
- When activated, a trigger sensor such as a door contact sensor will turn ON the lights and switches. | |
- **Light - Switches:** | |
- Enter any lights or switches that will be activated by the trigger sensor/s. | |
- **Light Control Options:** | |
- Utilize "Light Control" to adjust brightness, colour temperature, and transition times. | |
- **Timer Option:** | |
- You have the option to use a timer, which determines how long the lights remain ON after the trigger sensor is activated. It will then automatically turn OFF the 'Lights - Switches' when the timer expires. | |
- **Motion Sensor Option:** | |
- You have the option to use a motion sensor that will reset the timer. If the timer has turned OFF the lights and the trigger remains active, the motion sensor will turn the lights back ON when detecting motion. | |
- **HA Restart Safeguards:** | |
- Benefit from built-in safeguards for Home Assistant restarts. | |
- **Blueprint Integration:** | |
- Sensor Light - Motion activated lighting. [Click Here](https://community.home-assistant.io/t/481048) to learn more. | |
</details> | |
Need help? See our FAQ: [Click Here](https://community.home-assistant.io/t/697688/2?u=blacky) | |
Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/697688?u=blacky) | |
Required = * | |
domain: automation | |
input: | |
trigger_entity: | |
name: Trigger Sensor - Binary Sensors* | |
description: The trigger sensor is specifically designed to integrate seamlessly with a door contact | |
sensor and will be responsible for turning ON the lights and switches. | |
When using multiple trigger sensors, it's advisable to group them together using a group helper. | |
This ensures smoother automation execution and prevents conflicts. | |
For more information on grouping your trigger sensors [Click Here](https://community.home-assistant.io/t/697688/3?u=blacky) | |
selector: | |
entity: | |
filter: | |
domain: | |
- binary_sensor | |
multiple: true | |
light_switch: | |
name: Lights - Switches * | |
description: The lights & switches that will be activated by the trigger sensor/s. | |
**NOTE** - You can only use entities. Areas and devices are not supported. | |
selector: | |
target: | |
entity: | |
domain: | |
- light | |
- switch | |
include_light_control: | |
name: Use The Light Control Options (Optional) | |
description: Select if you would like to use brightness, colour temperature, or transition. | |
These settings will only affect a 'light' entity that supports each selected option. | |
The settings for brightness, colour temperature, and transition are provided below. | |
default: [] | |
selector: | |
select: | |
multiple: true | |
options: | |
- label: Use brightness | |
value: "use_brightness" | |
- label: Use colour temperature | |
value: "use_colour_temperature" | |
- label: Use transition | |
value: "use_transition" | |
light_brightness: | |
name: Brightness | |
description: The brightness setting for the lights when they are turned ON. | |
default: 100 | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
mode: slider | |
step: 1 | |
unit_of_measurement: '%' | |
light_colour_temperature: | |
name: Colour Temperature | |
description: The colour temperature setting for the lights when they are turned ON. | |
default: 5000 | |
selector: | |
number: | |
min: 2000 | |
max: 8000 | |
mode: slider | |
step: 100 | |
unit_of_measurement: 'kelvin' | |
light_transition_on: | |
name: Transition - ON | |
description: The transition setting for the lights when they are turned ON. | |
default: 1 | |
selector: | |
number: | |
min: 0 | |
max: 5 | |
mode: slider | |
step: 0.5 | |
unit_of_measurement: seconds | |
light_transition_off: | |
name: Transition - OFF | |
description: The transition setting for the lights when they are turned OFF. | |
default: 1 | |
selector: | |
number: | |
min: 0 | |
max: 30 | |
mode: slider | |
step: 1 | |
unit_of_measurement: seconds | |
include_timer: | |
name: Use The Timer Option (Optional) | |
description: Choose whether to activate the timer. | |
It determines the duration for which the lights can remain ON when the trigger sensor is activated. It will then automatically turn OFF the 'Lights - Switches' when the timer expires. | |
default: disable_timer | |
selector: | |
select: | |
options: | |
- label: Enable timer | |
value: "enable_timer" | |
- label: Disable timer | |
value: "disable_timer" | |
timer: | |
name: Timer | |
description: Enter the desired duration for the timer. | |
default: 00:00:00 | |
selector: | |
duration: | |
include_motion_trigger: | |
name: Use The Motion Sensor Option (Optional) | |
description: Use this option only when the timer is enabled to utilize the motion sensor. | |
The motion sensor pauses the timer when motion is detected and automatically resets it once motion is cleared. | |
Additionally, if the timer has turned OFF the lights and the trigger remains active, the motion sensor will turn the lights back ON when detecting motion. | |
default: disable_motion_trigger | |
selector: | |
select: | |
options: | |
- label: Enable the motion sensor option | |
value: "enable_motion_trigger" | |
- label: Disable the motion sensor option | |
value: "disable_motion_trigger" | |
motion_trigger: | |
name: Motion Sensor - Binary Sensors | |
description: Select a motion sensor or any binary sensors you would like to use. | |
If you plan to use multiple sensors, it's recommended to group them together using a group helper. | |
This ensures smoother automation execution and helps prevent conflicts. | |
For more information on grouping your motion sensors [Click Here](https://community.home-assistant.io/t/697688/3?u=blacky) | |
default: [] | |
selector: | |
entity: | |
filter: | |
domain: | |
- binary_sensor | |
mode: restart | |
max_exceeded: silent | |
variables: | |
trigger_entity: !input trigger_entity | |
light_switch: !input light_switch | |
include_light_control: !input include_light_control | |
light_brightness: !input light_brightness | |
brightness_value: "{{ iif ('use_brightness' in include_light_control , light_brightness, ) }}" | |
light_colour_temperature: !input light_colour_temperature | |
temperature_value: "{{ iif ('use_colour_temperature' in include_light_control , light_colour_temperature, [] ) }}" | |
light_transition_on: !input light_transition_on | |
light_transition_off: !input light_transition_off | |
transition_on_value: "{{ iif ('use_transition' in include_light_control, light_transition_on, ) }}" | |
transition_off_value: "{{ iif ('use_transition' in include_light_control, light_transition_off, ) }}" | |
include_timer: !input include_timer | |
timer: !input timer | |
include_motion_trigger: !input include_motion_trigger | |
motion_trigger: !input motion_trigger | |
# Split domains for light switch targets and check the entities are OFF - exclude scenes and scripts as they have no off state | |
light_entities_off: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}" | |
switch_entities_off: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}" | |
# Split domains for light switch targets | |
light_entities: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}" | |
switch_entities: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}" | |
trigger: | |
- platform: state | |
entity_id: !input trigger_entity | |
to: "on" | |
id: 't0' | |
- platform: state | |
entity_id: !input trigger_entity | |
to: "on" | |
id: 't1' | |
- platform: state | |
entity_id: !input trigger_entity | |
to: "off" | |
id: 't2' | |
- platform: state | |
id: "t3" | |
entity_id: !input motion_trigger | |
from: "off" | |
to: "on" | |
- platform: state | |
id: "t4" | |
entity_id: !input motion_trigger | |
from: "on" | |
to: "off" | |
- platform: homeassistant | |
id: "t5" | |
event: start | |
# All Conditions | |
condition: | |
#Trigger conditions | |
- condition: or | |
conditions: | |
- condition: and # trigger for ON state | |
conditions: | |
- condition: trigger | |
id: 't0' | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- condition: or | |
conditions: | |
- condition: and | |
conditions: | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input motion_trigger | |
state: 'off' | |
- "{{include_motion_trigger == 'disable_motion_trigger'}}" | |
- condition: and # trigger for ON state | |
conditions: | |
- condition: trigger | |
id: 't1' | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- condition: or | |
conditions: | |
- condition: and | |
conditions: | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input motion_trigger | |
state: 'on' | |
- condition: and # trigger for OFF state | |
conditions: | |
- condition: trigger | |
id: 't2' | |
- condition: state | |
entity_id: !input trigger_entity | |
state: 'off' | |
- condition: and # trigger for ON state | |
conditions: | |
- condition: trigger | |
id: 't3' | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- condition: and # trigger for ON state | |
conditions: | |
- condition: trigger | |
id: 't4' | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- condition: and # trigger by HA Restart, check if the timer helper is disabled & check if any triggers are on | |
conditions: | |
- condition: trigger | |
id: 't5' | |
- condition: or | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) }}" | |
action: | |
- choose: | |
- alias: "Default actions" | |
conditions: | |
- condition: trigger | |
id: | |
- "t0" | |
- "t4" | |
sequence: | |
- choose: | |
- alias: "Set the transition for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
- alias: "Set the transition and brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the transition and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the transition, brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the default for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
- alias: "Turn on the switches" | |
service: switch.turn_on | |
target: | |
entity_id: "{{ switch_entities_off }}" | |
- choose: | |
- alias: "If timer is disabled" | |
conditions: | |
- condition: template | |
value_template: "{{ include_timer == 'disable_timer' }}" | |
sequence: | |
- stop: "Stop the automation" | |
- alias: "If timer is enabled" | |
conditions: | |
- condition: template | |
value_template: "{{ include_timer == 'enable_timer' }}" | |
sequence: | |
- alias: "Wait for trigger" | |
wait_for_trigger: | |
platform: state | |
entity_id: !input trigger_entity | |
to: "off" | |
timeout: !input timer | |
- choose: | |
- alias: "If transition is selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
data: | |
transition: "{{ transition_off_value }}" | |
- alias: "If transition is not selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' not in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
- alias: "Turn off the switches" | |
service: switch.turn_off | |
target: | |
entity_id: "{{ switch_entities }}" | |
- alias: "Trigger turned OFF" | |
conditions: | |
- condition: trigger | |
id: "t2" | |
sequence: | |
- choose: | |
- alias: "If transition is selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
data: | |
transition: "{{ transition_off_value }}" | |
- alias: "If transition is not selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' not in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
- alias: "Turn off the switches" | |
service: switch.turn_off | |
target: | |
entity_id: "{{ switch_entities }}" | |
- alias: "Motion sensor actions" | |
conditions: | |
- condition: trigger | |
id: | |
- "t1" | |
- "t3" | |
sequence: | |
- choose: | |
- alias: "Set the transition for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
- alias: "Set the transition and brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the transition and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the transition, brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the default for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
- alias: "Turn on the switches" | |
service: switch.turn_on | |
target: | |
entity_id: "{{ switch_entities_off }}" | |
- alias: "Home Assistant Restart" | |
conditions: | |
- condition: trigger | |
id: "t5" | |
sequence: | |
- choose: | |
- alias: "If trigger is ON, light is ON, motion is enabled and motion is detected" | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) }}" | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input motion_trigger | |
state: 'on' | |
sequence: | |
- stop: "Stop the automation" | |
- alias: "If trigger is ON and light is ON" | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) }}" | |
sequence: | |
- choose: | |
- alias: "Set the transition for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
- alias: "Set the transition and brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the transition and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the transition, brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the default for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
- alias: "Turn on the switches" | |
service: switch.turn_on | |
target: | |
entity_id: "{{ switch_entities_off }}" | |
- choose: | |
- alias: "If timer is disabled" | |
conditions: | |
- condition: template | |
value_template: "{{ include_timer == 'disable_timer' }}" | |
sequence: | |
- stop: "Stop the automation" | |
- alias: "If transition is selected" | |
conditions: | |
- condition: template | |
value_template: "{{ include_timer == 'enable_timer' }}" | |
sequence: | |
- alias: "Wait for trigger" | |
wait_for_trigger: | |
platform: state | |
entity_id: !input trigger_entity | |
to: "off" | |
timeout: !input timer | |
- choose: | |
- alias: "If transition is selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
data: | |
transition: "{{ transition_off_value }}" | |
- alias: "If transition is not selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' not in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
- alias: "Turn off the switches" | |
service: switch.turn_off | |
target: | |
entity_id: "{{ switch_entities }}" | |
- alias: "If trigger is ON, light is OFF, motion is enabled and motion is detected" | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count) == 0 }}" | |
- "{{include_motion_trigger == 'enable_motion_trigger'}}" | |
- condition: state | |
entity_id: !input motion_trigger | |
state: 'on' | |
sequence: | |
- choose: | |
- alias: "Set the transition for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
- alias: "Set the transition and brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the transition and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the transition, brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
transition: "{{ transition_on_value }}" | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
- alias: "Set the colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the brightness and colour temperature for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('use_colour_temperature' in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
data: | |
brightness_pct: "{{ brightness_value }}" | |
kelvin: "{{temperature_value}}" | |
- alias: "Set the default for the lights" | |
conditions: | |
- condition: template | |
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('use_colour_temperature' not in include_light_control) }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ light_entities_off }}" | |
- alias: "Turn on the switches" | |
service: switch.turn_on | |
target: | |
entity_id: "{{ switch_entities_off }}" | |
- alias: "If trigger is ON and light is OFF" | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
match: any | |
state: 'on' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count) == 0 }}" | |
sequence: | |
- stop: "Stop the automation" | |
- alias: "If trigger is OFF and light is ON" | |
conditions: | |
- condition: state | |
entity_id: !input trigger_entity | |
state: 'off' | |
- "{{ (expand(light_switch.entity_id) | selectattr('state', '==', 'on') | list | count > 0) }}" | |
sequence: | |
- choose: | |
- alias: "If transition is selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
data: | |
transition: "{{ transition_off_value }}" | |
- alias: "If transition is not selected" | |
conditions: | |
- condition: template | |
value_template: "{{ 'use_transition' not in include_light_control }}" | |
sequence: | |
- alias: "Turn off the lights" | |
service: light.turn_off | |
target: | |
entity_id: "{{ light_entities }}" | |
- alias: "Turn off the switches" | |
service: switch.turn_off | |
target: | |
entity_id: "{{ switch_entities }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment