Files
Home-Assistant-Configs/blueprints/automation/Blackshome/sensor-light.yaml

8995 lines
434 KiB
YAML

blueprint:
name: Sensor Light
description: "# \U0001F4A1 Sensor Light\n**Version: 8.1**\n\nYour lighting experience,
your way - take control and customize it to perfection! \U0001F4A1✨\n\n**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) \U0001F642\n\n<details>
<summary><b>The Automation Process:</b> \U0001F448</summary>\n\n\n - **Trigger:**\n
\ - You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/)
or [schedules](https://www.home-assistant.io/integrations/schedule) to trigger
the automation.\n - A trigger sensor, such as a Motion Sensor, will activate
lights, switches, scenes, and scripts when the automation is triggered.\n -
A time delay begins the turning OFF process after all triggers are clear. See
[grouping](https://community.home-assistant.io/t/481048/34) sensors for more information.\n
\ - If triggers are activated again before the time delay ends, the automation
resets for continuous lighting.\n\n - **Scene and Script Integration:**\n -
Scenes or scripts offer additional customization for your spaces.\n\n - **Light
Control Options:**\n - Utilize \"Light Control\" to adjust brightness, colour
temperature, colour, and transition times.\n\n - **Dynamic Lighting Options:**\n
\ - Opt for 'Dynamic Lighting' to automatically adjust brightness based on lux
values, and/or adjust brightness and colour temperature according to the sun's
position or the time of day.\n - Opt to use the 'State Control Option,' allowing
you to toggle between dynamic lighting and normal lighting based on the entity's
activation state.\n\n - **Manual Override:**\n - Use \"Bypass Options\" for
manual bypassing of trigger sensors, providing manual control and additional customization.\n\n
\ - **Sun Elevation Options:**\n - Implement \"Sun Elevation\" to restrict
automation to darker conditions aligned with the sun's position.\n\n - **Ambient
Light Sensing Options:**\n - Set up an Ambient Light Sensor for activation
in low-light conditions, customizable with specified LUX values.\n\n - **Time-Based
Options:**\n - Specify precise start and end times along with weekday selections
to define when the automation should run.\n\n - **Device Tracker Options:**\n
\ - Utilize \"Device Tracker\" to activate automation when home or within specified
zones, preventing unnecessary activations. This feature is particularly useful
to prevent unnecessary lighting activations when pets trigger sensors while no
one is home.\n\n - **Night Lights Mode:**\n - Enable \"Night Lights\" for
softer illumination during night time activities, automatically enabled based
on conditions.\n - Opt to use \"Night Glow\". This feature activates a low-level
light when no trigger is detected, creating a subtle ambient glow perfect for
nighttime use.\n\n - **HA Restart Safeguards:**\n - Benefit from built-in
safeguards for Home Assistant restarts.\n\n - **Blueprint Add-On Integration:**\n
\ - Sensor Light Add-On - Enhances media control automation. [Click Here](https://community.home-assistant.io/t/591824)
to learn more.\n - Bathroom Humidity Exhaust Fan - Keeps the lights ON when
showering. [Click Here](https://community.home-assistant.io/t/509992) to learn
more.\n</details>\n\nNeed help?\n- The Settings & Best Practice Guidelines: [Click
Here](https://community.home-assistant.io/t/481048/345)\n- FAQ: [Click Here](https://community.home-assistant.io/t/481048/6)\n-
Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/481048)\n\nRequired
= *\n"
domain: automation
input:
trigger:
name: Trigger *
icon: mdi:cog-outline
collapsed: true
input:
motion_trigger:
name: Trigger Sensor - Binary Sensors - Schedule *
description: 'The trigger sensors are responsible for turning the lights,
switches, scenes, and scripts ON and OFF. You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/)
you prefer as triggers. Alternatively, if you prefer a time-based trigger,
you can also add a [schedule helper](https://community.home-assistant.io/t/481048/1616).
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/481048/34)
'
default: []
selector:
entity:
filter:
- domain:
- binary_sensor
- schedule
multiple: true
lights_settings:
name: Lights *
icon: mdi:lightbulb-outline
collapsed: true
input:
light_switch:
name: Lights - Switches - Scenes - Scripts *
description: 'The lights, switches, scenes, and scripts that will be activated
by the trigger sensor/s. If adding a scene or script, please refer to
the ''Scenes & Scripts - Toggle Helper'' section and the ''Scenes - Scripts
To Turn OFF'' section below.
For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595)
**NOTE** - You can only use entities. Areas, devices and labels are not
supported.
'
default: []
selector:
target:
entity:
- domain:
- light
- switch
- scene
- script
boolean_scenes_scripts:
name: Scenes & Scripts - Toggle Helper
description: 'To ensure the smooth operation of the automation, it''s recommended
to create an independent toggle helper when selecting a scene or script
in "Lights - Switches - Scenes - Scripts" above and then enter it here.
'
default: []
selector:
entity:
filter:
- domain:
- input_boolean
multiple: false
end_scenes:
name: Scenes - Scripts To Turn OFF
description: 'If you have selected a scene or a script to be turned ON above
in "Lights - Switches - Scenes - Scripts" or below in "Night Lights,"
and you would like it to be turned OFF after the time delay, then you
must create a scene or a script with everything OFF and enter it here.
'
default: []
selector:
entity:
multiple: true
filter:
- domain:
- scene
- script
time_delay:
name: Time Delay
description: 'The time delay determines how long the lights, switches, scenes,
and scripts will remain active after all triggers are clear, initiating
the time delay to turn them OFF.
'
default: 5
selector:
number:
min: 0.0
max: 30.0
step: 0.5
unit_of_measurement: minutes
mode: slider
normal_lights_settings:
name: Light Control
icon: mdi:lightbulb-on-outline
collapsed: true
input:
include_light_control:
name: Light Control Options (Optional)
description: 'Select if you would like to use brightness or transition.
These settings will only affect a ''light'' entity that supports each
selected option. The settings for brightness and transition are provided
below.
'
default: []
selector:
select:
multiple: true
options:
- label: Use Brightness
value: use_brightness
- label: Use Transition
value: use_transition
custom_value: false
sort: false
light_brightness:
name: Brightness
description: 'The brightness setting for the lights when they are turned
ON.
'
default: 100
selector:
number:
min: 1.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: '%'
light_transition_on:
name: Transition - ON
description: 'The transition setting for the lights when they are turned
ON.
'
default: 1
selector:
number:
min: 0.0
max: 5.0
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.0
max: 30.0
mode: slider
step: 1.0
unit_of_measurement: seconds
include_light_colour_control:
name: Light Colour Control Options (Optional)
description: 'Select if you would like to use colour temperature, RGB, RGBW
or RGBWW colour. These settings will only affect a ''light'' entity that
supports each selected option. The settings for colour temperature, RGB,
RGBW and RGBWW colour are provided below.
'
default: disable_colour_control
selector:
select:
options:
- label: Use Colour Temperature
value: use_colour_temperature
- label: Use RGB Colour
value: use_rgb_colour
- label: Use RGBW Colour
value: use_rgbw_colour
- label: Use RGBWW Colour
value: use_rgbww_colour
- label: Disable Colour Control
value: disable_colour_control
custom_value: false
sort: false
multiple: false
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.0
max: 8000.0
mode: slider
step: 100.0
unit_of_measurement: kelvin
light_rgb_colour:
name: RGB Colour
description: 'The RGB colour setting for the lights when they are turned
ON.
'
default:
- 255
- 255
- 255
selector:
color_rgb: {}
light_rgbw_colour:
name: RGBW Colour
description: 'The RGBW colour setting for the lights when they are turned
ON. Enter four integers between 0 and 255 to define the values for Red,
Green, Blue, and White.
'
default:
- 255
- 255
- 255
- 255
selector:
object: {}
light_rgbww_colour:
name: RGBWW Colour
description: 'The RGBWW colour setting for the lights when they are turned
ON. Enter five integers between 0 and 255 to define the values for Red,
Green, Blue, Cold White and Warm White.
'
default:
- 255
- 255
- 255
- 255
- 255
selector:
object: {}
dynamic_lighting_settings:
name: Dynamic Lighting
icon: mdi:creation-outline
collapsed: true
input:
include_dynamic_lighting:
name: Use The Dynamic Lighting Options (Optional)
description: "This option makes continual adjustments to your normal lighting
setup by modulating brightness based on floating lux values, or adapting
both colour temperature and brightness according to the sun's changing
elevation or the time of day. Choose from thirteen preset options available
in the dropdown menu.\n\n 1 - Lux Controlled Brightness\n 2 - Lux Controlled
Brightness Inverted\n 3 - Sun Elevation Lighting - Colour Temp\n 4 -
Sun Elevation Lighting - Brightness\n 5 - Sun Elevation Lighting - Brightness
Inverted\n 6 - Sun Elevation Lighting - Colour Temp + Brightness\n 7
- Sun Elevation Lighting - Colour Temp + Brightness Inverted\n 8 - Sun
Elevation Lighting - Colour Temp + Lux Controlled Brightness\n 9 - Sun
Elevation Lighting - Colour Temp + Lux Controlled Brightness Inverted\n
\ 10 - Time Controlled - Colour Temp\n 11 - Time Controlled - Brightness\n
\ 12 - Time Controlled - Brightness Inverted\n 13 - Time Controlled -
Colour Temp + Brightness\n\nA numbering system has been implemented to
facilitate navigation within the dropdown selections. Each number corresponds
to a specific configuration, aiding users in identifying and adjusting
the settings used within each selection. For instance, when selecting
\"3 - Sun Elevation Lighting - Colour Temp\" as a dropdown option, settings
marked \"Used in options 3, 6, 7, 8, 9, 10 or 13\" are required for that
respective selection because number 3 is included in those options.\n\nFor
more information on dynamic lighting settings [Click Here](https://community.home-assistant.io/t/481048/837)\n"
default: disable_dynamic_lighting
selector:
select:
mode: dropdown
options:
- label: Disable Dynamic Lighting
value: disable_dynamic_lighting
- label: 1 - Lux Controlled Brightness
value: enable_lux_controled_brightness
- label: 2 - Lux Controlled Brightness Inverted
value: enable_lux_controled_brightness_inv
- label: 3 - Sun Elevation Lighting - Colour Temp
value: enable_sun_elevation_colour
- label: 4 - Sun Elevation Lighting - Brightness
value: enable_sun_elevation_brightness
- label: 5 - Sun Elevation Lighting - Brightness Inverted
value: enable_sun_elevation_brightness_inv
- label: 6 - Sun Elevation Lighting - Colour Temp + Brightness
value: enable_sun_elevation_colour_brightness
- label: 7 - Sun Elevation Lighting - Colour Temp + Brightness Inverted
value: enable_sun_elevation_colour_brightness_inv
- label: 8 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness
value: enable_sun_elevation_colour_lux_brightness
- label: 9 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness
Inverted
value: enable_sun_elevation_colour_lux_brightness_inv
- label: 10 - Time Controlled - Colour Temp
value: enable_time_controled_colour
- label: 11 - Time Controlled - Brightness
value: enable_time_controled_brightness
- label: 12 - Time Controlled - Brightness Inverted
value: enable_time_controled_brightness_inv
- label: 13 - Time Controlled - Colour Temp + Brightness
value: enable_time_controled_colour_brightness
custom_value: false
sort: false
multiple: false
dynamic_lighting_lux_sensor:
name: Dynamic Lighting - Ambient Light Sensor
description: '**Used in options 1, 2, 8 or 9** - Enter the specific ambient
light sensor to be used, based on your selected Dynamic Lighting option.
'
default: []
selector:
entity:
filter:
- domain:
- sensor
device_class:
- illuminance
multiple: false
dynamic_lighting_max_lux:
name: Dynamic Lighting - Max Lux Value
description: '**Used in options 1, 2, 8 or 9** - Specify the maximum lux
value. Once the lux level meets or surpasses this set point, your lights
will adjust to either their maximum or minimum brightness, depending on
your chosen option. This value indicates when you prefer your lights
to start turning on or off.
'
default: 400
selector:
number:
min: 10.0
max: 900.0
step: 10.0
unit_of_measurement: lux
mode: slider
dynamic_lighting_min_lux:
name: Dynamic Lighting - Min Lux Value
description: '**Used in options 1, 2, 8 or 9** - Specify the minimum lux
value. Once the lux level meets or surpasses this set point, your lights
will adjust to either their maximum or minimum brightness, depending on
your chosen option. This value indicates when you prefer your lights
to start turning on or off.
'
default: 40
selector:
number:
min: 0.0
max: 600.0
step: 10.0
unit_of_measurement: lux
mode: slider
dynamic_lighting_max_brightness:
name: Dynamic Lighting - Max Brightness Value
description: '**Used in options 1, 2, 4, 5, 6, 7, 8, 9, 11, 12 or 13** -
Define the maximum brightness value, determines the peak brightness level
for your lights.
'
default: 100
selector:
number:
min: 10.0
max: 100.0
step: 1.0
unit_of_measurement: '%'
mode: slider
dynamic_lighting_min_brightness:
name: Dynamic Lighting - Min Brightness Value
description: '**Used in options 1, 2, 4, 5, 6, 7, 8, 9, 11, 12 or 13** -
Specify the minimum brightness value, establishing the lowest brightness
level for your lights. When setting the brightness to 0%, the light will
be turned off.
'
default: 0
selector:
number:
min: 0.0
max: 100.0
step: 1.0
unit_of_measurement: '%'
mode: slider
dynamic_lighting_boolean:
name: Dynamic Lighting - Toggle Helper (Optional)
description: '**Used in options 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 or 13**
- If you have chosen a brightness level of 0%, then it''s essential to
create an independent toggle helper and enter it here. This toggle helper
can also address issues if the automation doesn''t behave as expected
due to the occasional unavailability of light entities. While it may not
always be necessary, if you''re open to creating toggle helpers, it''s
highly recommended to utilize this option to ensure proper functionality
of the automation.
'
default: []
selector:
entity:
filter:
- domain:
- input_boolean
multiple: false
dynamic_lighting_max_colour_temp:
name: Dynamic Lighting - Max Colour Temperature
description: '**Used in options 3, 6, 7, 8, 9, 10 or 13** - Specify the
highest colour temperature value, determining the coolest colour setting
for your lights.
'
default: 5000
selector:
number:
min: 2500.0
max: 8000.0
mode: slider
step: 100.0
unit_of_measurement: kelvin
dynamic_lighting_min_colour_temp:
name: Dynamic Lighting - Min Colour Temperature
description: '**Used in options 3, 6, 7, 8, 9, 10 or 13** - Set the lowest
colour temperature value, defining the warmest colour setting for your
lights.
'
default: 3000
selector:
number:
min: 2000.0
max: 7500.0
mode: slider
step: 100.0
unit_of_measurement: kelvin
dynamic_lighting_sun_elevation_start_rising:
name: Dynamic Lighting - Sun Elevation Rising - Start Point
description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun rises
above the sensor''s starting point, both the colour temperature and brightness
percentage will transition linearly from their minimum to maximum values
until they reach the rising endpoint, based on your selected Dynamic Lighting
option.
'
default: -1.5
selector:
number:
min: -10.0
max: 30.0
step: 0.5
unit_of_measurement: degrees
mode: slider
dynamic_lighting_sun_elevation_end_rising:
name: Dynamic Lighting - Sun Elevation Rising - End Point
description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun rises
above the sensor''s endpoint, the maximum colour temperature and maximum
brightness value will be established, based on your selected Dynamic Lighting
option.
'
default: 15
selector:
number:
min: 0.0
max: 90.0
step: 0.5
unit_of_measurement: degrees
mode: slider
dynamic_lighting_sun_elevation_start_falling:
name: Dynamic Lighting - Sun Elevation Descending - Start Point
description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun descends
below the sensor''s starting point, both the colour temperature and brightness
percentage will transition linearly from their maximum to minimum values
until they reach the descending endpoint, based on your selected Dynamic
Lighting option.
'
default: 15
selector:
number:
min: 0.0
max: 90.0
step: 0.5
unit_of_measurement: degrees
mode: slider
dynamic_lighting_sun_elevation_end_falling:
name: Dynamic Lighting - Sun Elevation Descending - End Point
description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun descends
below the sensor''s endpoint, the minimum colour temperature and minimum
brightness value will be established, based on your selected Dynamic
Lighting option.
'
default: -4.0
selector:
number:
min: -10.0
max: 30.0
step: 0.5
unit_of_measurement: degrees
mode: slider
dynamic_lighting_time_start_morning:
name: Dynamic Lighting - Time Morning - Start Point
description: '**Used in options 10, 11, 12 or 13** - When the time passes
over the start point, both the colour temperature and brightness percentage
will transition linearly from their minimum to maximum values until they
reach the rising endpoint, based on your selected Dynamic Lighting option.
'
default: 06:00:00
selector:
time: {}
dynamic_lighting_time_end_morning:
name: Dynamic Lighting - Time Morning - End Point
description: '**Used in options 10, 11, 12 or 13** - When the time passes
over the end point, the maximum colour temperature and maximum brightness
value will be established, based on your selected Dynamic Lighting option.
'
default: 09:00:00
selector:
time: {}
dynamic_lighting_time_start_evening:
name: Dynamic Lighting - Time Evening - Start Point
description: '**Used in options 10, 11, 12 or 13** - When the time passes
over the start point, both the colour temperature and brightness percentage
will transition linearly from their maximum to minimum values until they
reach the descending endpoint, based on your selected Dynamic Lighting
option.
'
default: '17:00:00'
selector:
time: {}
dynamic_lighting_time_end_evening:
name: Dynamic Lighting - Time Evening - End Point
description: '**Used in options 10, 11, 12 or 13** - When the time passes
over the end point, the minimum colour temperature and minimum brightness
value will be established, based on your selected Dynamic Lighting option.
'
default: '19:00:00'
selector:
time: {}
dynamic_lighting_heartbeat:
name: Dynamic Lighting - Heartbeat
description: '**Used in options 1, 2, 8, 9, 10, 11, 12 or 13** - Define
the heartbeat rate to set the operational speed. During each heartbeat,
it may evaluate the lux value, light brightness, colour temperature, target
colour temperature, and target brightness, adjusting the colour temperature
or brightness based on your selected Dynamic Lighting option.
**Note** - When using a **Time Controlled** option (10, 11, 12, or 13),
the minimum heartbeat should be set to no lower than 1 minute, with adjustments
made in 1-minute increments (e.g., 1, 2, 3, 4, 5, and so on), as setting
it lower will not provide any benefit and may slow down your system''s
performance. Depending on the duration between the start and end points
of the light transition, adjusting this value will determine the size
of the step value. A longer heartbeat generally improves performance,
but it may also result in larger step values that could be bothersome
to the eye. Take the time to determine the correct heartbeat value for
your needs. The heartbeat is only active between the start and end points.
'
default: 1
selector:
number:
min: 0.25
max: 10.0
step: 0.25
unit_of_measurement: minutes
mode: slider
dynamic_lighting_step_value:
name: Dynamic Lighting - Step Value
description: '**Used in options 1, 2, 8, or 9** - With every heartbeat,
the system evaluates the lux value, light brightness, and targeted brightness.
If the targeted brightness exceeds the predefined step value, the system
applies the set step value to gradually moderate the rate of change, ensuring
a smoother transition in light brightness.
'
default: 4
selector:
number:
min: 1.0
max: 100.0
step: 1.0
unit_of_measurement: '%'
mode: slider
dynamic_lighting_dead_zone:
name: Dynamic Lighting - Dead Zone (±)
description: '**Used in options 1, 2, 8, or 9** - With every heartbeat,
the system evaluates the current light brightness and the targeted brightness.
If the targeted brightness falls within the defined dead zone, the system
maintains the current light brightness. This prevents minor fluctuations
in light intensity that could be bothersome to the eye.
'
default: 7
selector:
number:
min: 0.0
max: 15.0
step: 1.0
unit_of_measurement: '%'
mode: slider
dynamic_lighting_state_control:
name: Dynamic Lighting - State Control Option (Optional)
description: 'Enable or disable dynamic lighting based on the state of a
specified entity. When the entity is in the selected activation state
below, dynamic lighting will function as configured. When the entity is
not in the activation state below, dynamic lighting will be disabled.
This allows you to toggle between normal lighting and dynamic lighting
based on the entity''s state.
'
default: disable_state_control
selector:
select:
options:
- label: Enable State Control Option
value: enable_state_control
- label: Disable State Control Option
value: disable_state_control
custom_value: false
sort: false
multiple: false
dynamic_lighting_state_control_activation_state:
name: Dynamic Lighting - State Control Activation State
description: 'Select the state the entity must be in to activate dynamic
lighting. When the entity is in the selected state (ON or OFF), dynamic
lighting will be enabled. This option defines the activation condition
for dynamic lighting.
'
default: 'on'
selector:
select:
options:
- label: ON State
value: 'on'
- label: OFF State
value: 'off'
custom_value: false
sort: false
multiple: false
dynamic_lighting_state_control_entity:
name: Dynamic Lighting - State Control Entity
description: 'If the state control option above is enabled, select the entity
that will toggle dynamic lighting based on its activation state above.
'
default: []
selector:
entity: {}
bypass_settings:
name: Bypass
icon: mdi:cog-pause-outline
collapsed: true
input:
include_bypass:
name: Use The Bypass Options (Optional)
description: "Select if you would like to enable an option. Each option
determines how your lights will behave when the bypass switch is turned
ON:\n\n 1 - Turns the lights ON\n 2 - Turns the lights OFF\n 3 - Keeps
the lights current state\n\nIf you enable an option, make sure to enter
the corresponding bypass switch in the input below.\n\nFor more information
on how to use the bypass [Click Here](https://community.home-assistant.io/t/481048/895)\n"
default: []
selector:
select:
options:
- label: 1 - Enable the Bypass - Turn the Lights ON
value: bypass_enabled_turn_on
- label: 2 - Enable the Bypass - Turn the Lights OFF
value: bypass_enabled_turn_off
- label: 3 - Enable the Bypass - Keep the Lights Current State
value: bypass_enabled_stop
multiple: true
custom_value: false
sort: false
motion_bypass_lights_on:
name: Bypass Switch - Turn the Lights ON
description: 'Select the switches that will turn your lights ON, bypass
the trigger sensor, and allow your lights to function as normal. Please
note that the entity cannot be included in the ''Lights - Switches - Scenes
- Scripts'' or ''Night Lights'' selections.
'
default: []
selector:
entity:
multiple: true
motion_bypass_lights_off:
name: Bypass Switch - Turn the Lights OFF
description: 'Select the switches that will turn your lights OFF, bypass
the trigger sensor, and allow your lights to function as normal. Please
note that the entity cannot be included in the ''Lights - Switches - Scenes
- Scripts'' or ''Night Lights'' selections.
'
default: []
selector:
entity:
multiple: true
motion_bypass_lights_stop:
name: Bypass Switch - Keep the Lights Current State
description: 'Select the switches that will keep your lights current state,
bypass the trigger sensor, and allow your lights to function as normal.
Please note that the entity cannot be included in the ''Lights - Switches
- Scenes - Scripts'' or ''Night Lights'' selections.
'
default: []
selector:
entity:
multiple: true
bypass_time_delay:
name: Bypass - Time Delay
description: "This is only used in two specific bypass scenarios when your
lights are ON:\n\n 1. When you have selected option 2 above to \"Enable
the Bypass - Turn the Lights OFF\" and you turn the bypass ON.\n 2. When
the bypass is turned OFF, the trigger sensor is OFF, and your lights are
still ON.\n\nIn both cases, the automation will turn your lights OFF after
the set time delay.\n"
default: 0
selector:
number:
min: 0.0
max: 10.0
step: 0.25
unit_of_measurement: minutes
mode: slider
include_bypass_auto_off:
name: Use The Bypass Auto OFF Option (Optional)
description: "Enable this option if you want the bypass to automatically
turn OFF after a set time delay. You can choose which bypass option the
auto OFF will apply to:\n\n 1 - Turns the lights ON\n 2 - Turns the
lights OFF\n 3 - Keeps the lights current state\n\nEach option corresponds
to one of the bypass options above.\n"
default: []
selector:
select:
options:
- label: A - Enable Auto OFF for Bypass Option 1 - Turn the Lights ON
value: bypass_auto_off_enabled_on
- label: B - Enable Auto OFF for Bypass Option 2 - Turn the Lights OFF
value: bypass_auto_off_enabled_off
- label: C - Enable Auto OFF for Bypass Option 3 - Keep the Lights Current
State
value: bypass_auto_off_enabled_stop
multiple: true
custom_value: false
sort: false
bypass_auto_off_delay:
name: Bypass Auto OFF - Time Delay
description: 'Set the bypass auto OFF time delay. The time delay starts
from the last bypass that was turned ON.
'
default: 60
selector:
number:
min: 1.0
max: 240.0
step: 1.0
unit_of_measurement: minutes
mode: slider
sun_settings:
name: Sun Elevation
icon: mdi:weather-sunny
collapsed: true
input:
include_sun:
name: Use The Sun Option (Optional)
description: 'This option is used to add a condition that only allows the
automation to run when it is dark or below the ''Sun Elevation'' settings.
It''s a global condition that can work alongside other options. Enabling
this option is not necessary for the night lights sun elevation condition
to work.
For more information on sun settings [Click Here](https://community.home-assistant.io/t/481048/37)
'
default: sun_disabled
selector:
select:
options:
- label: Enable the sun option
value: sun_enabled
- label: Disable the sun option
value: sun_disabled
custom_value: false
sort: false
multiple: false
sun_elevation:
name: Sun Elevation Falling
description: 'The sun elevation falling refers to the angle between the
sun and the horizon when the sun is setting. A negative value indicates
that the sun is BELOW the horizon. For example, a setting guide of -1.5
corresponds to dusk
'
default: -1.5
selector:
number:
min: -10.0
max: 5.0
step: 0.5
unit_of_measurement: degrees
mode: slider
sun_elevation_rising:
name: Sun Elevation Rising
description: 'The sun elevation rising refers to the angle between the sun
and the horizon during sunrise. A negative value indicates that the sun
is BELOW the horizon. For example, a setting guide of -4.0 corresponds
to dawn.
'
default: -4.0
selector:
number:
min: -10.0
max: 5.0
step: 0.5
unit_of_measurement: degrees
mode: slider
ambient_settings:
name: Ambient
icon: mdi:theme-light-dark
collapsed: true
input:
include_ambient:
name: Use The Ambient Options (Optional)
description: 'This option is used to add a condition that only allows the
automation to run when it is dark or below the ''Ambient'' settings. It''s
a global condition that can work alongside other options.
For more information on ambient settings [Click Here](https://community.home-assistant.io/t/481048/1608)
'
default: ambient_disabled
selector:
select:
options:
- label: Enable the ambient options
value: ambient_enabled
- label: Disable the ambient options
value: ambient_disabled
custom_value: false
sort: false
multiple: false
ambient_light_sensor:
name: Ambient Light Sensor
description: 'Select the ambient sensor to be used.
'
default: []
selector:
entity:
filter:
- domain:
- sensor
device_class:
- illuminance
multiple: false
ambient_light_options:
name: Ambient Light Sensor - Site Conditions
description: 'In some cases when your lights turn ON, your ambient light
sensor is affected, increasing its LUX value. This can cause the lights
to go OFF prematurely. Please select an option that best suits your installation.
**NOTE** - If using an offset between the high and low lux value, then
please select NO.
'
default: ambient_light_option_disabled
selector:
select:
options:
- label: YES - My Ambient Light Sensor is affected by the Lights
value: ambient_light_option_enabled
- label: NO - My Ambient Light Sensor is not affected by the Lights
value: ambient_light_option_disabled
custom_value: false
sort: false
multiple: false
ambient_light_value:
name: Ambient Light - Low Lux Value
description: 'Set the Ambient Light Low Lux Value. The light will turn ON
when the lux level is below the set value. This value must be equal or
lower than the "High Lux Value" below. Guide is 20 lux (dusk).
'
default: 20
selector:
number:
min: 0.0
max: 500.0
step: 10.0
unit_of_measurement: lux
mode: slider
ambient_light_high_value:
name: Ambient Light - High Lux Value
description: 'Set the Ambient Light High Lux Value. The light will turn
OFF when the lux level is above the set value. This value must be equal
or higher than the "Low Lux Value" above. Setting a value higher than
the low value allows for an offset. Guide is 80 lux (dawn).
'
default: 80
selector:
number:
min: 0.0
max: 1000.0
step: 10.0
unit_of_measurement: lux
mode: slider
time_settings:
name: Time
icon: mdi:clock-outline
collapsed: true
input:
include_time:
name: Use The Time Options (Optional)
description: 'This option is used to add a condition that only allows the
automation to run between the start time and end time settings on the
selected weekdays. These time settings are global conditions that can
work alongside other options. Enabling this option is not necessary for
the night lights time condition to work.
For more information on time settings [Click Here](https://community.home-assistant.io/t/481048/310)
'
default: time_disabled
selector:
select:
options:
- label: Enable the time options
value: time_enabled
- label: Disable the time options
value: time_disabled
custom_value: false
sort: false
multiple: false
after_time:
name: Start Time
description: 'Set the start time.
'
default: 00:00:00
selector:
time: {}
before_time:
name: End Time
description: 'Set the end time.
'
default: 00:00:00
selector:
time: {}
weekday_options:
name: Weekdays
description: 'Select the days of the week you would like the automation
to run. You must select "Enable the time options" above for the weekday
selections to work.
'
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
multiple: true
mode: list
options:
- label: Monday
value: mon
- label: Tuesday
value: tue
- label: Wednesday
value: wed
- label: Thursday
value: thu
- label: Friday
value: fri
- label: Saturday
value: sat
- label: Sunday
value: sun
custom_value: false
sort: false
device_tracker_settings:
name: Device Tracker
icon: mdi:account-multiple-check-outline
collapsed: true
input:
include_device_tracker:
name: Use The Device Tracker Options (Optional)
description: 'Home Assistant can track the location of your devices (such
as mobile phones) within a designated zone via the mobile app device tracker.
To utilize this option, you need to set up a zone and configure your devices
for tracking in Home Assistant. There are two enable options available;
"Zone" tracks all devices within the zone, while "Zone + People" allows
you to track individuals within a zone. This feature can be particularly
useful if you have pets triggering the sensor, turning your lights ON
and OFF when no one is home.
'
default: device_tracker_disabled
selector:
select:
options:
- label: Enable the zone option
value: zone_enabled
- label: Enable the zone + people options
value: zone_people_enabled
- label: Disable the device tracker options
value: device_tracker_disabled
custom_value: false
sort: false
multiple: false
zone:
name: Device Tracker - Zone
description: 'Choose the zone that will track your devices and/or people
in it.
'
default: []
selector:
entity:
filter:
- domain:
- zone
multiple: false
people:
name: Device Tracker - People
description: 'Select the people you would like to track in the zone selected
above. You must enter a zone above for this option to work.
'
default: []
selector:
entity:
multiple: true
filter:
- domain:
- person
night_lights_trigger_settings:
name: Night Lights Settings
icon: mdi:weather-night
collapsed: true
input:
include_night_lights:
name: Use The Night Lights Options (Optional)
description: 'Enabling the night lights options allows for separate and
customizable lighting control when the night lights conditions are met.
Night light condition options include entity state, time, or sun elevation.
Please choose the condition option you would like to use below. This feature
is particularly beneficial for creating a soothing ambiance with softer
lighting at night. The flexibility of these options allows for personalized
adjustments, enhancing your night time ambiance and comfort, especially
when moving around during the night.
'
default: night_lights_disabled
selector:
select:
options:
- label: Enable the night lights options
value: night_lights_enabled
- label: Disable the night lights options
value: night_lights_disabled
custom_value: false
sort: false
multiple: false
night_lights_conditions:
name: Night Lights Conditions (Required For Night Lights)
description: 'Select any night light condition from the options provided
and ensure that **Use Night Lights Options** is enabled in the section
above. You must choose at least one ''Night Light Condition'' for the
night lights to operate, and the settings for each condition are provided
below. If you select two or more conditions, all selected conditions must
be met for the night lights to activate.
'
default: []
selector:
select:
multiple: true
options:
- label: Enable entity state option
value: entity_state_enabled
- label: Enable time option
value: time_enabled
- label: Enable sun elevation option
value: sun_enabled
custom_value: false
sort: false
night_lights_entity_state:
name: Night Lights - Entity State
description: 'Select an entity that will trigger the activation of night
lights when turned ON. This could be your phone on ''Do Not Disturb'',
a helper, a bed sensor, etc. Please note that the selected entity cannot
be included in the ''Lights - Switches - Scenes - Scripts'' or ''Night
Lights'' selections.
For more information on entity state [Click Here](https://community.home-assistant.io/t/481048/663)
'
default: []
selector:
entity:
multiple: true
night_lights_after_time:
name: Night Lights - Start Time
description: 'Set the start time.
'
default: 00:00:00
selector:
time: {}
night_lights_before_time:
name: Night Lights - End Time
description: 'Set the end time.
'
default: 00:00:00
selector:
time: {}
night_lights_sun_elevation:
name: Night Lights - Sun Elevation Falling
description: 'The sun elevation falling refers to the angle between the
sun and the horizon when the sun is setting. A negative value indicates
that the sun is BELOW the horizon. For example, a setting guide of -1.5
corresponds to dusk.
'
default: -1.5
selector:
number:
min: -10.0
max: 5.0
step: 0.5
unit_of_measurement: degrees
mode: slider
night_lights_sun_elevation_rising:
name: Night Lights - Sun Elevation Rising
description: 'The sun elevation rising refers to the angle between the sun
and the horizon during sunrise. A negative value indicates that the sun
is BELOW the horizon. For example, a setting guide of -4.0 corresponds
to dawn.
'
default: -4.0
selector:
number:
min: -10.0
max: 5.0
step: 0.5
unit_of_measurement: degrees
mode: slider
night_lights_settings:
name: Night Lights
icon: mdi:lightbulb-night-outline
collapsed: true
input:
night_lights:
name: Night Lights
description: 'The lights, switches, scenes, and scripts that will be activated
by the trigger sensor/s. If adding a scene or script, please refer to
the ''Night Lights - Scenes & Scripts - Toggle Helper'' section below
and the ''Scenes - Scripts To Turn OFF'' input in the lights section above.
For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595)
**NOTE** - You can only use entities. Areas, devices and labels are not
supported.
'
default: {}
selector:
target:
entity:
- domain:
- light
- switch
- scene
- script
night_boolean_scenes_scripts:
name: Night Lights - Scenes & Scripts - Toggle Helper
description: 'To ensure the smooth operation of the automation, it''s recommended
to create an independent toggle helper when selecting a scene or script
in "Night Lights" above and then enter it here.
'
default: []
selector:
entity:
filter:
- domain:
- input_boolean
multiple: false
night_time_delay:
name: Night Lights - Time Delay
description: 'The time delay determines how long the night lights will remain
active after all triggers are clear, initiating the time delay to turn
them OFF.
'
default: 5
selector:
number:
min: 0.0
max: 30.0
step: 0.5
unit_of_measurement: minutes
mode: slider
night_lights_light_control_settings:
name: Night Light Control
icon: mdi:lightbulb-on-80
collapsed: true
input:
include_night_light_control:
name: Night Lights - Light Control Options (Optional)
description: "Select if you would like to use brightness or transition.
These settings will only affect a 'light' entity that supports each selected
option. The settings for brightness and transition are provided below.
\n\nSelecting 'If lights are ON, adjust the lights when crossing over'
option ensures that the light control settings will be applied to any
lights that are already ON during the transition from normal lights to
night lights and vice versa.\n\nSelecting 'Yes - Manage OFF script when
crossing over' is beneficial for scripts containing if-then-else actions
that toggle various functions on and off during the transition from normal
lights to night lights and vice versa.\n"
default: []
selector:
select:
multiple: true
options:
- label: Use brightness
value: use_brightness
- label: Use transition
value: use_transition
- label: If lights are ON, adjust the lights when crossing over
value: if_lights_are_on_adjust_when_crossing_over
- label: Yes - Manage OFF script when crossing over
value: manage_scripts_crossing_over
custom_value: false
sort: false
night_light_brightness:
name: Night Lights - Brightness
description: 'The brightness setting of the lights when they are turned
ON.
'
default: 20
selector:
number:
min: 1.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: '%'
night_light_transition_on:
name: Night Lights - Transition - ON
description: 'The transition of the lights when they are turned ON.
'
default: 1
selector:
number:
min: 0.0
max: 5.0
mode: slider
step: 0.5
unit_of_measurement: seconds
night_light_transition_off:
name: Night Lights - Transition - OFF
description: 'The transition of the lights when they are turned OFF.
'
default: 1
selector:
number:
min: 0.0
max: 30.0
mode: slider
step: 1.0
unit_of_measurement: seconds
include_night_light_colour_control:
name: Night Lights - Light Colour Control Options (Optional)
description: 'Select if you would like to use colour temperature, RGB, RGBW
or RGBWW colour. These settings will only affect a ''light'' entity that
supports each selected option. The settings for colour temperature, RGB,
RGBW and RGBWW colour are provided below
'
default: disable_colour_control
selector:
select:
options:
- label: Use Colour Temperature
value: use_colour_temperature
- label: Use RGB Colour
value: use_rgb_colour
- label: Use RGBW Colour
value: use_rgbw_colour
- label: Use RGBWW Colour
value: use_rgbww_colour
- label: Disable Colour Control
value: disable_colour_control
custom_value: false
sort: false
multiple: false
night_light_colour_temperature:
name: Night Lights - Colour Temperature
description: 'The colour temperature setting for the lights when they are
turned ON.
'
default: 5000
selector:
number:
min: 2000.0
max: 8000.0
mode: slider
step: 100.0
unit_of_measurement: kelvin
night_light_rgb_colour:
name: Night Lights - RGB Colour
description: 'The RGB colour setting for the lights when they are turned
ON.
'
default:
- 255
- 255
- 255
selector:
color_rgb: {}
night_light_rgbw_colour:
name: Night Lights - RGBW Colour
description: 'The RGBW colour setting for the lights when they are turned
ON. Enter four integers between 0 and 255 to define the values for Red,
Green, Blue, and White.
'
default:
- 255
- 255
- 255
- 255
selector:
object: {}
night_light_rgbww_colour:
name: Night Lights - RGBWW Colour
description: 'The RGBWW colour setting for the lights when they are turned
ON. Enter five integers between 0 and 255 to define the values for Red,
Green, Blue, Cold White and Warm White.
'
default:
- 255
- 255
- 255
- 255
- 255
selector:
object: {}
night_lights_night_glow:
name: Night Glow
icon: mdi:candle
collapsed: true
input:
include_night_glow:
name: Night Glow (Optional)
description: 'This feature activates a low-level light when no trigger is
detected, creating a subtle ambient glow perfect for nighttime use. When
a trigger, such as a motion sensor, is detected, the light gradually increases
to the night light''s brightness level, providing enhanced visibility
and functionality without abrupt changes in lighting. You can also customize
the light''s colour temperature or RGB colour for added personalization.
'
default: night_glow_disabled
selector:
select:
options:
- label: Enable night glow
value: night_glow_enabled
- label: Disable night glow
value: night_glow_disabled
custom_value: false
sort: false
multiple: false
night_glow_lights:
name: Night Glow - Lights
description: 'The lights, switches, scenes, and scripts to be used for a
night glow. If adding a scene or script, please refer to the ''Scenes
- Scripts To Turn OFF'' input in the lights section above.
For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595)
**NOTE** - You can only use entities. Areas, devices and labels are not
supported.
'
default: {}
selector:
target:
entity:
- domain:
- light
- switch
- scene
- script
include_night_glow_light_control:
name: Night Glow - Light Control Options (Optional)
description: "Select if you would like to use brightness or transition.
These settings will only affect a 'light' entity that supports each selected
option. The settings for brightness and transition are provided below.
\n"
default: []
selector:
select:
multiple: true
options:
- label: Use brightness
value: use_brightness
- label: Use transition
value: use_transition
custom_value: false
sort: false
night_glow_light_brightness:
name: Night Glow - Brightness
description: 'The brightness setting of the lights when they are turned
ON.
'
default: 20
selector:
number:
min: 1.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: '%'
night_glow_light_transition_on:
name: Night Glow - Transition - ON
description: 'The transition of the lights when they are turned ON.
'
default: 1
selector:
number:
min: 0.0
max: 5.0
mode: slider
step: 0.5
unit_of_measurement: seconds
night_glow_light_transition_off:
name: Night Glow - Transition - OFF
description: 'The transition of the lights when they are turned OFF.
'
default: 1
selector:
number:
min: 0.0
max: 30.0
mode: slider
step: 1.0
unit_of_measurement: seconds
include_night_glow_light_colour_control:
name: Night Glow - Light Colour Control Options (Optional)
description: 'Select if you would like to use colour temperature, RGB, RGBW
or RGBWW colour. These settings will only affect a ''light'' entity that
supports each selected option. The settings for colour temperature, RGB,
RGBW and RGBWW colour are provided below
'
default: disable_colour_control
selector:
select:
options:
- label: Use Colour Temperature
value: use_colour_temperature
- label: Use RGB Colour
value: use_rgb_colour
- label: Use RGBW Colour
value: use_rgbw_colour
- label: Use RGBWW Colour
value: use_rgbww_colour
- label: Disable Colour Control
value: disable_colour_control
custom_value: false
sort: false
multiple: false
night_glow_light_colour_temperature:
name: Night Glow - Colour Temperature
description: 'The colour temperature setting for the lights when they are
turned ON.
'
default: 5000
selector:
number:
min: 2000.0
max: 8000.0
mode: slider
step: 100.0
unit_of_measurement: kelvin
night_glow_light_rgb_colour:
name: Night Glow - RGB Colour
description: 'The RGB colour setting for the lights when they are turned
ON.
'
default:
- 255
- 255
- 255
selector:
color_rgb: {}
night_glow_light_rgbw_colour:
name: Night Glow - RGBW Colour
description: 'The RGBW colour setting for the lights when they are turned
ON. Enter four integers between 0 and 255 to define the values for Red,
Green, Blue, and White.
'
default:
- 255
- 255
- 255
- 255
selector:
object: {}
night_glow_light_rgbww_colour:
name: Night Glow - RGBWW Colour
description: 'The RGBWW colour setting for the lights when they are turned
ON. Enter five integers between 0 and 255 to define the values for Red,
Green, Blue, Cold White and Warm White.
'
default:
- 255
- 255
- 255
- 255
- 255
selector:
object: {}
source_url: https://gist.github.com/Blackshome/6edfec0ff6a25c5da0d07b88dc908238
mode: restart
max_exceeded: silent
variables:
motion_trigger: !input motion_trigger
light_switch: !input light_switch
boolean_scenes_scripts: !input boolean_scenes_scripts
end_scenes: !input end_scenes
time_delay: !input time_delay
include_light_control: !input include_light_control
light_brightness: !input light_brightness
light_transition_on: !input light_transition_on
light_transition_off: !input light_transition_off
include_light_colour_control: !input include_light_colour_control
light_colour_temperature: !input light_colour_temperature
light_rgb_colour: !input light_rgb_colour
light_rgbw_colour: !input light_rgbw_colour
light_rgbww_colour: !input light_rgbww_colour
include_dynamic_lighting: !input include_dynamic_lighting
dynamic_lighting_lux_sensor: !input dynamic_lighting_lux_sensor
dynamic_lighting_max_lux: !input dynamic_lighting_max_lux
dynamic_lighting_min_lux: !input dynamic_lighting_min_lux
dynamic_lighting_max_brightness: !input dynamic_lighting_max_brightness
dynamic_lighting_min_brightness: !input dynamic_lighting_min_brightness
dynamic_lighting_boolean: !input dynamic_lighting_boolean
dynamic_lighting_max_colour_temp: !input dynamic_lighting_max_colour_temp
dynamic_lighting_min_colour_temp: !input dynamic_lighting_min_colour_temp
dynamic_lighting_sun_elevation_start_rising: !input dynamic_lighting_sun_elevation_start_rising
dynamic_lighting_sun_elevation_end_rising: !input dynamic_lighting_sun_elevation_end_rising
dynamic_lighting_sun_elevation_start_falling: !input dynamic_lighting_sun_elevation_start_falling
dynamic_lighting_sun_elevation_end_falling: !input dynamic_lighting_sun_elevation_end_falling
dynamic_lighting_time_start_morning: !input dynamic_lighting_time_start_morning
dynamic_lighting_time_end_morning: !input dynamic_lighting_time_end_morning
dynamic_lighting_time_start_evening: !input dynamic_lighting_time_start_evening
dynamic_lighting_time_end_evening: !input dynamic_lighting_time_end_evening
dynamic_lighting_heartbeat: !input dynamic_lighting_heartbeat
dynamic_lighting_step_value: !input dynamic_lighting_step_value
dynamic_lighting_dead_zone: !input dynamic_lighting_dead_zone
dynamic_lighting_state_control: !input dynamic_lighting_state_control
dynamic_lighting_state_control_activation_state: !input dynamic_lighting_state_control_activation_state
dynamic_lighting_state_control_entity: !input dynamic_lighting_state_control_entity
include_bypass: !input include_bypass
motion_bypass_lights_on: !input motion_bypass_lights_on
motion_bypass_lights_off: !input motion_bypass_lights_off
motion_bypass_lights_stop: !input motion_bypass_lights_stop
bypass_time_delay: !input bypass_time_delay
include_bypass_auto_off: !input include_bypass_auto_off
bypass_auto_off_delay: !input bypass_auto_off_delay
include_sun: !input include_sun
sun_elevation: !input sun_elevation
sun_elevation_rising: !input sun_elevation_rising
include_ambient: !input include_ambient
ambient_light_sensor: !input ambient_light_sensor
ambient_light_options: !input ambient_light_options
ambient_light_value: !input ambient_light_value
ambient_light_high_value: !input ambient_light_high_value
include_time: !input include_time
after_time: !input after_time
before_time: !input before_time
weekday_options: !input weekday_options
include_device_tracker: !input include_device_tracker
zone: !input zone
people: !input people
include_night_lights: !input include_night_lights
night_lights_conditions: !input night_lights_conditions
night_lights_entity_state: !input night_lights_entity_state
night_lights_after_time: !input night_lights_after_time
night_lights_before_time: !input night_lights_before_time
night_lights_sun_elevation: !input night_lights_sun_elevation
night_lights_sun_elevation_rising: !input night_lights_sun_elevation_rising
night_lights: !input night_lights
night_boolean_scenes_scripts: !input night_boolean_scenes_scripts
night_time_delay: !input night_time_delay
include_night_light_control: !input include_night_light_control
night_light_brightness: !input night_light_brightness
night_light_transition_on: !input night_light_transition_on
night_light_transition_off: !input night_light_transition_off
include_night_light_colour_control: !input include_night_light_colour_control
night_light_colour_temperature: !input night_light_colour_temperature
night_light_rgb_colour: !input night_light_rgb_colour
night_light_rgbw_colour: !input night_light_rgbw_colour
night_light_rgbww_colour: !input night_light_rgbww_colour
include_night_glow: !input include_night_glow
night_glow_lights: !input night_glow_lights
include_night_glow_light_control: !input include_night_glow_light_control
night_glow_light_brightness: !input night_glow_light_brightness
night_glow_light_transition_on: !input night_glow_light_transition_on
night_glow_light_transition_off: !input night_glow_light_transition_off
include_night_glow_light_colour_control: !input include_night_glow_light_colour_control
night_glow_light_colour_temperature: !input night_glow_light_colour_temperature
night_glow_light_rgb_colour: !input night_glow_light_rgb_colour
night_glow_light_rgbw_colour: !input night_glow_light_rgbw_colour
night_glow_light_rgbww_colour: !input night_glow_light_rgbww_colour
light_entities_off: "{{ expand(light_switch.entity_id)\n | selectattr('domain',
'eq', 'light')\n | selectattr('state', 'eq', 'off')\n | map(attribute='entity_id')\n
\ | list }}\n"
switch_entities_off: "{{ expand(light_switch.entity_id)\n | selectattr('domain',
'eq', 'switch')\n | selectattr('state', 'eq', 'off')\n | map(attribute='entity_id')|
list }}\n"
light_data: "{% set light = namespace(data={}) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if 'use_brightness' in include_light_control %}\n {% set
light.data = dict(light.data, **{ 'brightness_pct': light_brightness }) %}\n{%
endif %} {% if include_light_colour_control == 'use_colour_temperature' %}\n {%
set light.data = dict(light.data, **{ 'color_temp_kelvin': light_colour_temperature
}) %}\n{% endif %} {% if include_light_colour_control == 'use_rgb_colour' %}\n
\ {% set light.data = dict(light.data, **{ 'rgb_color': light_rgb_colour }) %}\n{%
endif %} {% if include_light_colour_control == 'use_rgbw_colour' %}\n {% set
light.data = dict(light.data, **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif
%} {% if include_light_colour_control == 'use_rgbww_colour' %}\n {% set light.data
= dict(light.data, **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{
light.data }}"
light_entities: "{{ expand(light_switch.entity_id)\n | selectattr('domain', 'eq',
'light')\n | map(attribute='entity_id')\n | list }}\n"
switch_entities: "{{ expand(light_switch.entity_id)\n | selectattr('domain', 'eq',
'switch')\n | map(attribute='entity_id')\n | list }}\n"
scene_entities: "{% set a = light_switch.entity_id %} {% if boolean_scenes_scripts
== [] %}\n {{ expand(a) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id')
| list }}\n{% elif is_state(boolean_scenes_scripts, 'off') %}\n {{ expand(a)
| selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}\n{%
else %}\n []\n{% endif %}"
script_entities: "{% set a = light_switch.entity_id %} {% if boolean_scenes_scripts
== [] %}\n {{ expand(a) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id')
| list }}\n{% elif is_state(boolean_scenes_scripts, 'off') %}\n {{ expand(a)
| selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}\n{%
else %}\n []\n{% endif %}"
boolean_scenes_scripts_helper: "{% if boolean_scenes_scripts | length > 0 and states(boolean_scenes_scripts)
== 'off' %}\n {{ boolean_scenes_scripts }}\n{% else %}\n []\n{% endif %}"
end_scene_entities: '{{ end_scenes | select(''match'', ''^scene\..*'') | list }}'
end_script_entities: '{{ end_scenes | select(''match'', ''^script\..*'') | list
}}'
night_light_entities_off: "{% set b = night_lights and night_lights.entity_id %}
{% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state',
'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
%}"
night_switch_entities_off: "{% set b = night_lights and night_lights.entity_id %}
{% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | selectattr('state',
'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
%}"
night_light_data: "{% set light = namespace(data={}) %} {% if 'use_transition' in
include_night_light_control %}\n {% set light.data = dict(light.data, **{ 'transition':
night_light_transition_on }) %}\n{% endif %} {% if 'use_brightness' in include_night_light_control
%}\n {% set light.data = dict(light.data, **{ 'brightness_pct': night_light_brightness
}) %}\n{% endif %} {% if include_night_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': night_light_colour_temperature
}) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgb_colour'
%}\n {% set light.data = dict(light.data, **{ 'rgb_color': night_light_rgb_colour
}) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgbw_colour'
%}\n {% set light.data = dict(light.data, **{ 'rgbw_color': night_light_rgbw_colour
}) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgbww_colour'
%}\n {% set light.data = dict(light.data, **{ 'rgbww_color': night_light_rgbww_colour
}) %}\n{% endif %} {{ light.data }}"
night_light_entities: "{% set b = night_lights and night_lights.entity_id %} {%
if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_switch_entities: "{% set b = night_lights and night_lights.entity_id %} {%
if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_scene_entities: "{% set b = night_lights and night_lights.entity_id %} {%
if night_boolean_scenes_scripts == [] %}\n {{ expand(b) | selectattr('domain',
'eq', 'scene') | map(attribute='entity_id') | list }}\n{% elif is_state(night_boolean_scenes_scripts,
'off') %}\n {{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_script_entities: "{% set b = night_lights and night_lights.entity_id %} {%
if night_boolean_scenes_scripts == [] %}\n {{ expand(b) | selectattr('domain',
'eq', 'script') | map(attribute='entity_id') | list }}\n{% elif is_state(night_boolean_scenes_scripts,
'off') %}\n {{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_boolean_scenes_scripts_helper: "{% if night_boolean_scenes_scripts | length
> 0 and states(night_boolean_scenes_scripts) == 'off' %}\n {{ night_boolean_scenes_scripts
}}\n{% else %}\n []\n{% endif %}"
night_glow_light_data: "{% set light = namespace(data={}) %} {% if 'use_transition'
in include_night_glow_light_control %}\n {% set light.data = dict(light.data,
**{ 'transition': night_glow_light_transition_on }) %}\n{% endif %} {% if 'use_brightness'
in include_night_glow_light_control %}\n {% set light.data = dict(light.data,
**{ 'brightness_pct': night_glow_light_brightness }) %}\n{% endif %} {% if include_night_glow_light_colour_control
== 'use_colour_temperature' %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
night_glow_light_colour_temperature }) %}\n{% endif %} {% if include_night_glow_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data, **{ 'rgb_color':
night_glow_light_rgb_colour }) %}\n{% endif %} {% if include_night_glow_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, **{ 'rgbw_color':
night_glow_light_rgbw_colour }) %}\n{% endif %} {% if include_night_glow_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, **{ 'rgbww_color':
night_glow_light_rgbww_colour }) %}\n{% endif %} {{ light.data }}"
night_glow_light_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id
%} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_glow_switch_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id
%} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_glow_scene_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id
%} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
night_glow_script_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id
%} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
crossover_night_glow_to_night_lights_light: "{% set a = night_lights and night_lights.entity_id
%} {% set b = night_glow_lights and night_glow_lights.entity_id %} {% if a and
b %}\n {{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'light')
| map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
crossover_night_glow_to_night_lights_switch: "{% set a = night_lights and night_lights.entity_id
%} {% set b = night_glow_lights and night_glow_lights.entity_id %} {% if a and
b %}\n {{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch')
| map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
crossover_night_lights_to_night_glow_light: "{% set a = night_glow_lights and night_glow_lights.entity_id
%} {% set b = night_lights and night_lights.entity_id %} {% if a and b %}\n {{
expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
crossover_night_lights_to_night_glow_switch: "{% set a = night_glow_lights and night_glow_lights.entity_id
%} {% set b = night_lights and night_lights.entity_id %} {% if a and b %}\n {{
expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
crossover_lights_to_night_glow_light: "{% set a = night_glow_lights and night_glow_lights.entity_id
%} {% set b = light_switch.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in',
expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
crossover_lights_to_night_glow_switch: "{% set a = night_glow_lights and night_glow_lights.entity_id
%} {% set b = light_switch.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in',
expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id')
| list }}\n{% else %}\n []\n{% endif %}"
crossover_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights
and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in',
expand(b)) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
crossover_lights_switch: "{% set a = light_switch.entity_id %} {% set b = night_lights
and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in',
expand(b)) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq',
'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
crossover_night_lights_light_on: "{% set b = night_lights and night_lights.entity_id
%} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state',
'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
%}"
crossover_night_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights
and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in',
expand(a)) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
crossover_night_lights_switch: "{% set a = light_switch.entity_id %} {% set b =
night_lights and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) |
reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | selectattr('state',
'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
%}"
crossover_lights_light_on: "{% set a = light_switch.entity_id %} {% if a %}\n {{
expand(a) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}"
dynamic_lighting_state_control_activation_state_inv: "{% if dynamic_lighting_state_control_activation_state
== 'on' %}\n off\n{% else %}\n on\n{% endif %}\n"
triggers:
- trigger: state
id: t0
entity_id: !input motion_trigger
from: 'off'
to: 'on'
- trigger: numeric_state
id: t1
entity_id: sun.sun
attribute: elevation
below: !input sun_elevation
- trigger: numeric_state
id: t2
entity_id: !input ambient_light_sensor
below: !input ambient_light_value
- trigger: time
id: t3
at: !input after_time
- trigger: state
id: t4
entity_id: !input night_lights_entity_state
from: 'off'
to: 'on'
- trigger: time
id: t5
at: !input night_lights_after_time
- trigger: numeric_state
id: t6
entity_id: sun.sun
attribute: elevation
below: !input night_lights_sun_elevation
- trigger: state
id: t7_on
entity_id: !input motion_bypass_lights_on
from: 'off'
to: 'on'
- trigger: state
id: t7_off
entity_id: !input motion_bypass_lights_off
from: 'off'
to: 'on'
- trigger: state
id: t7_stop
entity_id: !input motion_bypass_lights_stop
from: 'off'
to: 'on'
- trigger: state
id: t8_on
entity_id: !input motion_bypass_lights_on
from: 'on'
to: 'off'
- trigger: state
id: t8_off
entity_id: !input motion_bypass_lights_off
from: 'on'
to: 'off'
- trigger: state
id: t8_stop
entity_id: !input motion_bypass_lights_stop
from: 'on'
to: 'off'
- trigger: numeric_state
id: t9
entity_id: sun.sun
attribute: elevation
above: !input sun_elevation_rising
- trigger: numeric_state
id: t10
entity_id: !input ambient_light_sensor
above: !input ambient_light_high_value
- trigger: time
id: t11
at: !input before_time
- trigger: state
id: t12
entity_id: !input night_lights_entity_state
from: 'on'
to: 'off'
- trigger: time
id: t13
at: !input night_lights_before_time
- trigger: numeric_state
id: t14
entity_id: sun.sun
attribute: elevation
above: !input night_lights_sun_elevation_rising
- trigger: state
id: t15
entity_id: !input dynamic_lighting_state_control_entity
to: !input dynamic_lighting_state_control_activation_state
- trigger: state
id: t16
entity_id: !input dynamic_lighting_state_control_entity
from: !input dynamic_lighting_state_control_activation_state
- trigger: homeassistant
id: t17
event: start
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id: t0
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
- condition: and
conditions:
- condition: trigger
id: t1
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- '{{ include_sun == ''sun_enabled'' }}'
- condition: and
conditions:
- condition: trigger
id: t2
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- '{{ include_ambient == ''ambient_enabled'' }}'
- condition: and
conditions:
- condition: trigger
id: t3
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- '{{ include_time == ''time_enabled'' }}'
- condition: and
conditions:
- condition: trigger
id: t4
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''entity_state_enabled'' in night_lights_conditions }}'
- condition: state
entity_id: !input night_lights_entity_state
match: any
state: 'on'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t5
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''time_enabled'' in night_lights_conditions }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t6
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''sun_enabled'' in night_lights_conditions }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t7_on
- '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t7_off
- '{{ ''bypass_enabled_turn_off'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t7_stop
- '{{ ''bypass_enabled_stop'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t8_on
- '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t8_off
- '{{ ''bypass_enabled_turn_off'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t8_stop
- '{{ ''bypass_enabled_stop'' in include_bypass }}'
- condition: and
conditions:
- condition: trigger
id: t9
- '{{ include_sun == ''sun_enabled'' }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t10
- '{{ include_ambient == ''ambient_enabled'' }}'
- '{{ ambient_light_options == ''ambient_light_option_disabled'' }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t11
- '{{ include_time == ''time_enabled'' }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t12
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''entity_state_enabled'' in night_lights_conditions }}'
- condition: state
entity_id: !input night_lights_entity_state
state: 'off'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t13
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''time_enabled'' in night_lights_conditions }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t14
- '{{ include_night_lights == ''night_lights_enabled'' }}'
- '{{ ''sun_enabled'' in night_lights_conditions }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow
== ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id:
- t15
- t16
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- '{{ dynamic_lighting_state_control == ''enable_state_control'' }}'
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t17
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
| list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
- condition: and
conditions:
- condition: trigger
id: t17
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
- condition: and
conditions:
- condition: trigger
id: t17
- '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_off''
in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: or
conditions:
- '{{ include_bypass == [] }}'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: trigger
id:
- t7_on
- t7_off
- t7_stop
- t8_on
- t8_off
- t8_stop
- t17
- condition: or
conditions:
- '{{ include_sun == ''sun_disabled'' }}'
- '{{ include_sun == ''sun_enabled_night_lights'' }}'
- '{{ (include_sun == ''sun_enabled'') and (is_state_attr(''sun.sun'', ''rising'',
false)) and (state_attr(''sun.sun'',''elevation'') <= sun_elevation | float(90))
}}'
- '{{ (include_sun == ''sun_enabled'') and (is_state_attr(''sun.sun'', ''rising'',
true)) and (state_attr(''sun.sun'',''elevation'') <= sun_elevation_rising | float(90))
}}'
- condition: trigger
id:
- t7_on
- t7_off
- t7_stop
- t8_on
- t8_off
- t8_stop
- t9
- condition: or
conditions:
- '{{ include_ambient == ''ambient_disabled'' }}'
- '{{ ambient_light_sensor == [] }}'
- '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor)
| int) < (ambient_light_value | int)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor)
| int) < (ambient_light_high_value | int)) and (expand(light_switch.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor)
| int) < (ambient_light_high_value | int)) and ((include_night_lights == ''night_lights_enabled'')
and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') |
list | count > 0)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options == ''ambient_light_option_enabled'')
and (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'') |
list | count > 0) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options == ''ambient_light_option_enabled'')
and ((include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0)) }}'
- condition: and
conditions:
- '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor)
| int) < (ambient_light_high_value | int)) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: and
conditions:
- '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor)
| int) < (ambient_light_high_value | int)) }}'
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: and
conditions:
- '{{ (include_ambient == ''ambient_enabled'') and ( ambient_light_options ==
''ambient_light_option_enabled'' ) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: and
conditions:
- '{{ (include_ambient == ''ambient_enabled'') and ( ambient_light_options ==
''ambient_light_option_enabled'' ) }}'
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
'on') }}\n{% endif %}"
- condition: trigger
id:
- t7_on
- t7_off
- t7_stop
- t8_on
- t8_off
- t8_stop
- t10
- condition: or
conditions:
- '{{ include_time == ''time_disabled'' }}'
- condition: and
conditions:
- condition: time
after: !input after_time
before: !input before_time
weekday: !input weekday_options
- '{{ include_time == ''time_enabled'' }}'
- condition: trigger
id:
- t7_on
- t7_off
- t7_stop
- t8_on
- t8_off
- t8_stop
- t11
- condition: or
conditions:
- '{{ include_device_tracker == ''device_tracker_disabled'' }}'
- condition: and
conditions:
- '{{ include_device_tracker == ''zone_enabled'' }}'
- condition: numeric_state
entity_id: !input zone
above: 0
- condition: and
conditions:
- '{{ include_device_tracker == ''zone_people_enabled'' }}'
- '{{ (state_attr(zone, ''persons'') | list | select(''in'', people) | list |
length) > 0 }}'
- condition: trigger
id:
- t7_on
- t7_off
- t7_stop
- t8_on
- t8_off
- t8_stop
action:
- choose:
- alias: Check if night lights are enabled and within conditions
conditions:
- condition: and
conditions:
- alias: Check if night lights is enabled
condition: template
value_template: '{{ include_night_lights == ''night_lights_enabled'' }}'
- alias: Check if night lights entity state is enabled
condition: or
conditions:
- '{{ (''time_enabled'' in night_lights_conditions) and not (''entity_state_enabled''
in night_lights_conditions) }}'
- '{{ (''sun_enabled'' in night_lights_conditions) and not (''entity_state_enabled''
in night_lights_conditions) }}'
- condition: and
conditions:
- '{{ ''entity_state_enabled'' in night_lights_conditions }}'
- condition: state
entity_id: !input night_lights_entity_state
state: 'on'
match: any
- alias: Check if night lights time is enabled
condition: or
conditions:
- '{{ (''entity_state_enabled'' in night_lights_conditions) and not (''time_enabled''
in night_lights_conditions) }}'
- '{{ (''sun_enabled'' in night_lights_conditions) and not (''time_enabled''
in night_lights_conditions) }}'
- condition: and
conditions:
- '{{ ''time_enabled'' in night_lights_conditions }}'
- condition: time
after: !input night_lights_after_time
before: !input night_lights_before_time
- alias: Check if night lights sun is enabled
condition: or
conditions:
- '{{ (''entity_state_enabled'' in night_lights_conditions) and not (''sun_enabled''
in night_lights_conditions) }}'
- '{{ (''time_enabled'' in night_lights_conditions) and not (''sun_enabled''
in night_lights_conditions) }}'
- '{{ (''sun_enabled'' in night_lights_conditions) and (((is_state_attr(''sun.sun'',
''rising'', false)) and (state_attr(''sun.sun'',''elevation'') <= night_lights_sun_elevation
| float(90))) or ((is_state_attr(''sun.sun'', ''rising'', true)) and (state_attr(''sun.sun'',''elevation'')
<= night_lights_sun_elevation_rising | float(90)))) }}'
sequence:
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- choose:
- alias: By-pass is turned on & check by-pass option - Turn lights off
conditions:
- condition: trigger
id: t7_off
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
data:
transition: '{{ night_light_transition_off }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
data:
transition: '{{ night_glow_light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_switch_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_lights_switch }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
sequence:
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- alias: By-pass is turned on & check by-pass option - Keep the current lights
state
conditions:
- condition: trigger
id: t7_stop
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- choose:
- alias: By-pass is turned off & check if the motion trigger is off
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
- condition: state
entity_id: !input motion_trigger
match: all
state: 'off'
sequence:
- choose:
- alias: Check all by-pass are off
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If night glow is disabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_disabled''
}}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_switch_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- stop: Stop the automation
- alias: If night glow is enabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn on the lights
action: light.turn_on
target:
entity_id: '{{ night_glow_light_entities }}'
data: '{{ night_glow_light_data }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn OFF crossover night lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_light
}}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn OFF crossover lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_to_night_glow_light }}'
data:
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn OFF crossover night lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_light
}}'
- alias: Turn OFF crossover lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_to_night_glow_light }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_glow_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_on }}'
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
transition: '{{ night_glow_light_transition_on }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
- alias: Turn on the switches
action: switch.turn_on
target:
entity_id: '{{ night_glow_switch_entities }}'
- alias: Turn OFF crossover night switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_switch }}'
- alias: Turn OFF crossover light switches
action: switch.turn_off
target:
entity_id: '{{ crossover_lights_to_night_glow_switch }}'
- alias: Turn on the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn on the script
action: script.turn_on
data:
entity_id: '{{ night_glow_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- stop: Stop the automation
- alias: Motion trigger is off and check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time
delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- alias: By-pass is turned off & check if the motion trigger is on
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
sequence:
- choose:
- alias: Check all by-pass are off and check conditions if enabled
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: or
conditions:
- '{{ (include_sun == ''sun_enabled'') and (state_attr(''sun.sun'',''elevation'')
>= sun_elevation | float(90)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_disabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_enabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''off'') | list | count > 0) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_enabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) and (is_state(night_boolean_scenes_scripts,
''off'')) }}'
- condition: and
conditions:
- '{{ include_time == ''time_enabled'' }}'
- condition: time
after: !input before_time
before: !input after_time
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- stop: Stop the automation
- alias: Motion trigger is on and check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time
delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- alias: By-pass is turned off & reset lights to the site conditions
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
data:
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_lights_switch }}'
- choose:
- alias: Check if normal lights Scenes & Scripts - Toggle Helper is
on
conditions:
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the input boolean normal lights
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn ON lights
action: light.turn_on
target:
entity_id: '{{ crossover_night_lights_light_on }}'
data: '{{ night_light_data }}'
- choose:
- alias: Sun, ambient & time above setting to turn off
conditions:
- condition: trigger
id:
- t9
- t10
- t11
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
data:
transition: '{{ night_light_transition_off }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
data:
transition: '{{ night_glow_light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_switch_entities }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
sequence:
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the input boolean night lights
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- stop: Stop the automation
- alias: Turn off normal lights when trigger by start night lights conditions
conditions:
- condition: trigger
id:
- t4
- t5
- t6
sequence:
- choose:
- alias: light - switch - scene - script is ON
conditions:
- condition: or
conditions:
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='',
''on'') | list | count > 0) }}'
- '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
- condition: template
value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
'on') }}\n{% endif %}"
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
data:
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_lights_light }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- choose:
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the input boolean normal lights
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn ON lights
action: light.turn_on
target:
entity_id: '{{ crossover_night_lights_light_on }}'
data: '{{ night_light_data }}'
- alias: Turn on night glow lights if all lights are off
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: template
value_template: '{{ (expand(light_switch.entity_id) | selectattr(''state'',
''=='', ''off'') | list | count > 0) or (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''off'') | list | count > 0) or (is_state(boolean_scenes_scripts,
''off'')) }}
'
sequence:
- alias: Turn on the lights
action: light.turn_on
target:
entity_id: '{{ night_glow_light_entities }}'
data: '{{ night_glow_light_data }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_glow_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
transition: '{{ night_glow_light_transition_on }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_glow_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
- alias: Turn on the switches
action: switch.turn_on
target:
entity_id: '{{ night_glow_switch_entities }}'
- alias: Turn on the script
action: script.turn_on
data:
entity_id: '{{ night_glow_script_entities }}'
- stop: Stop the automation
- alias: If manage scripts is enabled
conditions:
- '{{ ''manage_scripts_crossing_over'' in include_night_light_control
}}'
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='',
''off'') | list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
''=='', ''off'') | list | count > 0) or (is_state(boolean_scenes_scripts,
''off'')) }}'
sequence:
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- stop: Stop the automation
- alias: Safe Guard when HA restarts
conditions:
- condition: trigger
id: t17
sequence:
- choose:
- alias: Check all by-pass are off and check conditions if enabled
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
sequence:
- alias: Small time delay required
delay:
seconds: 1
- alias: Check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass auto off is enabled and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time
delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- choose:
- alias: If night glow is disabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_disabled'' }}'
sequence:
- alias: Turn ON lights
action: light.turn_on
target:
entity_id: '{{ night_light_entities_off }}'
data: '{{ night_light_data }}'
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This is
for scenes only when crossing over
conditions:
- condition: template
value_template: "{% if boolean_scenes_scripts == [] %}\n false\n{%
elif is_state(boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n
\ false\n{% endif %}"
sequence:
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: '{{ boolean_scenes_scripts }}'
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This
is for scenes only when crossing over
conditions:
- '{{ night_boolean_scenes_scripts != [] }}'
sequence:
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn on the night scenes
action: scene.turn_on
target:
entity_id: '{{ night_scene_entities }}'
data:
transition: '{{ night_light_transition_on }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn on the night scenes
action: scene.turn_on
target:
entity_id: '{{ night_scene_entities }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: Turn on the night switches
action: switch.turn_on
target:
entity_id: '{{ night_switch_entities_off }}'
- alias: Turn on the night scripts
action: script.turn_on
target:
entity_id: '{{ night_script_entities }}'
- alias: If night glow is enabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: not
conditions:
- condition: trigger
id:
- t15
- t16
sequence:
- alias: Turn ON lights
action: light.turn_on
target:
entity_id: '{{ night_light_entities }}'
data: '{{ night_light_data }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_glow_light_control
}}'
sequence:
- alias: Turn OFF crossover night glow lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
data:
transition: '{{ night_glow_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_glow_light_control
}}'
sequence:
- alias: Turn OFF crossover night glow lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This is
for scenes only when crossing over
conditions:
- condition: template
value_template: "{% if boolean_scenes_scripts == [] %}\n false\n{%
elif is_state(boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n
\ false\n{% endif %}"
sequence:
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: '{{ boolean_scenes_scripts }}'
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This
is for scenes only when crossing over
conditions:
- '{{ night_boolean_scenes_scripts != [] }}'
sequence:
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn on the night scenes
action: scene.turn_on
target:
entity_id: '{{ night_scene_entities }}'
data:
transition: '{{ night_light_transition_on }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn on the night scenes
action: scene.turn_on
target:
entity_id: '{{ night_scene_entities }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ night_boolean_scenes_scripts_helper }}'
- alias: Turn on the night switches
action: switch.turn_on
target:
entity_id: '{{ night_switch_entities }}'
- alias: Turn off crossover night glow switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- alias: Turn on the night scripts
action: script.turn_on
target:
entity_id: '{{ night_script_entities }}'
- choose:
- alias: By-pass is enabled & check by-pass option - Turn lights on
conditions:
- condition: trigger
id: t7_on
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- choose:
- alias: Check if the trigger is on and wait for it to go off
conditions:
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
sequence:
- alias: Wait until motion sensor is off
wait_for_trigger:
- trigger: state
entity_id: !input motion_trigger
from: 'on'
to: 'off'
- alias: Wait the number of minutes set in the night lights time delay
delay:
minutes: !input night_time_delay
- choose:
- alias: If night glow is disabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_disabled'' }}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- alias: If night glow is enabled
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
sequence:
- alias: Turn on the lights
action: light.turn_on
target:
entity_id: '{{ night_glow_light_entities }}'
data: '{{ night_glow_light_data }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn OFF crossover night lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_light }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn OFF crossover night lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_light }}'
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_glow_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
transition: '{{ night_glow_light_transition_on }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
data:
entity_id: '{{ night_glow_scene_entities }}'
- alias: Turn on the switches
action: switch.turn_on
target:
entity_id: '{{ night_glow_switch_entities }}'
- alias: Turn OFF crossover night switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_to_night_glow_switch }}'
- alias: Turn on the script
action: script.turn_on
data:
entity_id: '{{ night_glow_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
default:
- choose:
- alias: By-pass is turned on & check by-pass option - Turn lights off
conditions:
- condition: trigger
id: t7_off
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If night lights are disabled
conditions:
- condition: template
value_template: '{{ include_night_lights == ''night_lights_disabled''
}}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- alias: If night lights are enabled
conditions:
- condition: template
value_template: '{{ include_night_lights == ''night_lights_enabled'' }}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
data:
transition: '{{ light_transition_off }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_switch }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
sequence:
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- alias: By-pass is turned on & check by-pass option - Keep the current lights
state
conditions:
- condition: trigger
id: t7_stop
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- choose:
- alias: By-pass is turned off & check if the motion trigger is off
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
- condition: state
entity_id: !input motion_trigger
match: all
state: 'off'
sequence:
- choose:
- alias: Check all by-pass are off
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If night lights are disabled
conditions:
- condition: template
value_template: '{{ include_night_lights == ''night_lights_disabled''
}}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{
is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- stop: Stop the automation
- alias: If night lights are enabled
conditions:
- condition: template
value_template: '{{ include_night_lights == ''night_lights_enabled''
}}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the night lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
data:
transition: '{{ light_transition_off }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light
}}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light
}}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_switch }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{
is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- stop: Stop the automation
- alias: Motion trigger is off and check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- alias: By-pass is turned off & check if the motion trigger is on
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
sequence:
- choose:
- alias: Check all by-pass are off and check conditions if enabled
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: or
conditions:
- '{{ (include_sun == ''sun_enabled'') and (state_attr(''sun.sun'',''elevation'')
>= sun_elevation | float(90)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_disabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_enabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) and (expand(light_switch.entity_id)
| selectattr(''state'', ''=='', ''off'') | list | count > 0) }}'
- '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
== ''ambient_light_option_enabled'') and ((states(ambient_light_sensor)
| int) > (ambient_light_value | int)) and (is_state(boolean_scenes_scripts,
''off'')) }}'
- condition: and
conditions:
- condition: time
after: !input before_time
before: !input after_time
- '{{ include_time == ''time_enabled'' }}'
sequence:
- alias: Wait the number of minutes set in the by-pass time delay
delay:
minutes: !input bypass_time_delay
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- stop: Stop the automation
- alias: Motion trigger is on and check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- alias: By-pass is turned off & reset lights to the site conditions
conditions:
- condition: trigger
id:
- t8_on
- t8_off
- t8_stop
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
data:
transition: '{{ night_light_transition_off }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
data:
transition: '{{ night_glow_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled''
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_light }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_switch }}'
- choose:
- alias: If night glow is selected
conditions:
- condition: template
value_template: '{{ include_night_glow == ''night_glow_enabled'' }}'
sequence:
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_glow_to_night_lights_switch }}'
- choose:
- alias: Check if night lights scenes & scripts - toggle helper is on
conditions:
- condition: template
value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{
is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}"
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the input boolean night lights
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Turn ON lights
conditions:
- alias: Check the dynamic lighting options
condition: or
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting''
}}'
- alias: Check that dynamic lighting is active and the state control
option is enabled
condition: and
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: '{{ dynamic_lighting_state_control == ''enable_state_control''
}}'
- condition: template
value_template: '{{ states(dynamic_lighting_state_control_entity)
== dynamic_lighting_state_control_activation_state_inv }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ crossover_lights_light_on }}'
data: '{{ light_data }}'
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{
is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- choose:
- alias: Sun, ambient & time above setting to turn off
conditions:
- condition: trigger
id:
- t9
- t10
- t11
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the input boolean night lights
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- stop: Stop the automation
- alias: Turn off night lights when trigger by end night lights conditions
conditions:
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- choose:
- alias: If the night glow is enabled
conditions:
- '{{ include_night_glow == ''night_glow_enabled'' }}'
- condition: state
entity_id: !input motion_trigger
state: 'off'
for:
minutes: !input night_time_delay
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_glow_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_glow_light_entities }}'
data:
transition: '{{ night_glow_light_transition_off}}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_glow_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_glow_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ night_glow_light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ night_glow_switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- stop: Stop the automation
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ (expand(light_switch.entity_id) | selectattr(''state'',
''=='', ''on'') | list | count > 0) or (expand(night_lights.entity_id)
| selectattr(''state'', ''=='', ''on'') | list | count > 0) or (is_state(night_boolean_scenes_scripts,
''on'')) }}
'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
data:
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ crossover_night_lights_light }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ crossover_night_lights_switch }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- choose:
- alias: Adjust the lights settings when crossing over if lights are ON
is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
sequence:
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_night_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ night_light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_night_light_control
}}'
sequence:
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the input boolean night lights
action: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: Turn ON lights
conditions:
- alias: Check the dynamic lighting options
condition: or
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting''
}}'
- alias: Check that dynamic lighting is active and the state control
option is enabled
condition: and
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: '{{ dynamic_lighting_state_control == ''enable_state_control''
}}'
- condition: template
value_template: '{{ states(dynamic_lighting_state_control_entity)
== dynamic_lighting_state_control_activation_state_inv }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ crossover_lights_light_on }}'
data: '{{ light_data }}'
- alias: If manage scripts is enabled
conditions:
- '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}'
- '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''off'')
| list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
''=='', ''off'') | list | count > 0) or (is_state(night_boolean_scenes_scripts,
''off'')) }}'
sequence:
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- stop: Stop the automation
- alias: Safe Guard when HA restarts
conditions:
- condition: trigger
id: t17
sequence:
- choose:
- alias: Check all by-pass are off and check conditions if enabled
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
state: 'off'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
state: 'off'
sequence:
- alias: Small time delay required
delay:
seconds: 1
- alias: Check if any by-passes are on
conditions:
- condition: or
conditions:
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: or
conditions:
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_on
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_off
match: any
state: 'on'
- condition: and
conditions:
- '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
}}'
- condition: state
entity_id: !input motion_bypass_lights_stop
match: any
state: 'on'
sequence:
- alias: Check by-pass auto off is enabled and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
- alias: Parallel actions for dynamic lighting and normal lights
parallel:
- sequence:
- alias: Check if the dynamic lighting is enabled
condition: and
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- alias: Check the dynamic lighting state control option
condition: or
conditions:
- condition: template
value_template: '{{ dynamic_lighting_state_control == ''disable_state_control''
}}'
- alias: Check if the dynamic lighting state control option is enabled
condition: and
conditions:
- condition: template
value_template: '{{ dynamic_lighting_state_control == ''enable_state_control''
}}'
- condition: state
entity_id: !input dynamic_lighting_state_control_entity
state: !input dynamic_lighting_state_control_activation_state
- choose:
- alias: Dynamic Lighting - Input Boolean Helper
conditions:
- condition: template
value_template: '{{ dynamic_lighting_boolean != [] }}'
sequence:
- alias: Turn on the boolean for dynamic lighting
action: input_boolean.turn_on
data:
entity_id: !input dynamic_lighting_boolean
- choose:
- alias: 1 - Dynamic Lighting - Lux Controlled Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness''}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_max_lux - dynamic_lighting_min_lux) %} {%
set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_max_brightness
%} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id')
| list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255 * 100
/ lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n
\ {% set bv = dynamic_lighting_max_brightness %}\n{% elif lux
>= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% elif
(bv > lp) and (dynamic_lighting_max_brightness - lp) <= dynamic_lighting_dead_zone
%}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif
(lp > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif
(bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}\n {%
set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n {% set bv = lp %}\n{% elif bv > (lp + dynamic_lighting_step_value)
%}\n {% set bv = lp + dynamic_lighting_step_value %}\n{% elif
bv < (lp - dynamic_lighting_step_value) %}\n {% set bv = lp -
dynamic_lighting_step_value %}\n{% endif %} {{ bv | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_max_lux - dynamic_lighting_min_lux) %} {%
set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_max_brightness
%} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id')
| list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255 * 100
/ lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n
\ {% set bv = dynamic_lighting_max_brightness %}\n{% elif lux
>= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness
- lp) <= dynamic_lighting_dead_zone %}\n false\n{% elif (lp >
bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n true\n{% else %}\n false\n{% endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If dynamic lighting brightness is in the dead zone
conditions: '{{ in_dead_zone }}'
sequence:
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set the dynamic lighting brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: 2 - Dynamic Lighting - Lux Controlled Brightness - Inverted
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness_inv''}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_min_lux - dynamic_lighting_max_lux) %} {%
set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_min_brightness
%} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id')
| list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255 * 100
/ lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n
\ {% set bv = dynamic_lighting_min_brightness %}\n{% elif lux
>= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% elif
(bv > lp) and (dynamic_lighting_max_brightness - lp) <= dynamic_lighting_dead_zone
%}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif
(lp > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif
(bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}\n {%
set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n {% set bv = lp %}\n{% elif bv > (lp + dynamic_lighting_step_value)
%}\n {% set bv = lp + dynamic_lighting_step_value %}\n{% elif
bv < (lp - dynamic_lighting_step_value) %}\n {% set bv = lp -
dynamic_lighting_step_value %}\n{% endif %} {{ bv | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_min_lux - dynamic_lighting_max_lux) %} {%
set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_min_brightness
%} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id')
| list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255 * 100
/ lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n
\ {% set bv = dynamic_lighting_min_brightness %}\n{% elif lux
>= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness
- lp) <= dynamic_lighting_dead_zone %}\n true\n{% elif (lp >
bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n true\n{% else %}\n false\n{% endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If dynamic lighting brightness is in the dead zone
conditions: '{{ in_dead_zone }}'
sequence:
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set dynamic lighting brightness inverted for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: 3 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %} {% set end_slope =
(dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n {% elif elevation <=
dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n{% endif %} {{ colour_temp_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if 'use_brightness' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'brightness_pct':
light_brightness }) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising
- 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising
+ 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling
+ 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n
\ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising
+ 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling
- 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising
- 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n
\ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If sun elevation is outside the adjustment zone and the lights
are ON
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set dynamic sun elevation colour temperature for the normal
lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 4 - Dynamic Lighting - Sun Elevation Lighting - Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun',
'elevation') | float %} {% set start_slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_brightness %} {% set end_slope =
(dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_brightness %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_max_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
should_wait: "{% set le = light_entities %} {% set lec = expand(le)
| map(attribute='entity_id') | list | length %} {% set lp = (expand(le)
| map(attribute='attributes.brightness') | reject('equalto', None)
| sum | float(default=255) / 255 * 100 / lec) | round(0) %} {%
set elevation = state_attr('sun.sun', 'elevation') | float %}
{% set start_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising)
%} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_brightness %} {% set end_slope =
(dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_brightness %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_max_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% endif %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if (brightness_value >=
(lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n
\ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If lights are ON and the lights are within 1% of the actual
brightness
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set dynamic sun elevation lighting brightness for the normal
lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 5 - Dynamic Lighting - Sun Elevation Lighting - Brightness Inverted
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness_inv''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun',
'elevation') | float %} {% set start_slope = (dynamic_lighting_max_brightness
- dynamic_lighting_min_brightness) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_min_brightness %} {% set end_slope =
(dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_max_brightness %} {% if elevation > -10
%}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_min_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
should_wait: "{% set le = light_entities %} {% set lec = expand(le)
| map(attribute='entity_id') | list | length %} {% set lp = (expand(le)
| map(attribute='attributes.brightness') | reject('equalto', None)
| sum | float(default=255) / 255 * 100 / lec) | round(0) %} {%
set elevation = state_attr('sun.sun', 'elevation') | float %}
{% set start_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising)
%} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_min_brightness %} {% set end_slope =
(dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_max_brightness %} {% if elevation > -10
%}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_min_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if (brightness_value >=
(lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n
\ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If lights are ON and the lights are within 1% of the actual
brightness
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set dynamic sun elevation lighting brightness inverted for
the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 6 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %} {% set end_slope =
(dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n {% elif elevation <=
dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n{% endif %} {{ colour_temp_value | round(0) }}\n"
dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun',
'elevation') | float %} {% set start_slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_brightness %} {% set end_slope =
(dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_brightness %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_max_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin
}) %} {% set light.data = dict(light.data, **{ 'brightness_pct':
dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set le = light_entities %} {% set lec = expand(le)
| map(attribute='entity_id') | list | length %} {% set lp = (expand(le)
| map(attribute='attributes.brightness') | reject('equalto', None)
| sum | float(default=255) / 255 * 100 / lec) | round(0) %} {%
set elevation = state_attr('sun.sun', 'elevation') | float %}
{% set start_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising)
%} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_brightness %} {% set end_slope =
(dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_brightness %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_max_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% endif %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if (brightness_value >=
(lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n
\ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If lights are ON and the lights are within 1% of the actual
brightness
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set dynamic sun elevation lighting brightness and dynamic
sun elevation colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 7 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Brightness
Inverted
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness_inv''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %} {% set end_slope =
(dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %} {% if elevation >=
-10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n {% elif elevation <=
dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n{% endif %} {{ colour_temp_value | round(0) }}\n"
dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun',
'elevation') | float %} {% set start_slope = (dynamic_lighting_max_brightness
- dynamic_lighting_min_brightness) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_min_brightness %} {% set end_slope =
(dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_max_brightness %} {% if elevation > -10
%}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_min_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin
}) %} {% set light.data = dict(light.data, **{ 'brightness_pct':
dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set le = light_entities %} {% set lec = expand(le)
| map(attribute='entity_id') | list | length %} {% set lp = (expand(le)
| map(attribute='attributes.brightness') | reject('equalto', None)
| sum | float(default=255) / 255 * 100 / lec) | round(0) %} {%
set elevation = state_attr('sun.sun', 'elevation') | float %}
{% set start_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising)
%} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_min_brightness %} {% set end_slope =
(dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_max_brightness %} {% if elevation > -10
%}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising and
is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif
elevation <= dynamic_lighting_sun_elevation_start_falling and
elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun',
'rising', false) %}\n {% set brightness_value = ((end_slope
* elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n {% else %}\n {% set
brightness_value = dynamic_lighting_min_brightness %}\n {% endif
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if (brightness_value >=
(lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n
\ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If lights are ON and the lights are within 1% of the actual
brightness
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set dynamic sun elevation lighting brightness and dynamic
sun elevation colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 8 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux
Controlled Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness''
}}'
sequence:
- alias: Parallel actions for dynamic lighting
parallel:
- sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0))
or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean,
''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
- dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
* -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
%} {% set lec = expand(le) | map(attribute='entity_id') |
list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255
* 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux
%}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif
lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{%
elif (bv > lp) and (dynamic_lighting_max_brightness - lp)
<= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% elif (lp > bv) and (lp - dynamic_lighting_min_brightness)
<= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <=
dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% elif
bv > (lp + dynamic_lighting_step_value) %}\n {% set bv =
lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - dynamic_lighting_step_value)
%}\n {% set bv = lp - dynamic_lighting_step_value %}\n{%
endif %} {{ bv | round(0) }}\n"
dynamic_kelvin: "{% if expand(light_entities) | selectattr('state',
'==', 'off') | list | count > 0 %}\n {% set elevation = state_attr('sun.sun',
'elevation') | float %}\n {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %}\n {% set
start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %}\n {% set end_slope
= (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%}\n {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %}\n {% if elevation
>= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {%
set colour_temp_value = ((start_slope * elevation) + start_ak)
| round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling
and elevation >= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {%
set colour_temp_value = ((end_slope * elevation) + end_ak)
| round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {%
set colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {%
set colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n {% else %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n {% endif %}\n {{
colour_temp_value | round(0) }}\n{% endif %}\n"
dynamic_light_off_data: "{% set light = namespace(data={}) %}
{% set light.data = dict(light.data, **{ 'brightness_pct':
dynamic_brightness_pct }) %} {% set light.data = dict(light.data,
**{ 'color_temp_kelvin': dynamic_kelvin }) %} {% if 'use_transition'
in include_light_control %}\n {% set light.data = dict(light.data,
**{ 'transition': light_transition_on }) %}\n{% endif %} {{
light.data }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {%
set light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n
\ {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {{ light.data }}\n"
in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
- dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
* -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
%} {% set lec = expand(le) | map(attribute='entity_id') |
list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255
* 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux
%}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif
lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness
- lp) <= dynamic_lighting_dead_zone %}\n false\n{% elif (lp
> bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n true\n{% else %}\n false\n{% endif %}\n"
- choose:
- alias: Check if the light is off
conditions: '{{ expand(light_entities) | selectattr(''state'',
''=='', ''off'') | list | count > 0 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is off
delay:
milliseconds: 100
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights
are ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is on
delay:
milliseconds: 100
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or
state control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is on
delay:
milliseconds: 100
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If dynamic lighting brightness is in the dead zone
conditions: '{{ in_dead_zone }}'
sequence:
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set dynamic lighting lux brightness and dynamic sun elevation
colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness''
}}'
- '{{ expand(light_entities) | selectattr(''state'', ''=='',
''off'') | list | count > 0 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_off_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set dynamic lighting lux brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0))
or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean,
''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %} {% set end_slope
= (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %} {% if elevation
>= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set
colour_temp_value = ((start_slope * elevation) + start_ak)
| round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling
and elevation >= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set
colour_temp_value = ((end_slope * elevation) + end_ak) | round(1)
%}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set
colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set
colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n{% else %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n{% endif %} {{ colour_temp_value
| round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {%
set light.data = dict(light.data, **{ 'color_temp_kelvin':
dynamic_kelvin }) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition':
light_transition_on }) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising
- 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising
+ 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling
+ 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n
\ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising
+ 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling
- 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising
- 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n
\ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights
are ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or
state control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If sun elevation is outside the adjustment zone and the
lights are ON
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If the lights are OFF
conditions: '{{ expand(light_entities) | selectattr(''state'',
''=='', ''off'') | list | count > 0 }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set sun elevation colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 9 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux
Controlled Brightness Inverted
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv''
}}'
sequence:
- alias: Parallel actions for dynamic lighting
parallel:
- sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0))
or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean,
''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_min_lux
- dynamic_lighting_max_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
* -1) + dynamic_lighting_min_brightness %} {% set le = light_entities
%} {% set lec = expand(le) | map(attribute='entity_id') |
list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255
* 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux
%}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif
lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{%
elif (bv > lp) and (dynamic_lighting_max_brightness - lp)
<= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% elif (lp > bv) and (lp - dynamic_lighting_min_brightness)
<= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_min_brightness
%}\n{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv)
<= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{%
elif bv > (lp + dynamic_lighting_step_value) %}\n {% set
bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp
- dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value
%}\n{% endif %} {{ bv | round(0) }}\n"
dynamic_kelvin: "{% if expand(light_entities) | selectattr('state',
'==', 'off') | list | count > 0 %}\n {% set elevation = state_attr('sun.sun',
'elevation') | float %}\n {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %}\n {% set
start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %}\n {% set end_slope
= (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%}\n {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %}\n {% if elevation
>= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {%
set colour_temp_value = ((start_slope * elevation) + start_ak)
| round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling
and elevation >= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {%
set colour_temp_value = ((end_slope * elevation) + end_ak)
| round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {%
set colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {%
set colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n {% else %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n {% endif %}\n {{
colour_temp_value | round(0) }}\n{% endif %}\n"
dynamic_light_off_data: "{% set light = namespace(data={}) %}
{% set light.data = dict(light.data, **{ 'brightness_pct':
dynamic_brightness_pct }) %} {% set light.data = dict(light.data,
**{ 'color_temp_kelvin': dynamic_kelvin }) %} {% if 'use_transition'
in include_light_control %}\n {% set light.data = dict(light.data,
**{ 'transition': light_transition_on }) %}\n{% endif %} {{
light.data }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {%
set light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n
\ {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {{ light.data }}\n"
in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor)
| float %} {% set slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (dynamic_lighting_min_lux
- dynamic_lighting_max_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
* -1) + dynamic_lighting_min_brightness %} {% set le = light_entities
%} {% set lec = expand(le) | map(attribute='entity_id') |
list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness')
| reject('equalto', None) | sum | float(default=255) / 255
* 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux
%}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif
lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness
%}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1)
%}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness
- lp) <= dynamic_lighting_dead_zone %}\n true\n{% elif (lp
> bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone
%}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone
%}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone
%}\n true\n{% else %}\n false\n{% endif %}\n"
- choose:
- alias: Check if the light is off
conditions: '{{ expand(light_entities) | selectattr(''state'',
''=='', ''off'') | list | count > 0 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is off
delay:
milliseconds: 100
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights
are ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is on
delay:
milliseconds: 100
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or
state control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- alias: Delay for parallel actions needed for when the light
is on
delay:
milliseconds: 100
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If dynamic lighting brightness is in the dead zone
conditions: '{{ in_dead_zone }}'
sequence:
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set dynamic lighting lux brightness and dynamic sun elevation
colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv''
}}'
- '{{ expand(light_entities) | selectattr(''state'', ''=='',
''off'') | list | count > 0 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_off_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Set dynamic lighting lux brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0))
or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean,
''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
- dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
= (( start_slope * dynamic_lighting_sun_elevation_end_rising)
* -1) + dynamic_lighting_max_colour_temp %} {% set end_slope
= (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
%} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
* -1) + dynamic_lighting_min_colour_temp %} {% if elevation
>= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising
and elevation <= dynamic_lighting_sun_elevation_end_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set
colour_temp_value = ((start_slope * elevation) + start_ak)
| round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling
and elevation >= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set
colour_temp_value = ((end_slope * elevation) + end_ak) | round(1)
%}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising
and elevation >= dynamic_lighting_sun_elevation_start_falling
\ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising
and is_state_attr('sun.sun', 'rising', true) %}\n {% set
colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling
and is_state_attr('sun.sun', 'rising', false) %}\n {% set
colour_temp_value = dynamic_lighting_min_colour_temp %}\n
\ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n {% endif %}\n{% else %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n{% endif %} {{ colour_temp_value
| round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {%
set light.data = dict(light.data, **{ 'color_temp_kelvin':
dynamic_kelvin }) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition':
light_transition_on }) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set elevation = state_attr('sun.sun', 'elevation')
| float %} {% if expand(light_entities) | selectattr('state',
'==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising
- 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising
+ 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling
+ 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n
\ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising
+ 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling
- 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising
- 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n
\ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling
- 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n
\ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{%
endif %}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights
are ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Adjust the light settings when all bypasses are off or
state control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If sun elevation is outside the adjustment zone and the
lights are ON
conditions: '{{ should_wait }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: If the lights are OFF
conditions: '{{ expand(light_entities) | selectattr(''state'',
''=='', ''off'') | list | count > 0 }}'
sequence:
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- alias: Set sun elevation colour temperature for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Wait for sun elevation to change
wait_for_trigger:
- trigger: state
entity_id: sun.sun
attribute: elevation
- choose:
- alias: 10 - Dynamic Lighting - Time Controlled - Colour Temp
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_kelvin: "{% set current_time = now().hour + (now().minute
/ 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (start_time_morning - end_time_morning)
%} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_colour_temp
%} {% set end_slope = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope
* (-end_time_evening)) + dynamic_lighting_min_colour_temp %} {%
if current_time >= start_time_morning and current_time <= end_time_morning
%}\n {% set colour_temp_value = (start_slope * current_time +
start_ak) | round(1) %}\n{% elif current_time >= start_time_evening
and current_time <= end_time_evening %}\n {% set colour_temp_value
= (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time
> end_time_morning and current_time < start_time_evening %}\n
\ {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n{% elif current_time < start_time_morning %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n{% elif current_time >
end_time_evening %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n{% endif %} {{ colour_temp_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if 'use_brightness' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'brightness_pct':
light_brightness }) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set current_time = now().hour + (now().minute /
60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities)
| selectattr('state', '==', 'on') | list | count > 0 %} {% set
in_morning = start_time_morning <= current_time <= end_time_morning
%} {% set in_evening = start_time_evening <= current_time <= end_time_evening
%} {{ lights_on and not (in_morning or in_evening) }}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If time is outside the adjustment zone and the lights are
ON
conditions: '{{ should_wait }}'
sequence:
- choose:
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_morning
before: !input dynamic_lighting_time_start_evening
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_evening
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_evening
before: !input dynamic_lighting_time_start_morning
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_morning
- alias: Set the dynamic lighting brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: 11 - Dynamic Lighting - Time Controlled - Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute
/ 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (start_time_morning - end_time_morning)
%} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_brightness
%} {% set end_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope
* (-end_time_evening)) + dynamic_lighting_min_brightness %} {%
if current_time >= start_time_morning and current_time <= end_time_morning
%}\n {% set brightness_value = (start_slope * current_time +
start_ak) | round(1) %}\n{% elif current_time >= start_time_evening
and current_time <= end_time_evening %}\n {% set brightness_value
= (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time
> end_time_morning and current_time < start_time_evening %}\n
\ {% set brightness_value = dynamic_lighting_max_brightness %}\n{%
elif current_time < start_time_morning %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n{% elif current_time > end_time_evening
%}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
should_wait: "{% set current_time = now().hour + (now().minute /
60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities)
| selectattr('state', '==', 'on') | list | count > 0 %} {% set
in_morning = start_time_morning <= current_time <= end_time_morning
%} {% set in_evening = start_time_evening <= current_time <= end_time_evening
%} {{ lights_on and not (in_morning or in_evening) }}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If time is outside the adjustment zone and the lights are
ON
conditions: '{{ should_wait }}'
sequence:
- choose:
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_morning
before: !input dynamic_lighting_time_start_evening
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_evening
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_evening
before: !input dynamic_lighting_time_start_morning
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_morning
- alias: Set the dynamic lighting brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: 12 - Dynamic Lighting - Time Controlled - Brightness Inverted
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness_inv''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute
/ 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_max_brightness
- dynamic_lighting_min_brightness) / (start_time_morning - end_time_morning)
%} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_min_brightness
%} {% set end_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
/ (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope
* (-end_time_evening)) + dynamic_lighting_max_brightness %} {%
if current_time >= start_time_morning and current_time <= end_time_morning
%}\n {% set brightness_value = (start_slope * current_time +
start_ak) | round(1) %}\n{% elif current_time >= start_time_evening
and current_time <= end_time_evening %}\n {% set brightness_value
= (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time
> end_time_morning and current_time < start_time_evening %}\n
\ {% set brightness_value = dynamic_lighting_min_brightness %}\n{%
elif current_time < start_time_morning %}\n {% set brightness_value
= dynamic_lighting_max_brightness %}\n{% elif current_time > end_time_evening
%}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct
}) %} {% if 'use_transition' in include_light_control %}\n {%
set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature'
%}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin':
light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgb_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbw_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control
== 'use_rgbww_colour' %}\n {% set light.data = dict(light.data,
**{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data
}}\n"
should_wait: "{% set current_time = now().hour + (now().minute /
60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities)
| selectattr('state', '==', 'on') | list | count > 0 %} {% set
in_morning = start_time_morning <= current_time <= end_time_morning
%} {% set in_evening = start_time_evening <= current_time <= end_time_evening
%} {{ lights_on and not (in_morning or in_evening) }}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If time is outside the adjustment zone and the lights are
ON
conditions: '{{ should_wait }}'
sequence:
- choose:
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_morning
before: !input dynamic_lighting_time_start_evening
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_evening
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_evening
before: !input dynamic_lighting_time_start_morning
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_morning
- alias: Set the dynamic lighting brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness_inv''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: 13 - Dynamic Lighting - Time Controlled - Colour Temp & Brightness
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour_brightness''
}}'
sequence:
- alias: Dynamic Lighting Control
repeat:
until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities)
| selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean
!= []) and (is_state(dynamic_lighting_boolean, ''off''))) }}'
sequence:
- variables:
dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute
/ 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_brightness
- dynamic_lighting_max_brightness) / (start_time_morning - end_time_morning)
%} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_brightness
%} {% set end_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
/ (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope
* (-end_time_evening)) + dynamic_lighting_min_brightness %} {%
if current_time >= start_time_morning and current_time <= end_time_morning
%}\n {% set brightness_value = (start_slope * current_time +
start_ak) | round(1) %}\n{% elif current_time >= start_time_evening
and current_time <= end_time_evening %}\n {% set brightness_value
= (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time
> end_time_morning and current_time < start_time_evening %}\n
\ {% set brightness_value = dynamic_lighting_max_brightness %}\n{%
elif current_time < start_time_morning %}\n {% set brightness_value
= dynamic_lighting_min_brightness %}\n{% elif current_time > end_time_evening
%}\n {% set brightness_value = dynamic_lighting_min_brightness
%}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness
%}\n{% endif %} {{ brightness_value | round(0) }}\n"
dynamic_kelvin: "{% set current_time = now().hour + (now().minute
/ 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_colour_temp
- dynamic_lighting_max_colour_temp) / (start_time_morning - end_time_morning)
%} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_colour_temp
%} {% set end_slope = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
/ (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope
* (-end_time_evening)) + dynamic_lighting_min_colour_temp %} {%
if current_time >= start_time_morning and current_time <= end_time_morning
%}\n {% set colour_temp_value = (start_slope * current_time +
start_ak) | round(1) %}\n{% elif current_time >= start_time_evening
and current_time <= end_time_evening %}\n {% set colour_temp_value
= (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time
> end_time_morning and current_time < start_time_evening %}\n
\ {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n{% elif current_time < start_time_morning %}\n {% set colour_temp_value
= dynamic_lighting_min_colour_temp %}\n{% elif current_time >
end_time_evening %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp
%}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp
%}\n{% endif %} {{ colour_temp_value | round(0) }}\n"
dynamic_light_data: "{% set light = namespace(data={}) %} {% set
light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin
}) %} {% set light.data = dict(light.data, **{ 'brightness_pct':
dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control
%}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on
}) %}\n{% endif %} {{ light.data }}\n"
should_wait: "{% set current_time = now().hour + (now().minute /
60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0]
| int + (dynamic_lighting_time_start_morning.split(':')[1] | int
/ 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0]
| int + (dynamic_lighting_time_end_morning.split(':')[1] | int
/ 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0]
| int + (dynamic_lighting_time_start_evening.split(':')[1] | int
/ 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0]
| int + (dynamic_lighting_time_end_evening.split(':')[1] | int
/ 60) %} {% if end_time_morning < start_time_morning %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_morning
= end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening
+ 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{%
endif %} {% if end_time_evening < start_time_evening %}\n {%
if current_time < end_time_evening %}\n {% set current_time
= current_time + 24 %}\n {% endif %}\n {% set end_time_evening
= end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities)
| selectattr('state', '==', 'on') | list | count > 0 %} {% set
in_morning = start_time_morning <= current_time <= end_time_morning
%} {% set in_evening = start_time_evening <= current_time <= end_time_evening
%} {{ lights_on and not (in_morning or in_evening) }}\n"
- choose:
- alias: Stop when crossing over
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
not in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- stop: Stop the automation
- alias: Adjust the lights settings when crossing over if lights are
ON is selected in night light control
conditions:
- condition: template
value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
in include_night_light_control }}'
- condition: trigger
id:
- t12
- t13
- t14
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: Adjust the light settings when all bypasses are off or state
control is enabled, and the entity is turned ON
conditions:
- condition: trigger
id:
- t15
- t8_on
- t8_off
- t8_stop
- condition: template
value_template: '{{ repeat.index == 1 }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: If time is outside the adjustment zone and the lights are
ON
conditions: '{{ should_wait }}'
sequence:
- choose:
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_morning
before: !input dynamic_lighting_time_start_evening
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_evening
- conditions:
- condition: time
after: !input dynamic_lighting_time_end_evening
before: !input dynamic_lighting_time_start_morning
sequence:
- wait_for_trigger:
- trigger: time
at: !input dynamic_lighting_time_start_morning
- alias: Set the dynamic lighting brightness for the normal lights
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour_brightness''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ dynamic_light_data }}'
- alias: Dynamic lighting heartbeat
delay:
minutes: !input dynamic_lighting_heartbeat
- stop: Stop the automation
- sequence:
- choose:
- alias: Turn ON lights
conditions:
- alias: Check the dynamic lighting options
condition: or
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting''
}}'
- alias: Check that dynamic lighting is active and the state control option
is enabled
condition: and
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: '{{ dynamic_lighting_state_control == ''enable_state_control''
}}'
- condition: template
value_template: '{{ states(dynamic_lighting_state_control_entity)
== dynamic_lighting_state_control_activation_state_inv }}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities_off }}'
data: '{{ light_data }}'
- choose:
- alias: Dynamic Lighting State Control Turning OFF
conditions:
- condition: trigger
id: t16
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
sequence:
- action: light.turn_on
target:
entity_id: '{{ light_entities }}'
data: '{{ light_data }}'
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This is for
scenes only when crossing over
conditions:
- condition: template
value_template: "{% if night_boolean_scenes_scripts == [] %}\n false\n{%
elif is_state(night_boolean_scenes_scripts, 'on') %}\n true\n{% else
%}\n false\n{% endif %}"
sequence:
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: '{{ night_boolean_scenes_scripts }}'
- choose:
- alias: Check if normal lights scenes or scripts helper is on - This
is for scenes only when crossing over
conditions:
- '{{ boolean_scenes_scripts != [] }}'
sequence:
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ boolean_scenes_scripts_helper }}'
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
target:
entity_id: '{{ scene_entities }}'
data:
transition: '{{ light_transition_on }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ boolean_scenes_scripts_helper }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control }}'
sequence:
- alias: Turn on the scenes
action: scene.turn_on
target:
entity_id: '{{ scene_entities }}'
- alias: Turn on the boolean for scenes and scripts
action: input_boolean.turn_on
data:
entity_id: '{{ boolean_scenes_scripts_helper }}'
- alias: Turn on the switches
action: switch.turn_on
target:
entity_id: '{{ switch_entities_off }}'
- alias: Turn on the scripts
action: script.turn_on
target:
entity_id: '{{ script_entities }}'
- choose:
- alias: By-pass is enabled & check by-pass option - Turn lights on
conditions:
- condition: trigger
id: t7_on
sequence:
- alias: Check by-pass settings and preform the correct action
if:
- alias: Check if the by-pass auto off is enabled
condition: template
value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
(''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
then:
- alias: Wait the number of minutes set in the by-pass auto off time delay
delay:
minutes: !input bypass_auto_off_delay
- alias: Parallel Actions for the by-pass auto off
parallel:
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_on
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_off
- sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
}}'
sequence:
- alias: Turn off the by-pass
action: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: Stop the automation
else:
- stop: Stop the automation
- choose:
- alias: Check if the trigger is on and wait for it to go off
conditions:
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
sequence:
- alias: Wait until motion sensor is off
wait_for_trigger:
- trigger: state
entity_id: !input motion_trigger
from: 'on'
to: 'off'
- alias: Wait the number of minutes set in the normal lights time delay
delay:
minutes: !input time_delay
- choose:
- alias: Dynamic Lighting - Check if Input Boolean Helper is ON
conditions:
- condition: template
value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
}}'
- condition: template
value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean,
'on') }}\n{% endif %}"
sequence:
- alias: Turn off the boolean for dynamic lighting
action: input_boolean.turn_off
data:
entity_id: !input dynamic_lighting_boolean
- choose:
- alias: If transition is selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
data:
transition: '{{ light_transition_off }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
transition: '{{ light_transition_off }}'
- alias: If transition is not selected
conditions:
- condition: template
value_template: '{{ ''use_transition'' not in include_light_control }}'
sequence:
- alias: Turn off the lights
action: light.turn_off
target:
entity_id: '{{ light_entities }}'
- alias: Turn off the scenes
action: scene.turn_on
data:
entity_id: '{{ end_scene_entities }}'
- alias: Turn off the switches
action: switch.turn_off
target:
entity_id: '{{ switch_entities }}'
- alias: Turn off the script
action: script.turn_on
data:
entity_id: '{{ end_script_entities }}'
- alias: Turn off the boolean for scenes and scripts
action: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts