Last active
January 23, 2024 07:39
-
-
Save Twanne/a14f88f5de0f74bdf1f7532fd9ab5ff0 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: The Everything Light BETA
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: The Everything Light (BETA) | |
author: AntonH | |
description: | | |
**Version 2.5** **(BETA)** | |
The Everything Light: select any trigger and turn on your light in multiple ways: | |
- just turn the light on in it's default state | |
- turn it on with a set brightness, color and/or temperature value | |
- turn it on dynamically with a brightness value that changes according to an ambient light sensor | |
The blueprint also allows you to turn the light off again in 3 ways: | |
- at a set time | |
- with 1 or more triggers | |
- with a staircase function (turn off the light after a set time has passed) | |
Conditions can be set to prevent both turn on and turn off functions. | |
**The dynamic lighting logic is based of the Smart Lux Dimmer Blueprint:** | |
- [Find it on the Home Assistant Community forums:](https://community.home-assistant.io/t/smart-lux-dimmer-adjust-light-brightness-depending-on-light-sensor-value/403646) | |
- [See the source on Github:](https://gist.github.com/Twanne/02dfb154084a8b9bf927c29160df4af3) | |
source_url: https://gist.github.com/Twanne/a14f88f5de0f74bdf1f7532fd9ab5ff0 | |
domain: automation | |
input: | |
#Triggers | |
triggers: | |
name: Triggers | |
description: Choose what turns your light on | |
default: [] | |
selector: | |
trigger: | |
#Conditions | |
run_conditions: | |
name: Conditions | |
description: Only turn the light on when these conditions are met. | |
default: | |
- condition: time | |
alias: Run only at these times ( - Remove me if not needed - ) | |
selector: | |
condition: | |
#Lights to control | |
target_light: | |
name: Target lights | |
description: | | |
Which lights do you want to control? | |
Supported entity types are: | |
- light | |
- switch (Only **DEFAULT** & **TOGGLE** modes are supported) | |
default: [] | |
selector: | |
target: | |
entity: | |
domain: | |
- light | |
- switch | |
#Choose mode | |
mode: | |
name: Mode | |
description: | | |
How do you want the light to turn on? | |
- **DEFAULT MODE:** | |
The light will turn on at it's default setting. | |
- **TOGGLE MODE:** | |
Toggle the light. | |
- **FIXED MODE: ** | |
The light will turn on at a set brightness percentage, optionally color or temperature can be set. | |
- **DYNAMIC MODE** | |
The light will be assigned a brightness value based on the value of a ambient light sensor, optionally color or temperature can be set. | |
default: default | |
selector: | |
select: | |
mode: dropdown | |
options: | |
- label: DEFAULT MODE | |
value: default | |
- label: TOGGLE | |
value: toggle | |
- label: FIXED MODE | |
value: fixed | |
- label: DYNAMIC MODE | |
value: dynamic | |
#Transition (FIXED & DYNAMIC MODE) | |
transition_time: | |
name: Transition time (FIXED & DYNAMIC MODE) | |
description: | | |
The time it takes for the light to transition to the assigned value when it's triggered. | |
WARNING!: | |
This can smoothen the transition, but your light needs to support it. | |
Leave at 0 if you don't need it or if your light doesn't support it. | |
default: 0 | |
selector: | |
number: | |
min: 0 | |
max: 300 | |
step: 1 | |
unit_of_measurement: s | |
mode: slider | |
#Include color or temperature (FIXED & DYNAMIC MODE) | |
include_color_or_temp: | |
name: Include color or temperature (FIXED & DYNAMIC MODE) | |
description: Do you want to set a color or temperature value for the light? | |
default: include_no_color_temp | |
selector: | |
select: | |
options: | |
- label: I don't want to set color or temperature | |
value: include_no_color_temp | |
- label: Set color | |
value: include_color | |
- label: Set temperature | |
value: include_temperature | |
#Light color (FIXED & DYNAMIC MODE) | |
light_color: | |
name: Light color (FIXED & DYNAMIC MODE) | |
description: Color of the light when between minimum and maximum ambient light values. | |
default: [255, 255, 255] | |
selector: | |
color_rgb: | |
#Light temperature (FIXED & DYNAMIC MODE) | |
light_temperature: | |
name: Light temperature (FIXED & DYNAMIC MODE) | |
description: Temperature of the light when between minimum and maximum ambient light values. | |
default: 2000 | |
selector: | |
color_temp: | |
#Brightness (FIXED BRIGHTNESS MODE) | |
brightness: | |
name: Brightness (FIXED BRIGHTNESS MODE) | |
description: Set the brightness value the light needs to turn on at | |
default: 0 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
mode: slider | |
unit_of_measurement: "%" | |
#Ambient light sensor (DYNAMIC MODE) | |
light_sensor_entity: | |
name: Light Sensor (DYNAMIC MODE) | |
description: Which light sensor do you want to use to measure the ambient light value? | |
default: | |
selector: | |
entity: | |
filter: | |
- domain: sensor | |
device_class: illuminance | |
#Maximum brightness (DYNAMIC MODE) | |
max_brightness_value: | |
name: Maximum ambient light value (DYNAMIC MODE) | |
description: Dynamically change the light so long as the ambient light stays under this value. | |
default: 500 | |
selector: | |
number: | |
min: 0 | |
max: 1000 | |
step: 10 | |
unit_of_measurement: lx | |
mode: slider | |
#Minimum brightness (DYNAMIC MODE) | |
min_brightness_value: | |
name: Minimum ambient light value (DYNAMIC MODE) | |
description: Dynamically change the light so long as the ambient light stays above this value. | |
default: 0 | |
selector: | |
number: | |
min: 0 | |
max: 1000 | |
step: 10 | |
unit_of_measurement: lx | |
mode: slider | |
#Light value at maximum brightness (DYNAMIC MODE) | |
light_value_1: | |
name: Brightness at maximum light level (DYNAMIC MODE) | |
description: Brightness of the light at maximum ambient light. | |
default: 0 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
mode: slider | |
unit_of_measurement: "%" | |
#Light value at minimum brightness (DYNAMIC MODE) | |
light_value_2: | |
name: Brightness at minimum light level (DYNAMIC MODE) | |
description: Brightness of the light at minimum ambient light. | |
default: 100 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
mode: slider | |
unit_of_measurement: "%" | |
#Brightness when ambient light value over max (DYNAMIC MODE) | |
light_brightness_over_max: | |
name: Brightness when ambient light value over max (DYNAMIC MODE) | |
description: Brightness of the light when the ambient light is higher than the set maximum value. | |
default: 0 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
mode: slider | |
unit_of_measurement: "%" | |
#Brightness when ambient light value under min (DYNAMIC MODE) | |
light_brightness_under_min: | |
name: Brightness when ambient light value under min (DYNAMIC MODE) | |
description: Brightness of the light when the ambient light is lower than the set minimum value. | |
default: 100 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
mode: slider | |
unit_of_measurement: "%" | |
#Include color or temperature values when outside range (DYNAMIC MODE) | |
include_color_or_temp_over_under: | |
name: Include color or temperature values when outside range (DYNAMIC MODE) | |
description: | | |
Set a color or temperature value for the light when over maximum or under minimum ambient light value? | |
*'Include values for under min and over max'* **MUST BE TRUE** | |
default: include_no_color_temp_outside_range | |
selector: | |
select: | |
options: | |
- label: I don't want to set color or temperature when outside range | |
value: include_no_color_temp_outside_range | |
- label: Set color when outside range | |
value: include_color_outside_range | |
- label: Set temperature when outside range | |
value: include_temp_outside_range | |
#Color when ambient light value over max (DYNAMIC MODE) | |
light_color_over_max: | |
name: Color when ambient light value over max (DYNAMIC MODE) | |
description: Color of the light when the ambient light is higher than the set maximum value. | |
default: [255, 255, 255] | |
selector: | |
color_rgb: | |
#Color when ambient light value under min (DYNAMIC MODE) | |
light_color_under_min: | |
name: Color when ambient light value under min (DYNAMIC MODE) | |
description: Color of the light when the ambient light is lower than the set minimum value. | |
default: [255, 255, 255] | |
selector: | |
color_rgb: | |
#Temperature when ambient light value over max (DYNAMIC MODE) | |
light_temp_over_max: | |
name: Temperature when ambient light value over max (DYNAMIC MODE) | |
description: Temperature of the light when the ambient light is higher than the set maximum value. | |
default: 2000 | |
selector: | |
color_temp: | |
#Temperature when ambient light value under min (DYNAMIC MODE) | |
light_temp_under_min: | |
name: Temperature when ambient light value under min (DYNAMIC MODE) | |
description: Temperature of the light when the ambient light is lower than the set minimum value. | |
default: 2000 | |
selector: | |
color_temp: | |
#Include turn off function | |
include_turn_off: | |
name: Include light turn off function | |
description: | | |
Select if the light needs to turn back off again and how you want to do it. | |
(Multiple options are possible) | |
- **TURN OFF WITH TRIGGER:** | |
Select triggers that turn off the light. | |
- **STAIRCASE FUNCTION:** | |
Waits after the light has been turned on and then turns it back off after the set duration. | |
default: [] | |
selector: | |
select: | |
multiple: true | |
options: | |
- label: Turn off with trigger | |
value: trigger | |
- label: Staircase function | |
value: staircase | |
#Turn off triggers | |
turn_off_triggers: | |
name: Turn off triggers | |
description: Triggers that turn the light off | |
default: | |
selector: | |
trigger: | |
#Staircase light duration | |
staircase_duration: | |
name: Staircase light | |
description: Turns the light off again after a set time (staircase function). | |
default: | |
hours: 0 | |
minutes: 0 | |
seconds: 0 | |
days: 0 | |
selector: | |
duration: | |
enable_day: true | |
#Turn off conditions | |
turn_off_conditions: | |
name: Turn off Conditions | |
description: | | |
Only turn the light off when these conditions are met. | |
(Only works with the turn off functions, DYNAMIC MODE is not impacted by this) | |
default: [] | |
selector: | |
condition: | |
#Automation mode | |
mode: restart | |
#Variables for use in calculations and statements | |
variables: | |
#General variables | |
mode: !input mode | |
transition_time: !input transition_time | |
#Fixed mode variables | |
include_color_or_temp: !input include_color_or_temp | |
light_color: !input light_color | |
light_temperature: !input light_temperature | |
light_brightness: !input brightness | |
#Dynamic mode variables | |
light_sensor: !input light_sensor_entity | |
maxB: !input max_brightness_value | |
minB: !input min_brightness_value | |
light1: !input light_value_1 | |
light2: !input light_value_2 | |
slope: "{{ ( light1 - light2 ) / ( maxB - minB ) }}" | |
constant: "{{ light1 - ( slope * maxB ) }}" | |
dynamic_brightness_pct: > | |
{% if mode == "dynamic" %} | |
{{ (( slope * states(light_sensor)|int ) + constant)|round }} | |
{% else %} | |
0 | |
{% endif %} | |
#Dynamic mode variables outside set range | |
include_color_or_temp_over_under: !input include_color_or_temp_over_under | |
light_brightness_over_max: !input light_brightness_over_max | |
light_color_over_max: !input light_color_over_max | |
light_temp_over_max: !input light_temp_over_max | |
light_brightness_under_min: !input light_brightness_under_min | |
light_color_under_min: !input light_color_under_min | |
light_temp_under_min: !input light_temp_under_min | |
#Turn off variables: | |
include_turn_off: !input include_turn_off | |
#Triggers | |
trigger: !input triggers | |
#Conditions | |
condition: | |
- condition: !input run_conditions | |
#Actions | |
action: | |
#Turn on actions | |
- choose: | |
#Toggle mode | |
- conditions: '{{ mode == "toggle" }}' | |
sequence: | |
- service: homeassistant.toggle | |
target: !input target_light | |
#Default mode | |
- conditions: '{{ mode == "default" }}' | |
sequence: | |
- service: homeassistant.turn_on | |
target: !input target_light | |
#Fixed brightness mode | |
- conditions: '{{ mode == "fixed" }}' | |
sequence: | |
- service: light.turn_on | |
data: > | |
{% if include_color_or_temp == "include_color" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness, "rgb_color": light_color } }} | |
{% elif include_color_or_temp == "include_temperature" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness, "color_temp": light_temperature } }} | |
{% else %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness } }} | |
{% endif %} | |
target: !input target_light | |
#Dynamic brightness mode | |
- conditions: '{{ mode == "dynamic" }}' | |
sequence: | |
- service: light.turn_on | |
data: > | |
{% if states(light_sensor)|int > maxB %} | |
{% if include_color_or_temp_over_under == "include_color_outside_range" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_over_max, "rgb_color": light_color_over_max } }} | |
{% elif include_color_or_temp_over_under == "include_temp_outside_range" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_over_max, "color_temp": light_temp_over_max } }} | |
{% else %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_over_max } }} | |
{% endif %} | |
{% elif states(light_sensor)|int < minB %} | |
{% if include_color_or_temp_over_under == "include_color_outside_range" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_under_min, "rgb_color": light_color_under_min } }} | |
{% elif include_color_or_temp_over_under == "include_temp_outside_range" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_under_min, "color_temp": light_temp_under_min } }} | |
{% else %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness_under_min } }} | |
{% endif %} | |
{% else %} | |
{% if include_color_or_temp == "include_color" %} | |
{{ { "transition": transition_time, "brightness_pct": light_brightness, "rgb_color": light_color } }} | |
{% elif include_color_or_temp == "include_temperature" %} | |
{{ { "transition": transition_time, "brightness_pct": dynamic_brightness_pct, "color_temp": light_temperature } }} | |
{% else %} | |
{{ { "transition": transition_time, "brightness_pct": dynamic_brightness_pct } }} | |
{% endif %} | |
{% endif %} | |
target: !input target_light | |
#Turn off conditions | |
- if: !input turn_off_conditions | |
then: | |
#Turn off actions | |
- choose: | |
#Staircase function | |
- conditions: '{{ "staircase" in include_turn_off }}' | |
sequence: | |
- if: '{{ "trigger" in include_turn_off }}' | |
then: | |
- wait_for_trigger: !input turn_off_triggers | |
timeout: !input staircase_duration | |
else: | |
- delay: !input staircase_duration | |
- service: homeassistant.turn_off | |
target: !input target_light | |
#Turn off with triggers | |
- conditions: '{{ "trigger" in include_turn_off and not "staircase" in include_turn_off }}' | |
sequence: | |
- wait_for_trigger: !input turn_off_triggers | |
- service: homeassistant.turn_off | |
target: !input target_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment