Skip to content

Instantly share code, notes, and snippets.

@onethirtyfive
Forked from Blackshome/sensor-light.yaml
Created April 21, 2024 16:28
Show Gist options
  • Save onethirtyfive/371476945e4e03cc33315d22e44d7188 to your computer and use it in GitHub Desktop.
Save onethirtyfive/371476945e4e03cc33315d22e44d7188 to your computer and use it in GitHub Desktop.
Home Assistant Sensor Light that can be used in Blueprints
blueprint:
name: Sensor Light
description: >
# 💡 Sensor Light
**Version: 6.5**
Your lighting experience, your way - take control and customize it to perfection! 💡✨
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) 🙂
<details>
<summary><b>The Automation Process:</b> - Click here to expand</summary>
- **Trigger:**
- 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.
- A trigger sensor, such as a Motion Sensor, will activate lights, switches, scenes, and scripts when the automation is triggered.
- 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.
- If triggers are activated again before the time delay ends, the automation resets for continuous lighting.
- **Scene and Script Integration:**
- Scenes or scripts offer additional customization for your spaces.
- **Light Control Options:**
- Utilize "Light Control" to adjust brightness, colour temperature, and transition times.
- **Dynamic Lighting Options:**
- Opt for 'Dynamic Lighting' to continuously adjust brightness based on lux values or adapt colour temperature and brightness according to the sun's changing elevation.
- **Manual Override:**
- Use "Bypass Options" for manual bypassing of trigger sensors, providing manual control and additional customization.
- **Sun Elevation Options:**
- Implement "Sun Elevation" to restrict automation to darker conditions aligned with the sun's position.
- **Ambient Light Sensing Options:**
- Set up an Ambient Light Sensor for activation in low-light conditions, customizable with specified LUX values.
- **Time-Based Options:**
- Specify precise start and end times along with weekday selections to define when the automation should run.
- **Device Tracker Options:**
- 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.
- **Night Lights Mode:**
- Enable "Night Lights" for softer illumination during night time activities, automatically enabled based on conditions.
- **HA Restart Safeguards:**
- Benefit from built-in safeguards for Home Assistant restarts.
- **Blueprint Add-On Integration:**
- Sensor Light Add-On - Enhances media control automation. [Click Here](https://community.home-assistant.io/t/591824) to learn more.
- Bathroom Humidity Exhaust Fan - Keeps the lights ON when showering. [Click Here](https://community.home-assistant.io/t/509992) to learn more.
</details>
The Settings & Best Practice Guidelines: [Click Here](https://community.home-assistant.io/t/481048/345)
Need help? See our FAQ: [Click Here](https://community.home-assistant.io/t/481048/6)
Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/481048)
Required = *
domain: automation
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)
selector:
entity:
filter:
domain:
- binary_sensor
- schedule
multiple: true
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 and devices are not supported.
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
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
max: 30
step: 0.5
unit_of_measurement: minutes
include_light_control:
name: Use The Light Control Options (Optional)
description: Select if you would like to use brightness, colour temperature, or transition.
These settings will only affect a 'light' entity that supports each selected option.
The settings for brightness, colour temperature, and transition are provided below.
default: []
selector:
select:
multiple: true
options:
- label: Use brightness
value: "use_brightness"
- label: Use colour temperature
value: "use_colour_temperature"
- label: Use transition
value: "use_transition"
light_brightness:
name: Brightness
description: The brightness setting for the lights when they are turned ON.
default: 100
selector:
number:
min: 1
max: 100
mode: slider
step: 1
unit_of_measurement: '%'
light_colour_temperature:
name: Colour Temperature
description: The colour temperature setting for the lights when they are turned ON.
default: 5000
selector:
number:
min: 2000
max: 8000
mode: slider
step: 100
unit_of_measurement: 'kelvin'
light_transition_on:
name: Transition - ON
description: The transition setting for the lights when they are turned ON.
default: 1
selector:
number:
min: 0
max: 5
mode: slider
step: 0.5
unit_of_measurement: seconds
light_transition_off:
name: Transition - OFF
description: The transition setting for the lights when they are turned OFF.
default: 1
selector:
number:
min: 0
max: 30
mode: slider
step: 1
unit_of_measurement: seconds
include_dynamic_lighting:
name: Use The Dynamic Lighting Options (Optional)
description: This option aims to make continual adjustments in your lighting setup by modulating brightness according to floating lux values
or adapting colour temperature and brightness based on the sun's changing elevation. Choose from six preset options available in the dropdown menu.
1 - Lux Controlled Brightness
2 - Lux Controlled Brightness - Inverted
3 - Sun Elevation Lighting - Colour Temp
4 - Sun Elevation Lighting - Brightness
5 - Sun Elevation Lighting - Brightness - Inverted
6 - Sun Elevation Lighting - Colour Temp + Brightness
7 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness
A 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 or 7" are required for that respective selection because number 3 is included in those options.
For more information on dynamic lighting settings [Click Here](https://community.home-assistant.io/t/481048/837)
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 + Lux Brightness
value: "enable_sun_elevation_colour_lux_brightness"
dynamic_lighting_lux_sensor:
name: Dynamic Lighting - Ambient Light Sensor
description: "**Used in options 1, 2 or 7** - Enter the specific ambient light sensor to be used, based on the chosen settings."
default: []
selector:
entity:
filter:
domain: sensor
device_class: illuminance
dynamic_lighting_max_lux:
name: Dynamic Lighting - Max Lux Value
description: "**Used in options 1, 2 or 7** - 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
max: 900
step: 10
unit_of_measurement: lux
dynamic_lighting_min_lux:
name: Dynamic Lighting - Min Lux Value
description: "**Used in options 1, 2 or 7** - 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
max: 600
step: 10
unit_of_measurement: lux
dynamic_lighting_max_brightness:
name: Dynamic Lighting - Max Brightness Value
description: "**Used in options 1, 2, 4, 5, 6 or 7** - Define the maximum brightness value, determines the peak brightness level for your lights."
default: 100
selector:
number:
min: 10
max: 100
step: 1
unit_of_measurement: '%'
dynamic_lighting_min_brightness:
name: Dynamic Lighting - Min Brightness Value
description: "**Used in options 1, 2, 4, 5, 6 or 7** - 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
max: 100
step: 1
unit_of_measurement: '%'
dynamic_lighting_max_colour_temp:
name: Dynamic Lighting - Max Colour Temperature
description: "**Used in options 3, 6 or 7** - Specify the highest colour temperature value, determining the coolest colour setting for your lights."
default: 5000
selector:
number:
min: 2500
max: 8000
mode: slider
step: 100
unit_of_measurement: 'kelvin'
dynamic_lighting_min_colour_temp:
name: Dynamic Lighting - Min Colour Temperature
description: "**Used in options 3, 6 or 7** - Set the lowest colour temperature value, defining the warmest colour setting for your lights."
default: 3000
selector:
number:
min: 2000
max: 7500
mode: slider
step: 100
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 or 7** - 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 the chosen settings."
default: -1.5
selector:
number:
min: -10
max: 30
step: 0.5
unit_of_measurement: degrees
dynamic_lighting_sun_elevation_end_rising:
name: Dynamic Lighting - Sun Elevation Rising - End Point
description: "**Used in options 3, 4, 5, 6 or 7** - When the sun rises above the sensor's endpoint, the maximum colour temperature and maximum brightness value will
be established according to the chosen settings."
default: 15
selector:
number:
min: 0
max: 90
step: 0.5
unit_of_measurement: degrees
dynamic_lighting_sun_elevation_start_falling:
name: Dynamic Lighting - Sun Elevation Descending - Start Point
description: "**Used in options 3, 4, 5, 6 or 7** - 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 the chosen settings."
default: 15
selector:
number:
min: 0
max: 90
step: 0.5
unit_of_measurement: degrees
dynamic_lighting_sun_elevation_end_falling:
name: Dynamic Lighting - Sun Elevation Descending - End Point
description: "**Used in options 3, 4, 5, 6 or 7** - When the sun descends below the sensor's endpoint, the minimum colour temperature and minimum brightness value will
be established according to the chosen settings."
default: -4.0
selector:
number:
min: -10
max: 30
step: 0.5
unit_of_measurement: degrees
dynamic_lighting_heartbeat:
name: Dynamic Lighting - Heartbeat
description: "**Used in options 1, 2, 3, 4, 5, 6 or 7** - Define the heartbeat rate, setting the operational speed.
During each heartbeat, it evaluates the lux value, light brightness, targeted brightness and the sun's elevation based on the chosen settings,
adjusting either brightness or colour temperature as per the selection."
default: 1
selector:
number:
min: 0.25
max: 10
step: 0.25
unit_of_measurement: minutes
dynamic_lighting_step_value:
name: Dynamic Lighting - Step Value
description: "**Used in options 1, 2 or 7** - With every heartbeat, the system evaluates the lux value, light brightness, and the targeted brightness.
If the targeted brightness surpasses the predefined step value, the system applies the set step value to gracefully moderate the rate of changes,
facilitating a smoother transition in light brightness."
default: 4
selector:
number:
min: 1
max: 100
step: 1
unit_of_measurement: '%'
dynamic_lighting_dead_zone:
name: Dynamic Lighting - Dead Zone (±)
description: "**Used in options 1, 2 or 7** - 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
max: 15
step: 1
unit_of_measurement: '%'
include_bypass:
name: Use The Bypass Options (Optional)
description: Select if you would like to enable an option. Each option allows manual control of your lights but alters its
behaviour by either turning ON, OFF, or keeping its current state when the bypass is switched ON. When enabling an option,
please enter the bypass switch into the corresponding input below.
For more information on how to use the bypass [Click Here](https://community.home-assistant.io/t/481048/895)
default: []
selector:
select:
options:
- label: 1 - Enable the Bypass - Turn lights ON
value: "bypass_enabled_turn_on"
- label: 2 - Enable the Bypass - Turn lights OFF
value: "bypass_enabled_turn_off"
- label: 3 - Enable the Bypass - Keep the lights current state
value: "bypass_enabled_stop"
multiple: true
motion_bypass_lights_on:
name: Bypass Switch - Turn 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 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 bypass scenarios; when the lights are already ON and when the automation turns the lights OFF.
The first scenario occurs when you have selected option 2 above to "Enable the Bypass - Turn lights OFF".
The second scenario occurs when you turn the bypass OFF, the trigger sensor is OFF, and your lights are ON.
In both scenarios, the automation will turn your lights OFF after the set time delay.
default: 0
selector:
number:
min: 0
max: 10
step: 0.25
unit_of_measurement: minutes
include_bypass_auto_off:
name: Use The Bypass Auto OFF Option (Optional)
description: This is used when you turn ON the bypass and want it to automatically turn OFF after a set time delay.
You can choose which bypass option you would like to apply the auto OFF feature to
default: []
selector:
select:
options:
- label: Enable the auto OFF for the bypass switch - Turn lights ON
value: "bypass_auto_off_enabled_on"
- label: Enable the auto OFF for the bypass switch - Turn lights OFF
value: "bypass_auto_off_enabled_off"
- label: Enable the auto OFF for the bypass switch - Keep The Lights Current State
value: "bypass_auto_off_enabled_stop"
multiple: true
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
max: 240
step: 1
unit_of_measurement: minutes
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"
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
max: 5
step: 0.5
unit_of_measurement: degrees
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
max: 5
step: 0.5
unit_of_measurement: degrees
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"
ambient_light_sensor:
name: Ambient Light Sensor
description: Select the ambient sensor to be used.
default: []
selector:
entity:
filter:
domain: sensor
device_class: illuminance
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"
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
max: 500
step: 10
unit_of_measurement: lux
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
max: 1000
step: 10
unit_of_measurement: lux
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"
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"
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"
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
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
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"
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' 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 and devices 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
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
max: 30
step: 0.5
unit_of_measurement: minutes
include_night_light_control:
name: Night Lights - Use The Light Control Options (Optional)
description: Select if you would like to use brightness, colour temperature, or transition.
These settings will only affect a 'light' entity that supports each selected option.
The settings for brightness, colour temperature, and transition are provided below.
Selecting '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.
Selecting '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.
default: []
selector:
select:
multiple: true
options:
- label: Use brightness
value: "use_brightness"
- label: Use colour temperature
value: "use_colour_temperature"
- label: Use transition
value: "use_transition"
- 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"
night_light_brightness:
name: Night Lights - Brightness
description: The brightness setting of the night lights when they are turned ON.
default: 20
selector:
number:
min: 1
max: 100
mode: slider
step: 1
unit_of_measurement: '%'
night_light_colour_temperature:
name: Night Lights - Colour Temperature
description: The colour temperature setting for the night lights when they are turned ON.
default: 5000
selector:
number:
min: 2000
max: 8000
mode: slider
step: 100
unit_of_measurement: 'kelvin'
night_light_transition_on:
name: Night Lights - Transition - ON
description: The transition of the night lights when they are turned ON.
default: 1
selector:
number:
min: 0
max: 5
mode: slider
step: 0.5
unit_of_measurement: seconds
night_light_transition_off:
name: Night Lights - Transition - OFF
description: The transition of the night lights when they are turned OFF.
default: 1
selector:
number:
min: 0
max: 30
mode: slider
step: 1
unit_of_measurement: seconds
night_lights_conditions:
name: Night Lights Conditions (Required For Night Lights)
description: Select any night light condition from the options provided.
Ensure you've enabled 'Use the night lights options' in the section above and choose at least one 'Night Lights Condition' for night lights to operate.
Settings for each option are provided below
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"
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
max: 5
step: 0.5
unit_of_measurement: degrees
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
max: 5
step: 0.5
unit_of_measurement: degrees
# If motion sensor turns ON again within the time delay, it will restart the script.
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
brightness_value: "{{ iif ('use_brightness' in include_light_control , light_brightness, ) }}"
light_colour_temperature: !input light_colour_temperature
temperature_value: "{{ iif ('use_colour_temperature' in include_light_control , light_colour_temperature, [] ) }}"
light_transition_on: !input light_transition_on
light_transition_off: !input light_transition_off
transition_on_value: "{{ iif ('use_transition' in include_light_control, light_transition_on, ) }}"
transition_off_value: "{{ iif ('use_transition' in include_light_control, light_transition_off, ) }}"
include_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_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_heartbeat: !input dynamic_lighting_heartbeat
dynamic_lighting_step_value: !input dynamic_lighting_step_value
dynamic_lighting_dead_zone: !input dynamic_lighting_dead_zone
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: !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_brightness_value: "{{ iif ('use_brightness' in include_night_light_control , night_light_brightness, ) }}"
night_light_colour_temperature: !input night_light_colour_temperature
night_temperature_value: "{{ iif ('use_colour_temperature' in include_night_light_control , night_light_colour_temperature, [] ) }}"
night_light_transition_on: !input night_light_transition_on
night_light_transition_off: !input night_light_transition_off
night_transition_on_value: "{{ iif ('use_transition' in include_night_light_control, night_light_transition_on, ) }}"
night_transition_off_value: "{{ iif ('use_transition' in include_night_light_control, night_light_transition_off, ) }}"
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
# Split domains for light switch targets and check the entities are OFF - exclude scenes and scripts as they have no off state
light_entities_off: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}"
switch_entities_off: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}"
# Split domains for light switch targets
light_entities: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}"
switch_entities: "{{ expand(light_switch.entity_id) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}"
scene_entities: >-
{% set a = light_switch.entity_id %}
{% if boolean_scenes_scripts == [] %}
{{ expand(a) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}
{% elif is_state(boolean_scenes_scripts, 'off') %}
{{ expand(a) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
script_entities: >-
{% set a = light_switch.entity_id %}
{% if boolean_scenes_scripts == [] %}
{{ expand(a) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}
{% elif is_state(boolean_scenes_scripts, 'off') %}
{{ expand(a) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
boolean_scenes_scripts_helper: >-
{% if boolean_scenes_scripts | length > 0 and states(boolean_scenes_scripts) == 'off' %}
{{ boolean_scenes_scripts }}
{% else %}
[]
{% endif %}
# Split domains for end scenes and scripts
end_scene_entities: "{{ end_scenes | select('match', '^scene\\..*') | list }}"
end_script_entities: "{{ end_scenes | select('match', '^script\\..*') | list }}"
# Split domains for night lights target and check the entities are OFF - exclude scenes and scripts as they have no off state
night_light_entities_off: >-
{% set b = night_lights and night_lights.entity_id %}
{% if b %}
{{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
night_switch_entities_off: >-
{% set b = night_lights and night_lights.entity_id %}
{% if b %}
{{ expand(b) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
# Split domains for night lights target
night_light_entities: >-
{% set b = night_lights and night_lights.entity_id %}
{% if b %}
{{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
night_switch_entities: >-
{% set b = night_lights and night_lights.entity_id %}
{% if b %}
{{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
night_scene_entities: >-
{% set b = night_lights and night_lights.entity_id %}
{% if night_boolean_scenes_scripts == [] %}
{{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}
{% elif is_state(night_boolean_scenes_scripts, 'off') %}
{{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
night_script_entities: >-
{% set b = night_lights and night_lights.entity_id %}
{% if night_boolean_scenes_scripts == [] %}
{{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}
{% elif is_state(night_boolean_scenes_scripts, 'off') %}
{{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
night_boolean_scenes_scripts_helper: >-
{% if night_boolean_scenes_scripts | length > 0 and states(night_boolean_scenes_scripts) == 'off' %}
{{ night_boolean_scenes_scripts }}
{% else %}
[]
{% endif %}
# Set up crossover lights for T4, T5 & t6 trigger. This is to stop the light flicker - exclude scenes and scripts as they have no off state
crossover_lights_light: >-
{% set a = light_switch.entity_id %}
{% set b = night_lights and night_lights.entity_id %}
{% if a and b %}
{{ expand(a) | reject('in', expand(b)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
crossover_lights_switch: >-
{% set a = light_switch.entity_id %}
{% set b = night_lights and night_lights.entity_id %}
{% if a and b %}
{{ expand(a) | reject('in', expand(b)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
crossover_night_lights_light_on: >-
{% set b = night_lights and night_lights.entity_id %}
{% if b %}
{{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
# Set up crossover lights for t12, t13 & t14 trigger. This is to stop the light flicker - exclude scenes and scripts as they have no off state
crossover_night_lights_light: >-
{% set a = light_switch.entity_id %}
{% set b = night_lights and night_lights.entity_id %}
{% if a and b %}
{{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
crossover_night_lights_switch: >-
{% set a = light_switch.entity_id %}
{% set b = night_lights and night_lights.entity_id %}
{% if a and b %}
{{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
crossover_lights_light_on: >-
{% set a = light_switch.entity_id %}
{% if a %}
{{ expand(a) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}
{% else %}
[]
{% endif %}
trigger:
- platform: state
id: "t0"
entity_id: !input motion_trigger
from: "off"
to: "on"
- platform: numeric_state
id: "t1"
entity_id: sun.sun
attribute: elevation
below: !input sun_elevation
- platform: numeric_state
id: "t2"
entity_id: !input ambient_light_sensor
below: !input ambient_light_value
- platform: time
id: "t3"
at: !input after_time
- platform: state
id: "t4"
entity_id: !input night_lights_entity_state
from: "off"
to: "on"
- platform: time
id: "t5"
at: !input night_lights_after_time
- platform: numeric_state
id: "t6"
entity_id: sun.sun
attribute: elevation
below: !input night_lights_sun_elevation
- platform: state
id: "t7_on"
entity_id: !input motion_bypass_lights_on
from: "off"
to: "on"
- platform: state
id: "t7_off"
entity_id: !input motion_bypass_lights_off
from: "off"
to: "on"
- platform: state
id: "t7_stop"
entity_id: !input motion_bypass_lights_stop
from: "off"
to: "on"
- platform: state
id: "t8_on"
entity_id: !input motion_bypass_lights_on
from: "on"
to: "off"
- platform: state
id: "t8_off"
entity_id: !input motion_bypass_lights_off
from: "on"
to: "off"
- platform: state
id: "t8_stop"
entity_id: !input motion_bypass_lights_stop
from: "on"
to: "off"
- platform: numeric_state
id: "t9"
entity_id: sun.sun
attribute: elevation
above: !input sun_elevation_rising
- platform: numeric_state
id: "t10"
entity_id: !input ambient_light_sensor
above: !input ambient_light_high_value
- platform: time
id: "t11"
at: !input before_time
- platform: state
id: "t12"
entity_id: !input night_lights_entity_state
from: "on"
to: "off"
- platform: time
id: "t13"
at: !input night_lights_before_time
- platform: numeric_state
id: "t14"
entity_id: sun.sun
attribute: elevation
above: !input night_lights_sun_elevation_rising
- platform: homeassistant
id: "t15"
event: start
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger from off to on
conditions:
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
- condition: trigger
id: 't0'
- condition: and # trigger by sun & check motion trigger is on
conditions:
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- "{{ include_sun == 'sun_enabled' }}"
- condition: trigger
id: 't1'
- condition: and # trigger by ambient & check motion trigger is on
conditions:
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- "{{ include_ambient == 'ambient_enabled' }}"
- condition: trigger
id: 't2'
- condition: and # trigger by time & check motion trigger is on
conditions:
- condition: state
entity_id: !input motion_trigger
state: 'on'
match: any
- "{{ include_time == 'time_enabled' }}"
- condition: trigger
id: 't3'
- condition: and # trigger by the start of night light entity state & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the start of night lights time & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the start of night lights sun elevation & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by by-pass turning on
conditions:
- condition: trigger
id: 't7_on'
- "{{ 'bypass_enabled_turn_on' in include_bypass }}"
- condition: and # trigger by by-pass turning off
conditions:
- condition: trigger
id: 't7_off'
- "{{ 'bypass_enabled_turn_off' in include_bypass }}"
- condition: and # trigger by by-pass stop
conditions:
- condition: trigger
id: 't7_stop'
- "{{ 'bypass_enabled_stop' in include_bypass }}"
- condition: and # trigger by by-pass turning on
conditions:
- condition: trigger
id: 't8_on'
- "{{ 'bypass_enabled_turn_on' in include_bypass }}"
- condition: and # trigger by by-pass turning off
conditions:
- condition: trigger
id: 't8_off'
- "{{ 'bypass_enabled_turn_off' in include_bypass }}"
- condition: and # trigger by by-pass stop
conditions:
- condition: trigger
id: 't8_stop'
- "{{ 'bypass_enabled_stop' in include_bypass }}"
- condition: and # trigger by rising of the sun & check if the lights are ON
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) }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by rising of the ambient high lux value, the ambient site condition is set to NO & check if the lights are ON
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) }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the end time & check if the lights are ON
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) }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the end of night lights entity state & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the end of night lights time & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by the end of night lights sun elevation & check if any lights are on
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) }}"
- condition: template
value_template: "{{ 'manage_scripts_crossing_over' in include_night_light_control }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by HA Restart & check if any lights are on
conditions:
- condition: trigger
id: 't15'
- 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 != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and # trigger by HA Restart & check if any triggers are on
conditions:
- condition: state
entity_id: !input motion_trigger
match: any
state: 'on'
- condition: trigger
id: 't15'
- condition: and # trigger by HA Restart & check if by-pass auto off is enabled and any by-passes are on
conditions:
- "{{ ('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: trigger
id: 't15'
- 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'
# Check Motion Sensor Manual By-pass
- 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'
- 't15'
# Check Sun Elevation
- 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'
# Check Ambient Light Sensor
- condition: or
conditions:
- "{{ include_ambient == 'ambient_disabled' }}"
- "{{ ambient_light_sensor == [] }}"
- "{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | int < ambient_light_value | int) }}"
- "{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | 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].state | 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].state | int < ambient_light_high_value | int) }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and
conditions:
- "{{ (include_ambient == 'ambient_enabled') and (states[ambient_light_sensor].state | int < ambient_light_high_value | int) }}"
- condition: template
value_template: >-
{% if night_boolean_scenes_scripts != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: and
conditions:
- "{{ (include_ambient == 'ambient_enabled') and ( ambient_light_options == 'ambient_light_option_enabled' ) }}"
- condition: template
value_template: >-
{% if boolean_scenes_scripts != [] %}
{{ is_state(boolean_scenes_scripts, 'on') }}
{% 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 != [] %}
{{ is_state(night_boolean_scenes_scripts, 'on') }}
{% endif %}
- condition: trigger
id:
- 't7_on'
- 't7_off'
- 't7_stop'
- 't8_on'
- 't8_off'
- 't8_stop'
- 't10'
# Check The Time Options
- 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'
# Check the Device Tracker Options
- condition: or
conditions:
- "{{ include_device_tracker == 'device_tracker_disabled' }}"
- condition: and
conditions:
- condition: numeric_state
entity_id: !input zone
above: 0
- "{{ include_device_tracker == 'zone_enabled' }}"
- condition: and
conditions:
- "{{ (state_attr(zone, 'persons') + people) | count != dict.fromkeys(state_attr(zone, 'persons') + people) | count }}"
- "{{ include_device_tracker == 'zone_people_enabled' }}"
- condition: trigger
id:
- 't7_on'
- 't7_off'
- 't7_stop'
- 't8_on'
- 't8_off'
- 't8_stop'
action:
- choose:
- alias: "Check if the night lights are enabled and within the night lights conditions"
conditions:
- condition: and
conditions:
- alias: "Check if night lights is enabled"
condition: or
conditions:
- "{{ 'night_lights_enabled' in include_night_lights }}"
- 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: "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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
data:
transition: "{{ night_transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ night_switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: "Turn off the boolean for scenes and scripts"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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 transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_night_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
data:
transition: "{{ night_transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ night_switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: "Turn off the boolean for scenes and scripts"
service: 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"
service: 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"
service: 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"
service: 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].state | int > ambient_light_value | int) }}"
- "{{ (include_ambient == 'ambient_enabled') and (ambient_light_options == 'ambient_light_option_enabled') and (states[ambient_light_sensor].state | 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].state | int > ambient_light_value | int) and (is_state(night_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_night_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
data:
transition: "{{ night_transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ night_switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- 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"
service: 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"
service: 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"
service: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: "Stop the automation"
- choose:
- alias: "Sun, Ambient Light Sensor & 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
data:
transition: "{{ night_transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ night_switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the input boolean night lights"
service: 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:
- "{{ (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(boolean_scenes_scripts, 'on')) }}"
sequence:
- choose:
- alias: "If transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ crossover_lights_light }}"
data:
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ crossover_lights_light }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ crossover_lights_switch }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- choose:
- alias: "If adjust light 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"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the input boolean normal lights"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- choose:
- alias: "Set the transition and brightness for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
transition: "{{ night_transition_on_value }}"
brightness_pct: "{{ night_brightness_value }}"
- alias: "Set the transition and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
transition: "{{ night_transition_on_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "Set the transition, brightness and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
transition: "{{ night_transition_on_value }}"
brightness_pct: "{{ night_brightness_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "Set the brightness for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
brightness_pct: "{{ night_brightness_value }}"
- alias: "Set the colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
kelvin: "{{ night_temperature_value }}"
- alias: "Set the brightness and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_night_lights_light_on }}"
data:
brightness_pct: "{{ night_brightness_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "light - switch - scene - script is ON"
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"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- stop: "Stop the automation"
- alias: "Safe Guard when HA restarts"
conditions:
- condition: trigger
id: 't15'
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"
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"
service: 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"
service: 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"
service: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: "Stop the automation"
- choose:
- alias: "Set the transition for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
transition: "{{ night_transition_on_value }}"
- alias: "Set the transition and brightness for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
transition: "{{ night_transition_on_value }}"
brightness_pct: "{{ night_brightness_value }}"
- alias: "Set the transition and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
transition: "{{ night_transition_on_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "Set the transition, brightness and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
transition: "{{ night_transition_on_value }}"
brightness_pct: "{{ night_brightness_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "Set the brightness for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
brightness_pct: "{{ night_brightness_value }}"
- alias: "Set the colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
kelvin: "{{ night_temperature_value }}"
- alias: "Set the brightness and colour temperature for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' in include_night_light_control) and ('use_colour_temperature' in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
data:
brightness_pct: "{{ night_brightness_value }}"
kelvin: "{{ night_temperature_value }}"
- alias: "Set the default for the night lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_night_light_control) and ('use_brightness' not in include_night_light_control) and ('use_colour_temperature' not in include_night_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ night_light_entities_off }}"
- 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 == [] %}
false
{% elif is_state(boolean_scenes_scripts, 'on') %}
true
{% else %}
false
{% endif %}
sequence:
- alias: "If transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_night_light_control }}"
sequence:
- alias: "Turn on the night scenes"
service: scene.turn_on
target:
entity_id: "{{ night_scene_entities }}"
data:
transition: "{{ night_transition_on_value }}"
- alias: "Turn on the boolean for scenes and scripts"
service: 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"
service: scene.turn_on
target:
entity_id: "{{ night_scene_entities }}"
- alias: "Turn on the boolean for scenes and scripts"
service: input_boolean.turn_on
data:
entity_id: "{{ night_boolean_scenes_scripts_helper }}"
- alias: "Turn on the night switches"
service: switch.turn_on
target:
entity_id: "{{ night_switch_entities_off }}"
- alias: "Turn on the night scripts"
service: 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"
service: 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"
service: 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"
service: 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:
platform: 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 transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_night_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
data:
transition: "{{ night_transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ night_light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ night_switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: 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 transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: "Turn off the boolean for scenes and scripts"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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 transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- alias: "Turn off the boolean for scenes and scripts"
service: 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"
service: 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"
service: 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"
service: 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].state | int > ambient_light_value | int) }}"
- "{{ (include_ambient == 'ambient_enabled') and (ambient_light_options == 'ambient_light_option_enabled') and (states[ambient_light_sensor].state | 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].state | 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"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- 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"
service: 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"
service: 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"
service: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: "Stop the automation"
- choose:
- alias: "Sun, Ambient Light Sensor & 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"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the input boolean night lights"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
- 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 transition is selected"
conditions:
- "{{ (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"
service: light.turn_off
target:
entity_id: "{{ crossover_night_lights_light }}"
data:
transition: "{{ night_transition_off_value }}"
- 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"
service: light.turn_off
target:
entity_id: "{{ crossover_night_lights_light }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ crossover_night_lights_switch }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- choose:
- alias: "If adjust light 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"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ night_transition_off_value }}"
- 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"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the input boolean night lights"
service: input_boolean.turn_off
data:
entity_id: !input night_boolean_scenes_scripts
- choose:
- alias: "Set the transition and brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
transition: "{{ transition_on_value }}"
brightness_pct: "{{ brightness_value }}"
- alias: "Set the transition and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
transition: "{{ transition_on_value }}"
kelvin: "{{temperature_value}}"
- alias: "Set the transition, brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
transition: "{{ transition_on_value }}"
brightness_pct: "{{ brightness_value }}"
kelvin: "{{temperature_value}}"
- alias: "Set the brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
brightness_pct: "{{ brightness_value }}"
- alias: "Set the colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
kelvin: "{{temperature_value}}"
- alias: "Set the brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and ('enable_lux_controled_brightness' not in include_dynamic_lighting) and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ crossover_lights_light_on }}"
data:
brightness_pct: "{{ brightness_value }}"
kelvin: "{{temperature_value}}"
- alias: "If transition is selected"
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"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- stop: "Stop the automation"
- alias: "Safe Guard when HA restarts"
conditions:
- condition: trigger
id: 't15'
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"
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"
service: 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"
service: 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"
service: homeassistant.turn_off
entity_id: !input motion_bypass_lights_stop
- stop: "Stop the automation"
- alias: "Parallel Actions for dynamic lighting"
parallel:
- sequence:
- alias: "Check if the dynamic lighting is enabled"
condition: and
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting != 'disable_dynamic_lighting' }}"
- choose:
- alias: "Set the Dynamic Lux Controlled Brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_lux_controled_brightness'}}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition and dynamic lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the transition, dynamic lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Dynamic Lighting - Lux Controlled Brightness - Inverted for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_lux_controled_brightness_inv'}}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition and dynamic lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness_inv') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the transition, dynamic lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness_inv') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness_inv') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_lux_controled_brightness_inv') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Dynamic Lighting - Sun Elevation Lighting - Colour Temp for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_sun_elevation_colour' }}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the transition, lighting brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
brightness_pct: "{{ brightness_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the lighting brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
brightness_pct: "{{ brightness_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Set the Sun Elevation Lighting - Brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_sun_elevation_brightness' }}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition and dynamic sun elevation lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the transition, dynamic sun elevation lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation lighting brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation lighting brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Set the Sun Elevation Lighting - Brightness Inverted for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_sun_elevation_brightness_inv' }}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition and dynamic sun elevation lighting brightness inverted for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness_inv') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the transition, dynamic sun elevation lighting brightness inverted and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness_inv') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation lighting brightness inverted for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness_inv') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation lighting brightness inverted and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_brightness_inv') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
kelvin: "{{temperature_value}}"
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Set the Sun Elevation Lighting - Colour Temp + Brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_sun_elevation_colour_brightness' }}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition, dynamic sun elevation lighting brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour_brightness') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic sun elevation lighting brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour_brightness') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set brightness_value = dynamic_lighting_max_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{% else %}
{% set brightness_value = dynamic_lighting_min_brightness %}
{% endif %}
{{ brightness_value | round(0) }}
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- choose:
- alias: "Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ include_dynamic_lighting == 'enable_sun_elevation_colour_lux_brightness' }}"
sequence:
- alias: "Dynamic Lighting Control"
repeat:
until: "{{ expand(light_switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"
sequence:
- choose:
- alias: "Set the transition, dynamic lighting lux brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour_lux_brightness') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_on_value }}"
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- alias: "Set the dynamic lighting lux brightness and dynamic sun elevation colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and (include_dynamic_lighting == 'enable_sun_elevation_colour_lux_brightness') }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities }}"
data:
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 %}
{% if lux <= dynamic_lighting_min_lux %}
{% set bv = dynamic_lighting_max_brightness %}
{% elif lux >= dynamic_lighting_max_lux %}
{% set bv = dynamic_lighting_min_brightness %}
{% else %}
{% set bv = ((slope * lux) + ak) | round(1) %}
{% endif %}
{% if lp <= 0 %}
{% set bv = bv %}
{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone %}
{% set bv = lp %}
{% elif bv > (lp + dynamic_lighting_step_value) %}
{% set bv = lp + dynamic_lighting_step_value %}
{% elif bv < (lp - dynamic_lighting_step_value) %}
{% set bv = lp - dynamic_lighting_step_value %}
{% endif %}
{{ bv | round(0) }}
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 %}
{% if elevation >= dynamic_lighting_sun_elevation_start_rising and elevation <= dynamic_lighting_sun_elevation_end_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = ((start_slope * elevation) + start_ak) | round(1) %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_falling and elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) %}
{% elif elevation >= dynamic_lighting_sun_elevation_end_rising and elevation >= dynamic_lighting_sun_elevation_start_falling %}
{% set colour_temp_value = dynamic_lighting_max_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_start_rising and is_state_attr('sun.sun', 'rising', true) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{% else %}
{% set colour_temp_value = dynamic_lighting_min_colour_temp %}
{% endif %}
{{ colour_temp_value | round(0) }}
- alias: "Dynamic lighting heartbeat"
delay:
minutes: !input dynamic_lighting_heartbeat
- stop: "Stop the automation"
- sequence:
- choose:
- alias: "Set the transition for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
transition: "{{ transition_on_value }}"
- alias: "Set the transition and brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
transition: "{{ transition_on_value }}"
brightness_pct: "{{ brightness_value }}"
- alias: "Set the transition and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
transition: "{{ transition_on_value }}"
kelvin: "{{temperature_value}}"
- alias: "Set the transition, brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
transition: "{{ transition_on_value }}"
brightness_pct: "{{ brightness_value }}"
kelvin: "{{temperature_value}}"
- alias: "Set the brightness for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
brightness_pct: "{{ brightness_value }}"
- alias: "Set the colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
kelvin: "{{temperature_value}}"
- alias: "Set the brightness and colour temperature for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
data:
brightness_pct: "{{ brightness_value }}"
kelvin: "{{temperature_value}}"
- alias: "Set the default for the normal lights switch"
conditions:
- condition: template
value_template: "{{ ('use_transition' not in include_light_control) and ('use_brightness' not in include_light_control) and (include_dynamic_lighting == 'disable_dynamic_lighting') and ('use_colour_temperature' not in include_light_control) }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light_entities_off }}"
- 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 == [] %}
false
{% elif is_state(night_boolean_scenes_scripts, 'on') %}
true
{% else %}
false
{% endif %}
sequence:
- alias: "If transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_light_control }}"
sequence:
- alias: "Turn on the scenes"
service: scene.turn_on
target:
entity_id: "{{ scene_entities }}"
data:
transition: "{{ transition_on_value }}"
- alias: "Turn on the boolean for scenes and scripts"
service: 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"
service: scene.turn_on
target:
entity_id: "{{ scene_entities }}"
- alias: "Turn on the boolean for scenes and scripts"
service: input_boolean.turn_on
data:
entity_id: "{{ boolean_scenes_scripts_helper }}"
- alias: "Turn on the switches"
service: switch.turn_on
target:
entity_id: "{{ switch_entities_off }}"
- alias: "Turn on the scripts"
service: 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"
service: 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"
service: 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"
service: 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:
platform: 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: "If transition is selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
data:
transition: "{{ transition_off_value }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
transition: "{{ transition_off_value }}"
- alias: "If transition is not selected"
conditions:
- condition: template
value_template: "{{ 'use_transition' not in include_light_control }}"
sequence:
- alias: "Turn off the lights"
service: light.turn_off
target:
entity_id: "{{ light_entities }}"
- alias: "Turn off the scenes"
service: scene.turn_on
data:
entity_id: "{{ end_scene_entities }}"
- alias: "Turn off the switches"
service: switch.turn_off
target:
entity_id: "{{ switch_entities }}"
- alias: "Turn off the script"
service: script.turn_on
data:
entity_id: "{{ end_script_entities }}"
- alias: "Turn off the boolean for scenes and scripts"
service: input_boolean.turn_off
data:
entity_id: !input boolean_scenes_scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment