diff --git a/blueprints/automation/Blackshome/sensor-light.yaml b/blueprints/automation/Blackshome/sensor-light.yaml index a691da9..ea68e2e 100644 --- a/blueprints/automation/Blackshome/sensor-light.yaml +++ b/blueprints/automation/Blackshome/sensor-light.yaml @@ -1,11 +1,11 @@ blueprint: name: Sensor Light - description: "# \U0001F4A1 Sensor Light\n**Version: 6.5**\n\nYour lighting experience, + description: "# \U0001F4A1 Sensor Light\n**Version: 8.1**\n\nYour lighting experience, your way - take control and customize it to perfection! \U0001F4A1✨\n\n**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) \U0001F642\n\n
- The Automation Process: - Click here to expand\n\n\n - \ - **Trigger:**\n - You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/) + The Automation Process: \U0001F448\n\n\n - **Trigger:**\n + \ - You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/) or [schedules](https://www.home-assistant.io/integrations/schedule) to trigger the automation.\n - A trigger sensor, such as a Motion Sensor, will activate lights, switches, scenes, and scripts when the automation is triggered.\n - @@ -15,974 +15,1614 @@ blueprint: resets for continuous lighting.\n\n - **Scene and Script Integration:**\n - Scenes or scripts offer additional customization for your spaces.\n\n - **Light Control Options:**\n - Utilize \"Light Control\" to adjust brightness, colour - temperature, and transition times.\n\n - **Dynamic Lighting Options:**\n - - 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.\n\n - \ - **Manual Override:**\n - Use \"Bypass Options\" for manual bypassing of - trigger sensors, providing manual control and additional customization.\n\n - - **Sun Elevation Options:**\n - Implement \"Sun Elevation\" to restrict automation - to darker conditions aligned with the sun's position.\n\n - **Ambient Light Sensing - Options:**\n - Set up an Ambient Light Sensor for activation in low-light conditions, - customizable with specified LUX values.\n\n - **Time-Based Options:**\n - - Specify precise start and end times along with weekday selections to define when - the automation should run.\n\n - **Device Tracker Options:**\n - Utilize \"Device - Tracker\" to activate automation when home or within specified zones, preventing - unnecessary activations. This feature is particularly useful to prevent unnecessary - lighting activations when pets trigger sensors while no one is home.\n\n - **Night - Lights Mode:**\n - Enable \"Night Lights\" for softer illumination during night - time activities, automatically enabled based on conditions.\n\n - **HA Restart - Safeguards:**\n - Benefit from built-in safeguards for Home Assistant restarts.\n - \ \n - **Blueprint Add-On Integration:**\n - Sensor Light Add-On - Enhances - media control automation. [Click Here](https://community.home-assistant.io/t/591824) + temperature, colour, and transition times.\n\n - **Dynamic Lighting Options:**\n + \ - Opt for 'Dynamic Lighting' to automatically adjust brightness based on lux + values, and/or adjust brightness and colour temperature according to the sun's + position or the time of day.\n - Opt to use the 'State Control Option,' allowing + you to toggle between dynamic lighting and normal lighting based on the entity's + activation state.\n\n - **Manual Override:**\n - Use \"Bypass Options\" for + manual bypassing of trigger sensors, providing manual control and additional customization.\n\n + \ - **Sun Elevation Options:**\n - Implement \"Sun Elevation\" to restrict + automation to darker conditions aligned with the sun's position.\n\n - **Ambient + Light Sensing Options:**\n - Set up an Ambient Light Sensor for activation + in low-light conditions, customizable with specified LUX values.\n\n - **Time-Based + Options:**\n - Specify precise start and end times along with weekday selections + to define when the automation should run.\n\n - **Device Tracker Options:**\n + \ - Utilize \"Device Tracker\" to activate automation when home or within specified + zones, preventing unnecessary activations. This feature is particularly useful + to prevent unnecessary lighting activations when pets trigger sensors while no + one is home.\n\n - **Night Lights Mode:**\n - Enable \"Night Lights\" for + softer illumination during night time activities, automatically enabled based + on conditions.\n - Opt to use \"Night Glow\". This feature activates a low-level + light when no trigger is detected, creating a subtle ambient glow perfect for + nighttime use.\n\n - **HA Restart Safeguards:**\n - Benefit from built-in + safeguards for Home Assistant restarts.\n\n - **Blueprint Add-On Integration:**\n + \ - Sensor Light Add-On - Enhances media control automation. [Click Here](https://community.home-assistant.io/t/591824) to learn more.\n - Bathroom Humidity Exhaust Fan - Keeps the lights ON when showering. [Click Here](https://community.home-assistant.io/t/509992) to learn - more.\n
\n\nThe Settings & Best Practice Guidelines: [Click Here](https://community.home-assistant.io/t/481048/345)\nNeed - help? See our FAQ: [Click Here](https://community.home-assistant.io/t/481048/6)\nLet - us know what you think of this blueprint and for community support including updates: - [Click Here](https://community.home-assistant.io/t/481048)\n\nRequired = *\n" + more.\n\n\nNeed help?\n- The Settings & Best Practice Guidelines: [Click + Here](https://community.home-assistant.io/t/481048/345)\n- FAQ: [Click Here](https://community.home-assistant.io/t/481048/6)\n- + Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/481048)\n\nRequired + = *\n" domain: automation input: - 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). + trigger: + name: Trigger * + icon: mdi:cog-outline + collapsed: true + input: + motion_trigger: + name: Trigger Sensor - Binary Sensors - Schedule * + description: 'The trigger sensors are responsible for turning the lights, + switches, scenes, and scripts ON and OFF. You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/) + you prefer as triggers. Alternatively, if you prefer a time-based trigger, + you can also add a [schedule helper](https://community.home-assistant.io/t/481048/1616). - When using multiple trigger sensors, it''s advisable to group them together - using a group helper. This ensures smoother automation execution and prevents - conflicts. + 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 grouping your trigger sensors [Click Here](https://community.home-assistant.io/t/481048/34) + + ' + default: [] + selector: + entity: + filter: + - domain: + - binary_sensor + - schedule + multiple: true + lights_settings: + name: Lights * + icon: mdi:lightbulb-outline + collapsed: true + input: + light_switch: + name: Lights - Switches - Scenes - Scripts * + description: 'The lights, switches, scenes, and scripts that will be activated + by the trigger sensor/s. If adding a scene or script, please refer to + the ''Scenes & Scripts - Toggle Helper'' section and the ''Scenes - Scripts + To Turn OFF'' section below. - For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595) + 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 - multiple: false - end_scenes: - name: Scenes - Scripts To Turn OFF - description: If you have selected a scene or a script to be turned ON above - in "Lights - Switches - Scenes - Scripts" or below in "Night Lights," and - you would like it to be turned OFF after the time delay, then you must create - a scene or a script with everything OFF and enter it here. - default: [] - selector: - entity: - multiple: true - filter: - - domain: - - scene - - script - time_delay: - name: Time Delay - description: The time delay determines how long the lights, switches, scenes, - and scripts will remain active after all triggers are clear, initiating the - time delay to turn them OFF. - default: 5 - selector: - number: - min: 0.0 - max: 30.0 - step: 0.5 - unit_of_measurement: minutes - mode: slider - 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 - sort: false - custom_value: false - light_brightness: - name: Brightness - description: The brightness setting for the lights when they are turned ON. - default: 100 - selector: - number: - min: 1.0 - max: 100.0 - mode: slider - step: 1.0 - unit_of_measurement: '%' - light_colour_temperature: - name: Colour Temperature - description: The colour temperature setting for the lights when they are turned - ON. - default: 5000 - selector: - number: - min: 2000.0 - max: 8000.0 - mode: slider - step: 100.0 - unit_of_measurement: kelvin - light_transition_on: - name: Transition - ON - description: The transition setting for the lights when they are turned ON. - default: 1 - selector: - number: - min: 0.0 - max: 5.0 - mode: slider - step: 0.5 - unit_of_measurement: seconds - light_transition_off: - name: Transition - OFF - description: The transition setting for the lights when they are turned OFF. - default: 1 - selector: - number: - min: 0.0 - max: 30.0 - mode: slider - step: 1.0 - unit_of_measurement: seconds - include_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. + **NOTE** - You can only use entities. Areas, devices and labels are not + supported. + + ' + default: [] + selector: + target: + entity: + - domain: + - light + - switch + - scene + - script + boolean_scenes_scripts: + name: Scenes & Scripts - Toggle Helper + description: 'To ensure the smooth operation of the automation, it''s recommended + to create an independent toggle helper when selecting a scene or script + in "Lights - Switches - Scenes - Scripts" above and then enter it here. + + ' + default: [] + selector: + entity: + filter: + - domain: + - input_boolean + multiple: false + end_scenes: + name: Scenes - Scripts To Turn OFF + description: 'If you have selected a scene or a script to be turned ON above + in "Lights - Switches - Scenes - Scripts" or below in "Night Lights," + and you would like it to be turned OFF after the time delay, then you + must create a scene or a script with everything OFF and enter it here. + + ' + default: [] + selector: + entity: + multiple: true + filter: + - domain: + - scene + - script + time_delay: + name: Time Delay + description: 'The time delay determines how long the lights, switches, scenes, + and scripts will remain active after all triggers are clear, initiating + the time delay to turn them OFF. + + ' + default: 5 + selector: + number: + min: 0.0 + max: 30.0 + step: 0.5 + unit_of_measurement: minutes + mode: slider + normal_lights_settings: + name: Light Control + icon: mdi:lightbulb-on-outline + collapsed: true + input: + include_light_control: + name: Light Control Options (Optional) + description: 'Select if you would like to use brightness or transition. + These settings will only affect a ''light'' entity that supports each + selected option. The settings for brightness and transition are provided + below. + + ' + default: [] + selector: + select: + multiple: true + options: + - label: Use Brightness + value: use_brightness + - label: Use Transition + value: use_transition + custom_value: false + sort: false + light_brightness: + name: Brightness + description: 'The brightness setting for the lights when they are turned + ON. + + ' + default: 100 + selector: + number: + min: 1.0 + max: 100.0 + mode: slider + step: 1.0 + unit_of_measurement: '%' + light_transition_on: + name: Transition - ON + description: 'The transition setting for the lights when they are turned + ON. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 5.0 + mode: slider + step: 0.5 + unit_of_measurement: seconds + light_transition_off: + name: Transition - OFF + description: 'The transition setting for the lights when they are turned + OFF. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 30.0 + mode: slider + step: 1.0 + unit_of_measurement: seconds + include_light_colour_control: + name: Light Colour Control Options (Optional) + description: 'Select if you would like to use colour temperature, RGB, RGBW + or RGBWW colour. These settings will only affect a ''light'' entity that + supports each selected option. The settings for colour temperature, RGB, + RGBW and RGBWW colour are provided below. + + ' + default: disable_colour_control + selector: + select: + options: + - label: Use Colour Temperature + value: use_colour_temperature + - label: Use RGB Colour + value: use_rgb_colour + - label: Use RGBW Colour + value: use_rgbw_colour + - label: Use RGBWW Colour + value: use_rgbww_colour + - label: Disable Colour Control + value: disable_colour_control + custom_value: false + sort: false + multiple: false + light_colour_temperature: + name: Colour Temperature + description: 'The colour temperature setting for the lights when they are + turned ON. + + ' + default: 5000 + selector: + number: + min: 2000.0 + max: 8000.0 + mode: slider + step: 100.0 + unit_of_measurement: kelvin + light_rgb_colour: + name: RGB Colour + description: 'The RGB colour setting for the lights when they are turned + ON. + + ' + default: + - 255 + - 255 + - 255 + selector: + color_rgb: {} + light_rgbw_colour: + name: RGBW Colour + description: 'The RGBW colour setting for the lights when they are turned + ON. Enter four integers between 0 and 255 to define the values for Red, + Green, Blue, and White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + selector: + object: {} + light_rgbww_colour: + name: RGBWW Colour + description: 'The RGBWW colour setting for the lights when they are turned + ON. Enter five integers between 0 and 255 to define the values for Red, + Green, Blue, Cold White and Warm White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + - 255 + selector: + object: {} + dynamic_lighting_settings: + name: Dynamic Lighting + icon: mdi:creation-outline + collapsed: true + input: + include_dynamic_lighting: + name: Use The Dynamic Lighting Options (Optional) + description: "This option makes continual adjustments to your normal lighting + setup by modulating brightness based on floating lux values, or adapting + both colour temperature and brightness according to the sun's changing + elevation or the time of day. Choose from thirteen preset options available + in the dropdown menu.\n\n 1 - Lux Controlled Brightness\n 2 - Lux Controlled + Brightness Inverted\n 3 - Sun Elevation Lighting - Colour Temp\n 4 - + Sun Elevation Lighting - Brightness\n 5 - Sun Elevation Lighting - Brightness + Inverted\n 6 - Sun Elevation Lighting - Colour Temp + Brightness\n 7 + - Sun Elevation Lighting - Colour Temp + Brightness Inverted\n 8 - Sun + Elevation Lighting - Colour Temp + Lux Controlled Brightness\n 9 - Sun + Elevation Lighting - Colour Temp + Lux Controlled Brightness Inverted\n + \ 10 - Time Controlled - Colour Temp\n 11 - Time Controlled - Brightness\n + \ 12 - Time Controlled - Brightness Inverted\n 13 - Time Controlled - + Colour Temp + Brightness\n\nA numbering system has been implemented to + facilitate navigation within the dropdown selections. Each number corresponds + to a specific configuration, aiding users in identifying and adjusting + the settings used within each selection. For instance, when selecting + \"3 - Sun Elevation Lighting - Colour Temp\" as a dropdown option, settings + marked \"Used in options 3, 6, 7, 8, 9, 10 or 13\" are required for that + respective selection because number 3 is included in those options.\n\nFor + more information on dynamic lighting settings [Click Here](https://community.home-assistant.io/t/481048/837)\n" + default: disable_dynamic_lighting + selector: + select: + mode: dropdown + options: + - label: Disable Dynamic Lighting + value: disable_dynamic_lighting + - label: 1 - Lux Controlled Brightness + value: enable_lux_controled_brightness + - label: 2 - Lux Controlled Brightness Inverted + value: enable_lux_controled_brightness_inv + - label: 3 - Sun Elevation Lighting - Colour Temp + value: enable_sun_elevation_colour + - label: 4 - Sun Elevation Lighting - Brightness + value: enable_sun_elevation_brightness + - label: 5 - Sun Elevation Lighting - Brightness Inverted + value: enable_sun_elevation_brightness_inv + - label: 6 - Sun Elevation Lighting - Colour Temp + Brightness + value: enable_sun_elevation_colour_brightness + - label: 7 - Sun Elevation Lighting - Colour Temp + Brightness Inverted + value: enable_sun_elevation_colour_brightness_inv + - label: 8 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness + value: enable_sun_elevation_colour_lux_brightness + - label: 9 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness + Inverted + value: enable_sun_elevation_colour_lux_brightness_inv + - label: 10 - Time Controlled - Colour Temp + value: enable_time_controled_colour + - label: 11 - Time Controlled - Brightness + value: enable_time_controled_brightness + - label: 12 - Time Controlled - Brightness Inverted + value: enable_time_controled_brightness_inv + - label: 13 - Time Controlled - Colour Temp + Brightness + value: enable_time_controled_colour_brightness + custom_value: false + sort: false + multiple: false + dynamic_lighting_lux_sensor: + name: Dynamic Lighting - Ambient Light Sensor + description: '**Used in options 1, 2, 8 or 9** - Enter the specific ambient + light sensor to be used, based on your selected Dynamic Lighting option. + + ' + default: [] + selector: + entity: + filter: + - domain: + - sensor + device_class: + - illuminance + multiple: false + dynamic_lighting_max_lux: + name: Dynamic Lighting - Max Lux Value + description: '**Used in options 1, 2, 8 or 9** - Specify the maximum lux + value. Once the lux level meets or surpasses this set point, your lights + will adjust to either their maximum or minimum brightness, depending on + your chosen option. This value indicates when you prefer your lights + to start turning on or off. + + ' + default: 400 + selector: + number: + min: 10.0 + max: 900.0 + step: 10.0 + unit_of_measurement: lux + mode: slider + dynamic_lighting_min_lux: + name: Dynamic Lighting - Min Lux Value + description: '**Used in options 1, 2, 8 or 9** - Specify the minimum lux + value. Once the lux level meets or surpasses this set point, your lights + will adjust to either their maximum or minimum brightness, depending on + your chosen option. This value indicates when you prefer your lights + to start turning on or off. + + ' + default: 40 + selector: + number: + min: 0.0 + max: 600.0 + step: 10.0 + unit_of_measurement: lux + mode: slider + dynamic_lighting_max_brightness: + name: Dynamic Lighting - Max Brightness Value + description: '**Used in options 1, 2, 4, 5, 6, 7, 8, 9, 11, 12 or 13** - + Define the maximum brightness value, determines the peak brightness level + for your lights. + + ' + default: 100 + selector: + number: + min: 10.0 + max: 100.0 + step: 1.0 + unit_of_measurement: '%' + mode: slider + dynamic_lighting_min_brightness: + name: Dynamic Lighting - Min Brightness Value + description: '**Used in options 1, 2, 4, 5, 6, 7, 8, 9, 11, 12 or 13** - + Specify the minimum brightness value, establishing the lowest brightness + level for your lights. When setting the brightness to 0%, the light will + be turned off. + + ' + default: 0 + selector: + number: + min: 0.0 + max: 100.0 + step: 1.0 + unit_of_measurement: '%' + mode: slider + dynamic_lighting_boolean: + name: Dynamic Lighting - Toggle Helper (Optional) + description: '**Used in options 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 or 13** + - If you have chosen a brightness level of 0%, then it''s essential to + create an independent toggle helper and enter it here. This toggle helper + can also address issues if the automation doesn''t behave as expected + due to the occasional unavailability of light entities. While it may not + always be necessary, if you''re open to creating toggle helpers, it''s + highly recommended to utilize this option to ensure proper functionality + of the automation. + + ' + default: [] + selector: + entity: + filter: + - domain: + - input_boolean + multiple: false + dynamic_lighting_max_colour_temp: + name: Dynamic Lighting - Max Colour Temperature + description: '**Used in options 3, 6, 7, 8, 9, 10 or 13** - Specify the + highest colour temperature value, determining the coolest colour setting + for your lights. + + ' + default: 5000 + selector: + number: + min: 2500.0 + max: 8000.0 + mode: slider + step: 100.0 + unit_of_measurement: kelvin + dynamic_lighting_min_colour_temp: + name: Dynamic Lighting - Min Colour Temperature + description: '**Used in options 3, 6, 7, 8, 9, 10 or 13** - Set the lowest + colour temperature value, defining the warmest colour setting for your + lights. + + ' + default: 3000 + selector: + number: + min: 2000.0 + max: 7500.0 + mode: slider + step: 100.0 + unit_of_measurement: kelvin + dynamic_lighting_sun_elevation_start_rising: + name: Dynamic Lighting - Sun Elevation Rising - Start Point + description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun rises + above the sensor''s starting point, both the colour temperature and brightness + percentage will transition linearly from their minimum to maximum values + until they reach the rising endpoint, based on your selected Dynamic Lighting + option. + + ' + default: -1.5 + selector: + number: + min: -10.0 + max: 30.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + dynamic_lighting_sun_elevation_end_rising: + name: Dynamic Lighting - Sun Elevation Rising - End Point + description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun rises + above the sensor''s endpoint, the maximum colour temperature and maximum + brightness value will be established, based on your selected Dynamic Lighting + option. + + ' + default: 15 + selector: + number: + min: 0.0 + max: 90.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + dynamic_lighting_sun_elevation_start_falling: + name: Dynamic Lighting - Sun Elevation Descending - Start Point + description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun descends + below the sensor''s starting point, both the colour temperature and brightness + percentage will transition linearly from their maximum to minimum values + until they reach the descending endpoint, based on your selected Dynamic + Lighting option. + + ' + default: 15 + selector: + number: + min: 0.0 + max: 90.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + dynamic_lighting_sun_elevation_end_falling: + name: Dynamic Lighting - Sun Elevation Descending - End Point + description: '**Used in options 3, 4, 5, 6, 7, 8 or 9** - When the sun descends + below the sensor''s endpoint, the minimum colour temperature and minimum + brightness value will be established, based on your selected Dynamic + Lighting option. + + ' + default: -4.0 + selector: + number: + min: -10.0 + max: 30.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + dynamic_lighting_time_start_morning: + name: Dynamic Lighting - Time Morning - Start Point + description: '**Used in options 10, 11, 12 or 13** - When the time passes + over the start point, both the colour temperature and brightness percentage + will transition linearly from their minimum to maximum values until they + reach the rising endpoint, based on your selected Dynamic Lighting option. + + ' + default: 06:00:00 + selector: + time: {} + dynamic_lighting_time_end_morning: + name: Dynamic Lighting - Time Morning - End Point + description: '**Used in options 10, 11, 12 or 13** - When the time passes + over the end point, the maximum colour temperature and maximum brightness + value will be established, based on your selected Dynamic Lighting option. + + ' + default: 09:00:00 + selector: + time: {} + dynamic_lighting_time_start_evening: + name: Dynamic Lighting - Time Evening - Start Point + description: '**Used in options 10, 11, 12 or 13** - When the time passes + over the start point, both the colour temperature and brightness percentage + will transition linearly from their maximum to minimum values until they + reach the descending endpoint, based on your selected Dynamic Lighting + option. + + ' + default: '17:00:00' + selector: + time: {} + dynamic_lighting_time_end_evening: + name: Dynamic Lighting - Time Evening - End Point + description: '**Used in options 10, 11, 12 or 13** - When the time passes + over the end point, the minimum colour temperature and minimum brightness + value will be established, based on your selected Dynamic Lighting option. + + ' + default: '19:00:00' + selector: + time: {} + dynamic_lighting_heartbeat: + name: Dynamic Lighting - Heartbeat + description: '**Used in options 1, 2, 8, 9, 10, 11, 12 or 13** - Define + the heartbeat rate to set the operational speed. During each heartbeat, + it may evaluate the lux value, light brightness, colour temperature, target + colour temperature, and target brightness, adjusting the colour temperature + or brightness based on your selected Dynamic Lighting option. - 1 - Lux Controlled Brightness + **Note** - When using a **Time Controlled** option (10, 11, 12, or 13), + the minimum heartbeat should be set to no lower than 1 minute, with adjustments + made in 1-minute increments (e.g., 1, 2, 3, 4, 5, and so on), as setting + it lower will not provide any benefit and may slow down your system''s + performance. Depending on the duration between the start and end points + of the light transition, adjusting this value will determine the size + of the step value. A longer heartbeat generally improves performance, + but it may also result in larger step values that could be bothersome + to the eye. Take the time to determine the correct heartbeat value for + your needs. The heartbeat is only active between the start and end points. - 2 - Lux Controlled Brightness - Inverted + ' + default: 1 + selector: + number: + min: 0.25 + max: 10.0 + step: 0.25 + unit_of_measurement: minutes + mode: slider + dynamic_lighting_step_value: + name: Dynamic Lighting - Step Value + description: '**Used in options 1, 2, 8, or 9** - With every heartbeat, + the system evaluates the lux value, light brightness, and targeted brightness. + If the targeted brightness exceeds the predefined step value, the system + applies the set step value to gradually moderate the rate of change, ensuring + a smoother transition in light brightness. - 3 - Sun Elevation Lighting - Colour Temp + ' + default: 4 + selector: + number: + min: 1.0 + max: 100.0 + step: 1.0 + unit_of_measurement: '%' + mode: slider + dynamic_lighting_dead_zone: + name: Dynamic Lighting - Dead Zone (±) + description: '**Used in options 1, 2, 8, or 9** - With every heartbeat, + the system evaluates the current light brightness and the targeted brightness. + If the targeted brightness falls within the defined dead zone, the system + maintains the current light brightness. This prevents minor fluctuations + in light intensity that could be bothersome to the eye. - 4 - Sun Elevation Lighting - Brightness + ' + default: 7 + selector: + number: + min: 0.0 + max: 15.0 + step: 1.0 + unit_of_measurement: '%' + mode: slider + dynamic_lighting_state_control: + name: Dynamic Lighting - State Control Option (Optional) + description: 'Enable or disable dynamic lighting based on the state of a + specified entity. When the entity is in the selected activation state + below, dynamic lighting will function as configured. When the entity is + not in the activation state below, dynamic lighting will be disabled. + This allows you to toggle between normal lighting and dynamic lighting + based on the entity''s state. - 5 - Sun Elevation Lighting - Brightness - Inverted + ' + default: disable_state_control + selector: + select: + options: + - label: Enable State Control Option + value: enable_state_control + - label: Disable State Control Option + value: disable_state_control + custom_value: false + sort: false + multiple: false + dynamic_lighting_state_control_activation_state: + name: Dynamic Lighting - State Control Activation State + description: 'Select the state the entity must be in to activate dynamic + lighting. When the entity is in the selected state (ON or OFF), dynamic + lighting will be enabled. This option defines the activation condition + for dynamic lighting. - 6 - Sun Elevation Lighting - Colour Temp + Brightness + ' + default: 'on' + selector: + select: + options: + - label: ON State + value: 'on' + - label: OFF State + value: 'off' + custom_value: false + sort: false + multiple: false + dynamic_lighting_state_control_entity: + name: Dynamic Lighting - State Control Entity + description: 'If the state control option above is enabled, select the entity + that will toggle dynamic lighting based on its activation state above. - 7 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness + ' + default: [] + selector: + entity: {} + bypass_settings: + name: Bypass + icon: mdi:cog-pause-outline + collapsed: true + input: + include_bypass: + name: Use The Bypass Options (Optional) + description: "Select if you would like to enable an option. Each option + determines how your lights will behave when the bypass switch is turned + ON:\n\n 1 - Turns the lights ON\n 2 - Turns the lights OFF\n 3 - Keeps + the lights current state\n\nIf you enable an option, make sure to enter + the corresponding bypass switch in the input below.\n\nFor more information + on how to use the bypass [Click Here](https://community.home-assistant.io/t/481048/895)\n" + default: [] + selector: + select: + options: + - label: 1 - Enable the Bypass - Turn the Lights ON + value: bypass_enabled_turn_on + - label: 2 - Enable the Bypass - Turn the Lights OFF + value: bypass_enabled_turn_off + - label: 3 - Enable the Bypass - Keep the Lights Current State + value: bypass_enabled_stop + multiple: true + custom_value: false + sort: false + motion_bypass_lights_on: + name: Bypass Switch - Turn the Lights ON + description: 'Select the switches that will turn your lights ON, bypass + the trigger sensor, and allow your lights to function as normal. Please + note that the entity cannot be included in the ''Lights - Switches - Scenes + - Scripts'' or ''Night Lights'' selections. + + ' + default: [] + selector: + entity: + multiple: true + motion_bypass_lights_off: + name: Bypass Switch - Turn the Lights OFF + description: 'Select the switches that will turn your lights OFF, bypass + the trigger sensor, and allow your lights to function as normal. Please + note that the entity cannot be included in the ''Lights - Switches - Scenes + - Scripts'' or ''Night Lights'' selections. + + ' + default: [] + selector: + entity: + multiple: true + motion_bypass_lights_stop: + name: Bypass Switch - Keep the Lights Current State + description: 'Select the switches that will keep your lights current state, + bypass the trigger sensor, and allow your lights to function as normal. + Please note that the entity cannot be included in the ''Lights - Switches + - Scenes - Scripts'' or ''Night Lights'' selections. + + ' + default: [] + selector: + entity: + multiple: true + bypass_time_delay: + name: Bypass - Time Delay + description: "This is only used in two specific bypass scenarios when your + lights are ON:\n\n 1. When you have selected option 2 above to \"Enable + the Bypass - Turn the Lights OFF\" and you turn the bypass ON.\n 2. When + the bypass is turned OFF, the trigger sensor is OFF, and your lights are + still ON.\n\nIn both cases, the automation will turn your lights OFF after + the set time delay.\n" + default: 0 + selector: + number: + min: 0.0 + max: 10.0 + step: 0.25 + unit_of_measurement: minutes + mode: slider + include_bypass_auto_off: + name: Use The Bypass Auto OFF Option (Optional) + description: "Enable this option if you want the bypass to automatically + turn OFF after a set time delay. You can choose which bypass option the + auto OFF will apply to:\n\n 1 - Turns the lights ON\n 2 - Turns the + lights OFF\n 3 - Keeps the lights current state\n\nEach option corresponds + to one of the bypass options above.\n" + default: [] + selector: + select: + options: + - label: A - Enable Auto OFF for Bypass Option 1 - Turn the Lights ON + value: bypass_auto_off_enabled_on + - label: B - Enable Auto OFF for Bypass Option 2 - Turn the Lights OFF + value: bypass_auto_off_enabled_off + - label: C - Enable Auto OFF for Bypass Option 3 - Keep the Lights Current + State + value: bypass_auto_off_enabled_stop + multiple: true + custom_value: false + sort: false + bypass_auto_off_delay: + name: Bypass Auto OFF - Time Delay + description: 'Set the bypass auto OFF time delay. The time delay starts + from the last bypass that was turned ON. + + ' + default: 60 + selector: + number: + min: 1.0 + max: 240.0 + step: 1.0 + unit_of_measurement: minutes + mode: slider + sun_settings: + name: Sun Elevation + icon: mdi:weather-sunny + collapsed: true + input: + include_sun: + name: Use The Sun Option (Optional) + description: 'This option is used to add a condition that only allows the + automation to run when it is dark or below the ''Sun Elevation'' settings. + It''s a global condition that can work alongside other options. Enabling + this option is not necessary for the night lights sun elevation condition + to work. - 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 sun settings [Click Here](https://community.home-assistant.io/t/481048/37) + + ' + default: sun_disabled + selector: + select: + options: + - label: Enable the sun option + value: sun_enabled + - label: Disable the sun option + value: sun_disabled + custom_value: false + sort: false + multiple: false + sun_elevation: + name: Sun Elevation Falling + description: 'The sun elevation falling refers to the angle between the + sun and the horizon when the sun is setting. A negative value indicates + that the sun is BELOW the horizon. For example, a setting guide of -1.5 + corresponds to dusk + + ' + default: -1.5 + selector: + number: + min: -10.0 + max: 5.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + sun_elevation_rising: + name: Sun Elevation Rising + description: 'The sun elevation rising refers to the angle between the sun + and the horizon during sunrise. A negative value indicates that the sun + is BELOW the horizon. For example, a setting guide of -4.0 corresponds + to dawn. + + ' + default: -4.0 + selector: + number: + min: -10.0 + max: 5.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + ambient_settings: + name: Ambient + icon: mdi:theme-light-dark + collapsed: true + input: + include_ambient: + name: Use The Ambient Options (Optional) + description: 'This option is used to add a condition that only allows the + automation to run when it is dark or below the ''Ambient'' settings. It''s + a global condition that can work alongside other options. - For more information on 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 - multiple: false - sort: false - custom_value: false - 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 - multiple: false - 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.0 - max: 900.0 - step: 10.0 - unit_of_measurement: lux - mode: slider - dynamic_lighting_min_lux: - name: Dynamic Lighting - Min Lux Value - description: '**Used in options 1, 2 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.0 - max: 600.0 - step: 10.0 - unit_of_measurement: lux - mode: slider - dynamic_lighting_max_brightness: - name: Dynamic Lighting - Max Brightness Value - description: '**Used in options 1, 2, 4, 5, 6 or 7** - Define the maximum brightness - value, determines the peak brightness level for your lights.' - default: 100 - selector: - number: - min: 10.0 - max: 100.0 - step: 1.0 - unit_of_measurement: '%' - mode: slider - dynamic_lighting_min_brightness: - name: Dynamic Lighting - Min Brightness Value - description: '**Used in options 1, 2, 4, 5, 6 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.0 - max: 100.0 - step: 1.0 - unit_of_measurement: '%' - mode: slider - 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.0 - max: 8000.0 - mode: slider - step: 100.0 - unit_of_measurement: kelvin - dynamic_lighting_min_colour_temp: - name: Dynamic Lighting - Min Colour Temperature - description: '**Used in options 3, 6 or 7** - Set the lowest colour temperature - value, defining the warmest colour setting for your lights.' - default: 3000 - selector: - number: - min: 2000.0 - max: 7500.0 - mode: slider - step: 100.0 - unit_of_measurement: kelvin - dynamic_lighting_sun_elevation_start_rising: - name: Dynamic Lighting - Sun Elevation Rising - Start Point - description: '**Used in options 3, 4, 5, 6 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.0 - max: 30.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - dynamic_lighting_sun_elevation_end_rising: - name: Dynamic Lighting - Sun Elevation Rising - End Point - description: '**Used in options 3, 4, 5, 6 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.0 - max: 90.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - dynamic_lighting_sun_elevation_start_falling: - name: Dynamic Lighting - Sun Elevation Descending - Start Point - description: '**Used in options 3, 4, 5, 6 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.0 - max: 90.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - dynamic_lighting_sun_elevation_end_falling: - name: Dynamic Lighting - Sun Elevation Descending - End Point - description: '**Used in options 3, 4, 5, 6 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.0 - max: 30.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - 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.0 - step: 0.25 - unit_of_measurement: minutes - mode: slider - dynamic_lighting_step_value: - name: Dynamic Lighting - Step Value - description: '**Used in options 1, 2 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.0 - max: 100.0 - step: 1.0 - unit_of_measurement: '%' - mode: slider - dynamic_lighting_dead_zone: - name: Dynamic Lighting - Dead Zone (±) - description: '**Used in options 1, 2 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.0 - max: 15.0 - step: 1.0 - unit_of_measurement: '%' - mode: slider - 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 ambient settings [Click Here](https://community.home-assistant.io/t/481048/1608) + + ' + default: ambient_disabled + selector: + select: + options: + - label: Enable the ambient options + value: ambient_enabled + - label: Disable the ambient options + value: ambient_disabled + custom_value: false + sort: false + multiple: false + ambient_light_sensor: + name: Ambient Light Sensor + description: 'Select the ambient sensor to be used. + + ' + default: [] + selector: + entity: + filter: + - domain: + - sensor + device_class: + - illuminance + multiple: false + ambient_light_options: + name: Ambient Light Sensor - Site Conditions + description: 'In some cases when your lights turn ON, your ambient light + sensor is affected, increasing its LUX value. This can cause the lights + to go OFF prematurely. Please select an option that best suits your installation. - 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 - sort: false - custom_value: false - 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.0 - max: 10.0 - step: 0.25 - unit_of_measurement: minutes - mode: slider - include_bypass_auto_off: - name: Use The Bypass Auto OFF Option (Optional) - description: 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 - sort: false - custom_value: false - bypass_auto_off_delay: - name: Bypass Auto OFF - Time Delay - description: Set the bypass auto OFF time delay. The time delay starts from - the last bypass that was turned ON. - default: 60 - selector: - number: - min: 1.0 - max: 240.0 - step: 1.0 - unit_of_measurement: minutes - mode: slider - 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. + **NOTE** - If using an offset between the high and low lux value, then + please select NO. + + ' + default: ambient_light_option_disabled + selector: + select: + options: + - label: YES - My Ambient Light Sensor is affected by the Lights + value: ambient_light_option_enabled + - label: NO - My Ambient Light Sensor is not affected by the Lights + value: ambient_light_option_disabled + custom_value: false + sort: false + multiple: false + ambient_light_value: + name: Ambient Light - Low Lux Value + description: 'Set the Ambient Light Low Lux Value. The light will turn ON + when the lux level is below the set value. This value must be equal or + lower than the "High Lux Value" below. Guide is 20 lux (dusk). + + ' + default: 20 + selector: + number: + min: 0.0 + max: 500.0 + step: 10.0 + unit_of_measurement: lux + mode: slider + ambient_light_high_value: + name: Ambient Light - High Lux Value + description: 'Set the Ambient Light High Lux Value. The light will turn + OFF when the lux level is above the set value. This value must be equal + or higher than the "Low Lux Value" above. Setting a value higher than + the low value allows for an offset. Guide is 80 lux (dawn). + + ' + default: 80 + selector: + number: + min: 0.0 + max: 1000.0 + step: 10.0 + unit_of_measurement: lux + mode: slider + time_settings: + name: Time + icon: mdi:clock-outline + collapsed: true + input: + include_time: + name: Use The Time Options (Optional) + description: 'This option is used to add a condition that only allows the + automation to run between the start time and end time settings on the + selected weekdays. These time settings are global conditions that can + work alongside other options. Enabling this option is not necessary for + the night lights time condition to work. - For more information on 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 - multiple: false - sort: false - custom_value: false - sun_elevation: - name: Sun Elevation Falling - description: The sun elevation falling refers to the angle between the sun and - the horizon when the sun is setting. A negative value indicates that the sun - is BELOW the horizon. For example, a setting guide of -1.5 corresponds to - dusk - default: -1.5 - selector: - number: - min: -10.0 - max: 5.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - sun_elevation_rising: - name: Sun Elevation Rising - description: The sun elevation rising refers to the angle between the sun and - the horizon during sunrise. A negative value indicates that the sun is BELOW - the horizon. For example, a setting guide of -4.0 corresponds to dawn. - default: -4.0 - selector: - number: - min: -10.0 - max: 5.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - 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 time settings [Click Here](https://community.home-assistant.io/t/481048/310) + + ' + default: time_disabled + selector: + select: + options: + - label: Enable the time options + value: time_enabled + - label: Disable the time options + value: time_disabled + custom_value: false + sort: false + multiple: false + after_time: + name: Start Time + description: 'Set the start time. + + ' + default: 00:00:00 + selector: + time: {} + before_time: + name: End Time + description: 'Set the end time. + + ' + default: 00:00:00 + selector: + time: {} + weekday_options: + name: Weekdays + description: 'Select the days of the week you would like the automation + to run. You must select "Enable the time options" above for the weekday + selections to work. + + ' + default: + - mon + - tue + - wed + - thu + - fri + - sat + - sun + selector: + select: + multiple: true + mode: list + options: + - label: Monday + value: mon + - label: Tuesday + value: tue + - label: Wednesday + value: wed + - label: Thursday + value: thu + - label: Friday + value: fri + - label: Saturday + value: sat + - label: Sunday + value: sun + custom_value: false + sort: false + device_tracker_settings: + name: Device Tracker + icon: mdi:account-multiple-check-outline + collapsed: true + input: + include_device_tracker: + name: Use The Device Tracker Options (Optional) + description: 'Home Assistant can track the location of your devices (such + as mobile phones) within a designated zone via the mobile app device tracker. + To utilize this option, you need to set up a zone and configure your devices + for tracking in Home Assistant. There are two enable options available; + "Zone" tracks all devices within the zone, while "Zone + People" allows + you to track individuals within a zone. This feature can be particularly + useful if you have pets triggering the sensor, turning your lights ON + and OFF when no one is home. + + ' + default: device_tracker_disabled + selector: + select: + options: + - label: Enable the zone option + value: zone_enabled + - label: Enable the zone + people options + value: zone_people_enabled + - label: Disable the device tracker options + value: device_tracker_disabled + custom_value: false + sort: false + multiple: false + zone: + name: Device Tracker - Zone + description: 'Choose the zone that will track your devices and/or people + in it. + + ' + default: [] + selector: + entity: + filter: + - domain: + - zone + multiple: false + people: + name: Device Tracker - People + description: 'Select the people you would like to track in the zone selected + above. You must enter a zone above for this option to work. + + ' + default: [] + selector: + entity: + multiple: true + filter: + - domain: + - person + night_lights_trigger_settings: + name: Night Lights Settings + icon: mdi:weather-night + collapsed: true + input: + include_night_lights: + name: Use The Night Lights Options (Optional) + description: 'Enabling the night lights options allows for separate and + customizable lighting control when the night lights conditions are met. + Night light condition options include entity state, time, or sun elevation. + Please choose the condition option you would like to use below. This feature + is particularly beneficial for creating a soothing ambiance with softer + lighting at night. The flexibility of these options allows for personalized + adjustments, enhancing your night time ambiance and comfort, especially + when moving around during the night. + + ' + default: night_lights_disabled + selector: + select: + options: + - label: Enable the night lights options + value: night_lights_enabled + - label: Disable the night lights options + value: night_lights_disabled + custom_value: false + sort: false + multiple: false + night_lights_conditions: + name: Night Lights Conditions (Required For Night Lights) + description: 'Select any night light condition from the options provided + and ensure that **Use Night Lights Options** is enabled in the section + above. You must choose at least one ''Night Light Condition'' for the + night lights to operate, and the settings for each condition are provided + below. If you select two or more conditions, all selected conditions must + be met for the night lights to activate. + + ' + default: [] + selector: + select: + multiple: true + options: + - label: Enable entity state option + value: entity_state_enabled + - label: Enable time option + value: time_enabled + - label: Enable sun elevation option + value: sun_enabled + custom_value: false + sort: false + night_lights_entity_state: + name: Night Lights - Entity State + description: 'Select an entity that will trigger the activation of night + lights when turned ON. This could be your phone on ''Do Not Disturb'', + a helper, a bed sensor, etc. Please note that the selected entity cannot + be included in the ''Lights - Switches - Scenes - Scripts'' or ''Night + Lights'' selections. - For more information on 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 - multiple: false - sort: false - custom_value: false - ambient_light_sensor: - name: Ambient Light Sensor - description: Select the ambient sensor to be used. - default: [] - selector: - entity: - filter: - - domain: - - sensor - device_class: - - illuminance - multiple: false - ambient_light_options: - name: Ambient Light Sensor - Site Conditions - description: 'In some cases when your lights turn ON, your ambient light sensor - is affected, increasing its LUX value. This can cause the lights to go OFF - prematurely. Please select an option that best suits your installation. + 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. - **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 - multiple: false - sort: false - custom_value: false - ambient_light_value: - name: Ambient Light - Low Lux Value - description: Set the Ambient Light Low Lux Value. The light will turn ON when - the lux level is below the set value. This value must be equal or lower than - the "High Lux Value" below. Guide is 20 lux (dusk). - default: 20 - selector: - number: - min: 0.0 - max: 500.0 - step: 10.0 - unit_of_measurement: lux - mode: slider - ambient_light_high_value: - name: Ambient Light - High Lux Value - description: Set the Ambient Light High Lux Value. The light will turn OFF when - the lux level is above the set value. This value must be equal or higher than - the "Low Lux Value" above. Setting a value higher than the low value allows - for an offset. Guide is 80 lux (dawn). - default: 80 - selector: - number: - min: 0.0 - max: 1000.0 - step: 10.0 - unit_of_measurement: lux - mode: slider - 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. + ' + 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. - 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 - multiple: false - sort: false - custom_value: false - after_time: - name: Start Time - description: Set the start time. - default: 00:00:00 - selector: - time: {} - before_time: - name: End Time - description: Set the end time. - default: 00:00:00 - selector: - time: {} - weekday_options: - name: Weekdays - description: Select the days of the week you would like the automation to run. - You must select "Enable the time options" above for the weekday selections - to work. - default: - - mon - - tue - - wed - - thu - - fri - - sat - - sun - selector: - select: - multiple: true - mode: list - options: - - label: Monday - value: mon - - label: Tuesday - value: tue - - label: Wednesday - value: wed - - label: Thursday - value: thu - - label: Friday - value: fri - - label: Saturday - value: sat - - label: Sunday - value: sun - sort: false - custom_value: false - 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 - multiple: false - sort: false - custom_value: false - zone: - name: Device Tracker - Zone - description: Choose the zone that will track your devices and/or people in it. - default: [] - selector: - entity: - filter: - - domain: - - zone - multiple: false - people: - name: Device Tracker - People - description: Select the people you would like to track in the zone selected - above. You must enter a zone above for this option to work. - default: [] - selector: - entity: - multiple: true - filter: - - domain: - - person - 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 - multiple: false - sort: false - custom_value: false - night_lights: + ' + default: -1.5 + selector: + number: + min: -10.0 + max: 5.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + night_lights_sun_elevation_rising: + name: Night Lights - Sun Elevation Rising + description: 'The sun elevation rising refers to the angle between the sun + and the horizon during sunrise. A negative value indicates that the sun + is BELOW the horizon. For example, a setting guide of -4.0 corresponds + to dawn. + + ' + default: -4.0 + selector: + number: + min: -10.0 + max: 5.0 + step: 0.5 + unit_of_measurement: degrees + mode: slider + night_lights_settings: name: Night Lights - 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. + icon: mdi:lightbulb-night-outline + collapsed: true + input: + night_lights: + name: Night Lights + description: 'The lights, switches, scenes, and scripts that will be activated + by the trigger sensor/s. If adding a scene or script, please refer to + the ''Night Lights - Scenes & Scripts - Toggle Helper'' section below + and the ''Scenes - Scripts To Turn OFF'' input in the lights section above. - For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595) + 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 - multiple: false - night_time_delay: - name: Night Lights - Time Delay - description: The time delay determines how long the night lights will remain - active after all triggers are clear, initiating the time delay to turn them - OFF. - default: 5 - selector: - number: - min: 0.0 - max: 30.0 - step: 0.5 - unit_of_measurement: minutes - mode: slider - 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. + **NOTE** - You can only use entities. Areas, devices and labels are not + supported. + + ' + default: {} + selector: + target: + entity: + - domain: + - light + - switch + - scene + - script + night_boolean_scenes_scripts: + name: Night Lights - Scenes & Scripts - Toggle Helper + description: 'To ensure the smooth operation of the automation, it''s recommended + to create an independent toggle helper when selecting a scene or script + in "Night Lights" above and then enter it here. + + ' + default: [] + selector: + entity: + filter: + - domain: + - input_boolean + multiple: false + night_time_delay: + name: Night Lights - Time Delay + description: 'The time delay determines how long the night lights will remain + active after all triggers are clear, initiating the time delay to turn + them OFF. + + ' + default: 5 + selector: + number: + min: 0.0 + max: 30.0 + step: 0.5 + unit_of_measurement: minutes + mode: slider + night_lights_light_control_settings: + name: Night Light Control + icon: mdi:lightbulb-on-80 + collapsed: true + input: + include_night_light_control: + name: Night Lights - Light Control Options (Optional) + description: "Select if you would like to use brightness or transition. + These settings will only affect a 'light' entity that supports each selected + option. The settings for brightness and transition are provided below. + \n\nSelecting 'If lights are ON, adjust the lights when crossing over' + option ensures that the light control settings will be applied to any + lights that are already ON during the transition from normal lights to + night lights and vice versa.\n\nSelecting 'Yes - Manage OFF script when + crossing over' is beneficial for scripts containing if-then-else actions + that toggle various functions on and off during the transition from normal + lights to night lights and vice versa.\n" + default: [] + selector: + select: + multiple: true + options: + - label: Use brightness + value: use_brightness + - label: Use transition + value: use_transition + - label: If lights are ON, adjust the lights when crossing over + value: if_lights_are_on_adjust_when_crossing_over + - label: Yes - Manage OFF script when crossing over + value: manage_scripts_crossing_over + custom_value: false + sort: false + night_light_brightness: + name: Night Lights - Brightness + description: 'The brightness setting of the lights when they are turned + ON. + + ' + default: 20 + selector: + number: + min: 1.0 + max: 100.0 + mode: slider + step: 1.0 + unit_of_measurement: '%' + night_light_transition_on: + name: Night Lights - Transition - ON + description: 'The transition of the lights when they are turned ON. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 5.0 + mode: slider + step: 0.5 + unit_of_measurement: seconds + night_light_transition_off: + name: Night Lights - Transition - OFF + description: 'The transition of the lights when they are turned OFF. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 30.0 + mode: slider + step: 1.0 + unit_of_measurement: seconds + include_night_light_colour_control: + name: Night Lights - Light Colour Control Options (Optional) + description: 'Select if you would like to use colour temperature, RGB, RGBW + or RGBWW colour. These settings will only affect a ''light'' entity that + supports each selected option. The settings for colour temperature, RGB, + RGBW and RGBWW colour are provided below + + ' + default: disable_colour_control + selector: + select: + options: + - label: Use Colour Temperature + value: use_colour_temperature + - label: Use RGB Colour + value: use_rgb_colour + - label: Use RGBW Colour + value: use_rgbw_colour + - label: Use RGBWW Colour + value: use_rgbww_colour + - label: Disable Colour Control + value: disable_colour_control + custom_value: false + sort: false + multiple: false + night_light_colour_temperature: + name: Night Lights - Colour Temperature + description: 'The colour temperature setting for the lights when they are + turned ON. + + ' + default: 5000 + selector: + number: + min: 2000.0 + max: 8000.0 + mode: slider + step: 100.0 + unit_of_measurement: kelvin + night_light_rgb_colour: + name: Night Lights - RGB Colour + description: 'The RGB colour setting for the lights when they are turned + ON. + + ' + default: + - 255 + - 255 + - 255 + selector: + color_rgb: {} + night_light_rgbw_colour: + name: Night Lights - RGBW Colour + description: 'The RGBW colour setting for the lights when they are turned + ON. Enter four integers between 0 and 255 to define the values for Red, + Green, Blue, and White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + selector: + object: {} + night_light_rgbww_colour: + name: Night Lights - RGBWW Colour + description: 'The RGBWW colour setting for the lights when they are turned + ON. Enter five integers between 0 and 255 to define the values for Red, + Green, Blue, Cold White and Warm White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + - 255 + selector: + object: {} + night_lights_night_glow: + name: Night Glow + icon: mdi:candle + collapsed: true + input: + include_night_glow: + name: Night Glow (Optional) + description: 'This feature activates a low-level light when no trigger is + detected, creating a subtle ambient glow perfect for nighttime use. When + a trigger, such as a motion sensor, is detected, the light gradually increases + to the night light''s brightness level, providing enhanced visibility + and functionality without abrupt changes in lighting. You can also customize + the light''s colour temperature or RGB colour for added personalization. + + ' + default: night_glow_disabled + selector: + select: + options: + - label: Enable night glow + value: night_glow_enabled + - label: Disable night glow + value: night_glow_disabled + custom_value: false + sort: false + multiple: false + night_glow_lights: + name: Night Glow - Lights + description: 'The lights, switches, scenes, and scripts to be used for a + night glow. If adding a scene or script, please refer to the ''Scenes + - Scripts To Turn OFF'' input in the lights section above. - 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. + For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595) - 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 - sort: false - custom_value: false - 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.0 - max: 100.0 - mode: slider - step: 1.0 - 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.0 - max: 8000.0 - mode: slider - step: 100.0 - 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.0 - max: 5.0 - mode: slider - step: 0.5 - unit_of_measurement: seconds - night_light_transition_off: - name: Night Lights - Transition - OFF - description: The transition of the night lights when they are turned OFF. - default: 1 - selector: - number: - min: 0.0 - max: 30.0 - mode: slider - step: 1.0 - unit_of_measurement: seconds - 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 - sort: false - custom_value: false - night_lights_entity_state: - name: Night Lights - Entity State - description: 'Select an entity that will trigger the activation of night lights - when turned ON. This could be your phone on ''Do Not Disturb'', a helper, - a bed sensor, etc. Please note that the selected entity cannot be included - in the ''Lights - Switches - Scenes - Scripts'' or ''Night Lights'' selections. + **NOTE** - You can only use entities. Areas, devices and labels are not + supported. + ' + default: {} + selector: + target: + entity: + - domain: + - light + - switch + - scene + - script + include_night_glow_light_control: + name: Night Glow - Light Control Options (Optional) + description: "Select if you would like to use brightness or transition. + These settings will only affect a 'light' entity that supports each selected + option. The settings for brightness and transition are provided below. + \n" + default: [] + selector: + select: + multiple: true + options: + - label: Use brightness + value: use_brightness + - label: Use transition + value: use_transition + custom_value: false + sort: false + night_glow_light_brightness: + name: Night Glow - Brightness + description: 'The brightness setting of the lights when they are turned + ON. - For more information on entity state [Click Here](https://community.home-assistant.io/t/481048/663)' - default: [] - selector: - entity: - multiple: true - night_lights_after_time: - name: Night Lights - Start Time - description: Set the start time. - default: 00:00:00 - selector: - time: {} - night_lights_before_time: - name: Night Lights - End Time - description: Set the end time. - default: 00:00:00 - selector: - time: {} - night_lights_sun_elevation: - name: Night Lights - Sun Elevation Falling - description: The sun elevation falling refers to the angle between the sun and - the horizon when the sun is setting. A negative value indicates that the sun - is BELOW the horizon. For example, a setting guide of -1.5 corresponds to - dusk. - default: -1.5 - selector: - number: - min: -10.0 - max: 5.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider - night_lights_sun_elevation_rising: - name: Night Lights - Sun Elevation Rising - description: The sun elevation rising refers to the angle between the sun and - the horizon during sunrise. A negative value indicates that the sun is BELOW - the horizon. For example, a setting guide of -4.0 corresponds to dawn. - default: -4.0 - selector: - number: - min: -10.0 - max: 5.0 - step: 0.5 - unit_of_measurement: degrees - mode: slider + ' + default: 20 + selector: + number: + min: 1.0 + max: 100.0 + mode: slider + step: 1.0 + unit_of_measurement: '%' + night_glow_light_transition_on: + name: Night Glow - Transition - ON + description: 'The transition of the lights when they are turned ON. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 5.0 + mode: slider + step: 0.5 + unit_of_measurement: seconds + night_glow_light_transition_off: + name: Night Glow - Transition - OFF + description: 'The transition of the lights when they are turned OFF. + + ' + default: 1 + selector: + number: + min: 0.0 + max: 30.0 + mode: slider + step: 1.0 + unit_of_measurement: seconds + include_night_glow_light_colour_control: + name: Night Glow - Light Colour Control Options (Optional) + description: 'Select if you would like to use colour temperature, RGB, RGBW + or RGBWW colour. These settings will only affect a ''light'' entity that + supports each selected option. The settings for colour temperature, RGB, + RGBW and RGBWW colour are provided below + + ' + default: disable_colour_control + selector: + select: + options: + - label: Use Colour Temperature + value: use_colour_temperature + - label: Use RGB Colour + value: use_rgb_colour + - label: Use RGBW Colour + value: use_rgbw_colour + - label: Use RGBWW Colour + value: use_rgbww_colour + - label: Disable Colour Control + value: disable_colour_control + custom_value: false + sort: false + multiple: false + night_glow_light_colour_temperature: + name: Night Glow - Colour Temperature + description: 'The colour temperature setting for the lights when they are + turned ON. + + ' + default: 5000 + selector: + number: + min: 2000.0 + max: 8000.0 + mode: slider + step: 100.0 + unit_of_measurement: kelvin + night_glow_light_rgb_colour: + name: Night Glow - RGB Colour + description: 'The RGB colour setting for the lights when they are turned + ON. + + ' + default: + - 255 + - 255 + - 255 + selector: + color_rgb: {} + night_glow_light_rgbw_colour: + name: Night Glow - RGBW Colour + description: 'The RGBW colour setting for the lights when they are turned + ON. Enter four integers between 0 and 255 to define the values for Red, + Green, Blue, and White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + selector: + object: {} + night_glow_light_rgbww_colour: + name: Night Glow - RGBWW Colour + description: 'The RGBWW colour setting for the lights when they are turned + ON. Enter five integers between 0 and 255 to define the values for Red, + Green, Blue, Cold White and Warm White. + + ' + default: + - 255 + - 255 + - 255 + - 255 + - 255 + selector: + object: {} source_url: https://gist.github.com/Blackshome/6edfec0ff6a25c5da0d07b88dc908238 mode: restart max_exceeded: silent @@ -994,32 +1634,36 @@ variables: 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_light_colour_control: !input include_light_colour_control + light_colour_temperature: !input light_colour_temperature + light_rgb_colour: !input light_rgb_colour + light_rgbw_colour: !input light_rgbw_colour + light_rgbww_colour: !input light_rgbww_colour include_dynamic_lighting: !input include_dynamic_lighting dynamic_lighting_lux_sensor: !input dynamic_lighting_lux_sensor dynamic_lighting_max_lux: !input dynamic_lighting_max_lux dynamic_lighting_min_lux: !input dynamic_lighting_min_lux dynamic_lighting_max_brightness: !input dynamic_lighting_max_brightness dynamic_lighting_min_brightness: !input dynamic_lighting_min_brightness + dynamic_lighting_boolean: !input dynamic_lighting_boolean dynamic_lighting_max_colour_temp: !input dynamic_lighting_max_colour_temp dynamic_lighting_min_colour_temp: !input dynamic_lighting_min_colour_temp dynamic_lighting_sun_elevation_start_rising: !input dynamic_lighting_sun_elevation_start_rising dynamic_lighting_sun_elevation_end_rising: !input dynamic_lighting_sun_elevation_end_rising dynamic_lighting_sun_elevation_start_falling: !input dynamic_lighting_sun_elevation_start_falling dynamic_lighting_sun_elevation_end_falling: !input dynamic_lighting_sun_elevation_end_falling + dynamic_lighting_time_start_morning: !input dynamic_lighting_time_start_morning + dynamic_lighting_time_end_morning: !input dynamic_lighting_time_end_morning + dynamic_lighting_time_start_evening: !input dynamic_lighting_time_start_evening + dynamic_lighting_time_end_evening: !input dynamic_lighting_time_end_evening dynamic_lighting_heartbeat: !input dynamic_lighting_heartbeat dynamic_lighting_step_value: !input dynamic_lighting_step_value dynamic_lighting_dead_zone: !input dynamic_lighting_dead_zone + dynamic_lighting_state_control: !input dynamic_lighting_state_control + dynamic_lighting_state_control_activation_state: !input dynamic_lighting_state_control_activation_state + dynamic_lighting_state_control_entity: !input dynamic_lighting_state_control_entity include_bypass: !input include_bypass motion_bypass_lights_on: !input motion_bypass_lights_on motion_bypass_lights_off: !input motion_bypass_lights_off @@ -1043,38 +1687,58 @@ variables: 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 - 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 }}' - 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 }}' + night_lights: !input night_lights + night_boolean_scenes_scripts: !input night_boolean_scenes_scripts + night_time_delay: !input night_time_delay + include_night_light_control: !input include_night_light_control + night_light_brightness: !input night_light_brightness + night_light_transition_on: !input night_light_transition_on + night_light_transition_off: !input night_light_transition_off + include_night_light_colour_control: !input include_night_light_colour_control + night_light_colour_temperature: !input night_light_colour_temperature + night_light_rgb_colour: !input night_light_rgb_colour + night_light_rgbw_colour: !input night_light_rgbw_colour + night_light_rgbww_colour: !input night_light_rgbww_colour + include_night_glow: !input include_night_glow + night_glow_lights: !input night_glow_lights + include_night_glow_light_control: !input include_night_glow_light_control + night_glow_light_brightness: !input night_glow_light_brightness + night_glow_light_transition_on: !input night_glow_light_transition_on + night_glow_light_transition_off: !input night_glow_light_transition_off + include_night_glow_light_colour_control: !input include_night_glow_light_colour_control + night_glow_light_colour_temperature: !input night_glow_light_colour_temperature + night_glow_light_rgb_colour: !input night_glow_light_rgb_colour + night_glow_light_rgbw_colour: !input night_glow_light_rgbw_colour + night_glow_light_rgbww_colour: !input night_glow_light_rgbww_colour + light_entities_off: "{{ expand(light_switch.entity_id)\n | selectattr('domain', + 'eq', 'light')\n | selectattr('state', 'eq', 'off')\n | map(attribute='entity_id')\n + \ | list }}\n" + switch_entities_off: "{{ expand(light_switch.entity_id)\n | selectattr('domain', + 'eq', 'switch')\n | selectattr('state', 'eq', 'off')\n | map(attribute='entity_id')| + list }}\n" + light_data: "{% set light = namespace(data={}) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if 'use_brightness' in include_light_control %}\n {% set + light.data = dict(light.data, **{ 'brightness_pct': light_brightness }) %}\n{% + endif %} {% if include_light_colour_control == 'use_colour_temperature' %}\n {% + set light.data = dict(light.data, **{ 'color_temp_kelvin': light_colour_temperature + }) %}\n{% endif %} {% if include_light_colour_control == 'use_rgb_colour' %}\n + \ {% set light.data = dict(light.data, **{ 'rgb_color': light_rgb_colour }) %}\n{% + endif %} {% if include_light_colour_control == 'use_rgbw_colour' %}\n {% set + light.data = dict(light.data, **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif + %} {% if include_light_colour_control == 'use_rgbww_colour' %}\n {% set light.data + = dict(light.data, **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ + light.data }}" + light_entities: "{{ expand(light_switch.entity_id)\n | selectattr('domain', 'eq', + 'light')\n | map(attribute='entity_id')\n | list }}\n" + switch_entities: "{{ expand(light_switch.entity_id)\n | selectattr('domain', 'eq', + 'switch')\n | map(attribute='entity_id')\n | list }}\n" scene_entities: "{% set a = light_switch.entity_id %} {% if boolean_scenes_scripts == [] %}\n {{ expand(a) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}\n{% elif is_state(boolean_scenes_scripts, 'off') %}\n {{ expand(a) @@ -1090,18 +1754,31 @@ variables: end_scene_entities: '{{ end_scenes | select(''match'', ''^scene\..*'') | list }}' end_script_entities: '{{ end_scenes | select(''match'', ''^script\..*'') | list }}' - night_light_entities_off: "{% set b = night_lights and night_lights.entity_id %} + night_light_entities_off: "{% set b = night_lights and night_lights.entity_id %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - night_switch_entities_off: "{% set b = night_lights and night_lights.entity_id - %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | selectattr('state', + night_switch_entities_off: "{% set b = night_lights and night_lights.entity_id %} + {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - night_light_entities: "{% set b = night_lights and night_lights.entity_id %} {% + night_light_data: "{% set light = namespace(data={}) %} {% if 'use_transition' in + include_night_light_control %}\n {% set light.data = dict(light.data, **{ 'transition': + night_light_transition_on }) %}\n{% endif %} {% if 'use_brightness' in include_night_light_control + %}\n {% set light.data = dict(light.data, **{ 'brightness_pct': night_light_brightness + }) %}\n{% endif %} {% if include_night_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': night_light_colour_temperature + }) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgb_colour' + %}\n {% set light.data = dict(light.data, **{ 'rgb_color': night_light_rgb_colour + }) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgbw_colour' + %}\n {% set light.data = dict(light.data, **{ 'rgbw_color': night_light_rgbw_colour + }) %}\n{% endif %} {% if include_night_light_colour_control == 'use_rgbww_colour' + %}\n {% set light.data = dict(light.data, **{ 'rgbww_color': night_light_rgbww_colour + }) %}\n{% endif %} {{ light.data }}" + night_light_entities: "{% set b = night_lights and night_lights.entity_id %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - night_switch_entities: "{% set b = night_lights and night_lights.entity_id %} {% + night_switch_entities: "{% set b = night_lights and night_lights.entity_id %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" night_scene_entities: "{% set b = night_lights and night_lights.entity_id %} {% @@ -1117,156 +1794,216 @@ variables: night_boolean_scenes_scripts_helper: "{% if night_boolean_scenes_scripts | length > 0 and states(night_boolean_scenes_scripts) == 'off' %}\n {{ night_boolean_scenes_scripts }}\n{% else %}\n []\n{% endif %}" - crossover_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights - and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in', - expand(b)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') + night_glow_light_data: "{% set light = namespace(data={}) %} {% if 'use_transition' + in include_night_glow_light_control %}\n {% set light.data = dict(light.data, + **{ 'transition': night_glow_light_transition_on }) %}\n{% endif %} {% if 'use_brightness' + in include_night_glow_light_control %}\n {% set light.data = dict(light.data, + **{ 'brightness_pct': night_glow_light_brightness }) %}\n{% endif %} {% if include_night_glow_light_colour_control + == 'use_colour_temperature' %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + night_glow_light_colour_temperature }) %}\n{% endif %} {% if include_night_glow_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, **{ 'rgb_color': + night_glow_light_rgb_colour }) %}\n{% endif %} {% if include_night_glow_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, **{ 'rgbw_color': + night_glow_light_rgbw_colour }) %}\n{% endif %} {% if include_night_glow_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, **{ 'rgbww_color': + night_glow_light_rgbww_colour }) %}\n{% endif %} {{ light.data }}" + night_glow_light_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id + %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - crossover_lights_switch: "{% set a = light_switch.entity_id %} {% set b = night_lights - and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in', - expand(b)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') + night_glow_switch_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id + %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - crossover_night_lights_light_on: "{% set b = night_lights and night_lights.entity_id + night_glow_scene_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id + %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + night_glow_script_entities: "{% set b = night_glow_lights and night_glow_lights.entity_id + %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + crossover_night_glow_to_night_lights_light: "{% set a = night_lights and night_lights.entity_id + %} {% set b = night_glow_lights and night_glow_lights.entity_id %} {% if a and + b %}\n {{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'light') + | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" + crossover_night_glow_to_night_lights_switch: "{% set a = night_lights and night_lights.entity_id + %} {% set b = night_glow_lights and night_glow_lights.entity_id %} {% if a and + b %}\n {{ expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') + | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" + crossover_night_lights_to_night_glow_light: "{% set a = night_glow_lights and night_glow_lights.entity_id + %} {% set b = night_lights and night_lights.entity_id %} {% if a and b %}\n {{ + expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + crossover_night_lights_to_night_glow_switch: "{% set a = night_glow_lights and night_glow_lights.entity_id + %} {% set b = night_lights and night_lights.entity_id %} {% if a and b %}\n {{ + expand(b) | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + crossover_lights_to_night_glow_light: "{% set a = night_glow_lights and night_glow_lights.entity_id + %} {% set b = light_switch.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in', + expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + crossover_lights_to_night_glow_switch: "{% set a = night_glow_lights and night_glow_lights.entity_id + %} {% set b = light_switch.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in', + expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') + | list }}\n{% else %}\n []\n{% endif %}" + crossover_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights + and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in', + expand(b)) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') + | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" + crossover_lights_switch: "{% set a = light_switch.entity_id %} {% set b = night_lights + and night_lights.entity_id %} {% if a and b %}\n {{ expand(a) | reject('in', + expand(b)) | selectattr('domain', 'eq', 'switch') | selectattr('state', 'eq', + 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" + crossover_night_lights_light_on: "{% set b = night_lights and night_lights.entity_id %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" - crossover_night_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights + crossover_night_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in', - expand(a)) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') - | list }}\n{% else %}\n []\n{% endif %}" + expand(a)) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') + | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" crossover_night_lights_switch: "{% set a = light_switch.entity_id %} {% set b = - \ night_lights and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) - | reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id') - | list }}\n{% else %}\n []\n{% endif %}" + night_lights and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) | + reject('in', expand(a)) | selectattr('domain', 'eq', 'switch') | selectattr('state', + 'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif + %}" crossover_lights_light_on: "{% set a = light_switch.entity_id %} {% if a %}\n {{ expand(a) | selectattr('domain', 'eq', 'light') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif %}" -trigger: -- platform: state + dynamic_lighting_state_control_activation_state_inv: "{% if dynamic_lighting_state_control_activation_state + == 'on' %}\n off\n{% else %}\n on\n{% endif %}\n" +triggers: +- trigger: state id: t0 entity_id: !input motion_trigger from: 'off' to: 'on' -- platform: numeric_state +- trigger: numeric_state id: t1 entity_id: sun.sun attribute: elevation below: !input sun_elevation -- platform: numeric_state +- trigger: numeric_state id: t2 entity_id: !input ambient_light_sensor below: !input ambient_light_value -- platform: time +- trigger: time id: t3 at: !input after_time -- platform: state +- trigger: state id: t4 entity_id: !input night_lights_entity_state from: 'off' to: 'on' -- platform: time +- trigger: time id: t5 at: !input night_lights_after_time -- platform: numeric_state +- trigger: numeric_state id: t6 entity_id: sun.sun attribute: elevation below: !input night_lights_sun_elevation -- platform: state +- trigger: state id: t7_on entity_id: !input motion_bypass_lights_on from: 'off' to: 'on' -- platform: state +- trigger: state id: t7_off entity_id: !input motion_bypass_lights_off from: 'off' to: 'on' -- platform: state +- trigger: state id: t7_stop entity_id: !input motion_bypass_lights_stop from: 'off' to: 'on' -- platform: state +- trigger: state id: t8_on entity_id: !input motion_bypass_lights_on from: 'on' to: 'off' -- platform: state +- trigger: state id: t8_off entity_id: !input motion_bypass_lights_off from: 'on' to: 'off' -- platform: state +- trigger: state id: t8_stop entity_id: !input motion_bypass_lights_stop from: 'on' to: 'off' -- platform: numeric_state +- trigger: numeric_state id: t9 entity_id: sun.sun attribute: elevation above: !input sun_elevation_rising -- platform: numeric_state +- trigger: numeric_state id: t10 entity_id: !input ambient_light_sensor above: !input ambient_light_high_value -- platform: time +- trigger: time id: t11 at: !input before_time -- platform: state +- trigger: state id: t12 entity_id: !input night_lights_entity_state from: 'on' to: 'off' -- platform: time +- trigger: time id: t13 at: !input night_lights_before_time -- platform: numeric_state +- trigger: numeric_state id: t14 entity_id: sun.sun attribute: elevation above: !input night_lights_sun_elevation_rising -- platform: homeassistant +- trigger: state id: t15 + entity_id: !input dynamic_lighting_state_control_entity + to: !input dynamic_lighting_state_control_activation_state +- trigger: state + id: t16 + entity_id: !input dynamic_lighting_state_control_entity + from: !input dynamic_lighting_state_control_activation_state +- trigger: homeassistant + id: t17 event: start condition: - condition: or conditions: - condition: and conditions: + - condition: trigger + id: t0 - condition: state entity_id: !input motion_trigger match: any state: 'on' - - condition: trigger - id: t0 - condition: and conditions: + - condition: trigger + id: t1 - condition: state entity_id: !input motion_trigger state: 'on' match: any - '{{ include_sun == ''sun_enabled'' }}' - - condition: trigger - id: t1 - condition: and conditions: + - condition: trigger + id: t2 - condition: state entity_id: !input motion_trigger state: 'on' match: any - '{{ include_ambient == ''ambient_enabled'' }}' - - condition: trigger - id: t2 - condition: and conditions: + - condition: trigger + id: t3 - condition: state entity_id: !input motion_trigger state: 'on' match: any - '{{ include_time == ''time_enabled'' }}' - - condition: trigger - id: t3 - condition: and conditions: - condition: trigger @@ -1283,6 +2020,7 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ include_night_glow == ''night_glow_enabled'' }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1292,6 +2030,9 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1304,6 +2045,7 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ include_night_glow == ''night_glow_enabled'' }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1313,6 +2055,9 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1325,6 +2070,7 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ include_night_glow == ''night_glow_enabled'' }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1334,6 +2080,9 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1375,12 +2124,18 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, 'on') }}\n{% endif %}" - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1393,12 +2148,18 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, 'on') }}\n{% endif %}" - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1410,12 +2171,18 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, 'on') }}\n{% endif %}" - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1431,6 +2198,9 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1440,6 +2210,9 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1452,6 +2225,9 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1461,6 +2237,9 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger @@ -1473,6 +2252,9 @@ condition: | list | count > 0) }}' - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (include_night_glow + == ''night_glow_enabled'') and (expand(night_glow_lights.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) }}' - condition: template value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -1482,10 +2264,30 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: - condition: trigger - id: t15 + id: + - t15 + - t16 + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - '{{ dynamic_lighting_state_control == ''enable_state_control'' }}' + - condition: or + conditions: + - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'') + | list | count > 0) }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + - condition: and + conditions: + - condition: trigger + id: t17 - condition: or conditions: - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'') @@ -1498,21 +2300,24 @@ condition: - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" - condition: and conditions: + - condition: trigger + id: t17 - condition: state entity_id: !input motion_trigger match: any state: 'on' - - condition: trigger - id: t15 - condition: and conditions: + - condition: trigger + id: t17 - '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}' - - condition: trigger - id: t15 - condition: or conditions: - condition: state @@ -1602,7 +2407,7 @@ condition: - t8_on - t8_off - t8_stop - - t15 + - t17 - condition: or conditions: - '{{ include_sun == ''sun_disabled'' }}' @@ -1626,13 +2431,13 @@ condition: 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'') + - '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor) + | int) < (ambient_light_value | int)) }}' + - '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor) + | int) < (ambient_light_high_value | int)) and (expand(light_switch.entity_id) + | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor) + | int) < (ambient_light_high_value | int)) and ((include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') | list | count > 0)) }}' - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options == ''ambient_light_option_enabled'') @@ -1643,15 +2448,15 @@ condition: | 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) }}' + - '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor) + | int) < (ambient_light_high_value | int)) }}' - condition: template value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, 'on') }}\n{% endif %}" - condition: and conditions: - - '{{ (include_ambient == ''ambient_enabled'') and (states[ambient_light_sensor].state - | int < ambient_light_high_value | int) }}' + - '{{ (include_ambient == ''ambient_enabled'') and ((states(ambient_light_sensor) + | int) < (ambient_light_high_value | int)) }}' - condition: template value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" @@ -1702,15 +2507,15 @@ condition: - '{{ include_device_tracker == ''device_tracker_disabled'' }}' - condition: and conditions: + - '{{ include_device_tracker == ''zone_enabled'' }}' - 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'' }}' + - '{{ (state_attr(zone, ''persons'') | list | select(''in'', people) | list | + length) > 0 }}' - condition: trigger id: - t7_on @@ -1721,14 +2526,13 @@ condition: - t8_stop action: - choose: - - alias: Check if the night lights are enabled and within the night lights conditions + - alias: Check if night lights are enabled and within conditions conditions: - condition: and conditions: - alias: Check if night lights is enabled - condition: or - conditions: - - '{{ ''night_lights_enabled'' in include_night_lights }}' + condition: template + value_template: '{{ include_night_lights == ''night_lights_enabled'' }}' - alias: Check if night lights entity state is enabled condition: or conditions: @@ -1769,7 +2573,21 @@ action: <= night_lights_sun_elevation_rising | float(90)))) }}' sequence: - choose: - - alias: By-pass is turned on & check by-pass option - turn lights off + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean + - choose: + - alias: By-pass is turned on & check by-pass option - Turn lights off conditions: - condition: trigger id: t7_off @@ -1785,16 +2603,35 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' data: - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + data: + transition: '{{ night_light_transition_off }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + data: + transition: '{{ night_glow_light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -1802,27 +2639,56 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ night_switch_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_lights_switch }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + sequence: + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - alias: Turn off the boolean for scenes and scripts - service: input_boolean.turn_off + action: 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 + action: input_boolean.turn_off data: entity_id: !input night_boolean_scenes_scripts - alias: Check by-pass settings and preform the correct action @@ -1847,7 +2713,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -1858,7 +2724,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -1869,12 +2735,12 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation else: - stop: Stop the automation - - alias: By-pass is turned on & check by-pass option - Keep the current lights + - alias: By-pass is turned on & check by-pass option - Keep the current lights state conditions: - condition: trigger @@ -1902,7 +2768,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -1913,7 +2779,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -1924,13 +2790,13 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation else: - stop: Stop the automation - choose: - - alias: By-pass is turned off & check if the motion trigger is off + - alias: By-pass is turned off & check if the motion trigger is off conditions: - condition: trigger id: @@ -2023,54 +2889,181 @@ action: delay: minutes: !input bypass_time_delay - choose: - - alias: If transition is selected + - alias: If night glow is disabled conditions: - condition: template - value_template: '{{ ''use_transition'' in include_night_light_control + value_template: '{{ include_night_glow == ''night_glow_disabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_light_entities }}' + data: + transition: '{{ night_light_transition_off }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + data: + transition: '{{ night_light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ night_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_light_entities }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off target: - entity_id: '{{ night_light_entities }}' + entity_id: '{{ night_switch_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_lights_switch }}' + - alias: Turn off the script + action: script.turn_on data: - transition: '{{ night_transition_off_value }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off data: - entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' - - alias: If transition is not selected + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - stop: Stop the automation + - alias: If night glow is enabled conditions: - condition: template - value_template: '{{ ''use_transition'' not in include_night_light_control + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - alias: Turn on the lights + action: light.turn_on target: - entity_id: '{{ night_light_entities }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ night_glow_light_entities }}' + data: '{{ night_glow_light_data }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn OFF crossover night lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_light + }}' + data: + transition: '{{ night_light_transition_off }}' + - alias: Turn OFF crossover lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_to_night_glow_light }}' + data: + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn OFF crossover night lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_light + }}' + - alias: Turn OFF crossover lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_to_night_glow_light }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_glow_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ night_light_transition_on }}' + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + transition: '{{ night_glow_light_transition_on }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + - alias: Turn on the switches + action: switch.turn_on + target: + entity_id: '{{ night_glow_switch_entities }}' + - alias: Turn OFF crossover night switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_switch }}' + - alias: Turn OFF crossover light switches + action: switch.turn_off + target: + entity_id: '{{ crossover_lights_to_night_glow_switch }}' + - alias: Turn on the script + action: script.turn_on data: - entity_id: '{{ end_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 + entity_id: '{{ end_script_entities }}' + - alias: Turn on the script + action: script.turn_on + data: + entity_id: '{{ night_glow_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - stop: Stop the automation - alias: Motion trigger is off and check if any by-passes are on conditions: - condition: or @@ -2191,7 +3184,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -2202,7 +3195,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -2213,10 +3206,10 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation - - alias: By-pass is turned off & check if the motion trigger is on + - alias: By-pass is turned off & check if the motion trigger is on conditions: - condition: trigger id: @@ -2229,7 +3222,7 @@ action: state: 'on' sequence: - choose: - - alias: 'Check all by-pass are off and check conditions if enabled ' + - alias: Check all by-pass are off and check conditions if enabled conditions: - condition: or conditions: @@ -2309,22 +3302,22 @@ action: - '{{ (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) }}' + == ''ambient_light_option_disabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) }}' - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options - == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state - | int > ambient_light_value | int) and (expand(night_lights.entity_id) + == ''ambient_light_option_enabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''off'') | list | count > 0) }}' - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options - == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state - | int > ambient_light_value | int) and (is_state(night_boolean_scenes_scripts, + == ''ambient_light_option_enabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) and (is_state(night_boolean_scenes_scripts, ''off'')) }}' - condition: and conditions: + - '{{ include_time == ''time_enabled'' }}' - condition: time after: !input before_time before: !input after_time - - '{{ include_time == ''time_enabled'' }}' sequence: - alias: Wait the number of minutes set in the by-pass time delay delay: @@ -2337,16 +3330,16 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' data: - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -2354,21 +3347,25 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ night_switch_entities }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts - stop: Stop the automation - alias: Motion trigger is on and check if any by-passes are on conditions: @@ -2490,7 +3487,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -2501,7 +3498,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -2512,11 +3509,89 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation + - alias: By-pass is turned off & reset lights to the site conditions + conditions: + - condition: trigger + id: + - t8_on + - t8_off + - t8_stop + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + data: + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_lights_light }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_lights_switch }}' + - choose: + - alias: Check if normal lights Scenes & Scripts - Toggle Helper is + on + conditions: + - condition: template + value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, + 'on') }}\n{% endif %}" + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control + }}' + sequence: + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the script + action: script.turn_on + data: + entity_id: '{{ end_script_entities }}' + - alias: Turn off the input boolean normal lights + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - alias: Turn ON lights + action: light.turn_on + target: + entity_id: '{{ crossover_night_lights_light_on }}' + data: '{{ night_light_data }}' - choose: - - alias: Sun, Ambient Light Sensor & time above setting to turn off + - alias: Sun, ambient & time above setting to turn off conditions: - condition: trigger id: @@ -2532,16 +3607,29 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' data: - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + data: + transition: '{{ night_glow_light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -2549,23 +3637,44 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ night_light_entities }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ night_switch_entities }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + sequence: + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - alias: Turn off the input boolean night lights - service: input_boolean.turn_off + action: input_boolean.turn_off data: entity_id: !input night_boolean_scenes_scripts - stop: Stop the automation @@ -2580,10 +3689,15 @@ action: - 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'')) }}' + - condition: or + conditions: + - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', + ''on'') | list | count > 0) }}' + - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id) + | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}' + - condition: template + value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts, + 'on') }}\n{% endif %}" sequence: - choose: - alias: If transition is selected @@ -2593,11 +3707,11 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ crossover_lights_light }}' data: - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -2605,20 +3719,20 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ crossover_lights_light }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ crossover_lights_switch }}' - alias: Turn off the script - service: script.turn_on + action: 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 + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control conditions: - condition: template value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' @@ -2632,10 +3746,10 @@ action: }}' sequence: - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -2643,102 +3757,67 @@ action: }}' sequence: - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the input boolean normal lights - service: input_boolean.turn_off + action: 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 + - alias: Turn ON lights + action: light.turn_on + target: + entity_id: '{{ crossover_night_lights_light_on }}' + data: '{{ night_light_data }}' + - alias: Turn on night glow lights if all lights are off + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + - condition: template + value_template: '{{ (expand(light_switch.entity_id) | selectattr(''state'', + ''=='', ''off'') | list | count > 0) or (expand(night_lights.entity_id) + | selectattr(''state'', ''=='', ''off'') | list | count > 0) or (is_state(boolean_scenes_scripts, + ''off'')) }} + + ' + sequence: + - alias: Turn on the lights + action: light.turn_on + target: + entity_id: '{{ night_glow_light_entities }}' + data: '{{ night_glow_light_data }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_glow_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + transition: '{{ night_glow_light_transition_on }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_glow_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + - alias: Turn on the switches + action: switch.turn_on + target: + entity_id: '{{ night_glow_switch_entities }}' + - alias: Turn on the script + action: script.turn_on + data: + entity_id: '{{ night_glow_script_entities }}' + - stop: Stop the automation + - alias: If manage scripts is enabled conditions: - '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' @@ -2748,17 +3827,17 @@ action: ''off'')) }}' sequence: - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - stop: Stop the automation - alias: Safe Guard when HA restarts conditions: - condition: trigger - id: t15 + id: t17 sequence: - choose: - - alias: 'Check all by-pass are off and check conditions if enabled ' + - alias: Check all by-pass are off and check conditions if enabled conditions: - condition: or conditions: @@ -2933,7 +4012,7 @@ action: match: any state: 'on' sequence: - - alias: Check by-pass auto off is enabled and preform the correct + - alias: Check by-pass auto off is enabled and preform the correct action if: - alias: Check if the by-pass auto off is enabled condition: template @@ -2957,7 +4036,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -2968,7 +4047,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -2979,158 +4058,187 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation - choose: - - alias: Set the transition for the night lights switch + - alias: If night glow is disabled 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) }}' + value_template: '{{ include_night_glow == ''night_glow_disabled'' }}' sequence: - - service: light.turn_on + - alias: Turn ON lights + action: 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 + data: '{{ night_light_data }}' + - choose: + - alias: Check if normal lights scenes or scripts helper is on - This is + for scenes only when crossing over + conditions: + - condition: template + value_template: "{% if boolean_scenes_scripts == [] %}\n false\n{% + elif is_state(boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n + \ false\n{% endif %}" + sequence: + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: '{{ boolean_scenes_scripts }}' + - choose: + - alias: Check if normal lights scenes or scripts helper is on - This + is for scenes only when crossing over + conditions: + - '{{ night_boolean_scenes_scripts != [] }}' + sequence: + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn on the night scenes + action: scene.turn_on + target: + entity_id: '{{ night_scene_entities }}' + data: + transition: '{{ night_light_transition_on }}' + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn on the night scenes + action: scene.turn_on + target: + entity_id: '{{ night_scene_entities }}' + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: Turn on the night switches + action: switch.turn_on + target: + entity_id: '{{ night_switch_entities_off }}' + - alias: Turn on the night scripts + action: script.turn_on + target: + entity_id: '{{ night_script_entities }}' + - alias: If night glow is enabled conditions: - condition: template - value_template: '{{ (''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) }}' + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + - condition: not + conditions: + - condition: trigger + id: + - t15 + - t16 sequence: - - service: light.turn_on + - alias: Turn ON lights + action: 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 + entity_id: '{{ night_light_entities }}' + data: '{{ night_light_data }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_glow_light_control + }}' + sequence: + - alias: Turn OFF crossover night glow lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + data: + transition: '{{ night_glow_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_glow_light_control + }}' + sequence: + - alias: Turn OFF crossover night glow lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + - choose: + - alias: Check if normal lights scenes or scripts helper is on - This is + for scenes only when crossing over + conditions: + - condition: template + value_template: "{% if boolean_scenes_scripts == [] %}\n false\n{% + elif is_state(boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n + \ false\n{% endif %}" + sequence: + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: '{{ boolean_scenes_scripts }}' + - choose: + - alias: Check if normal lights scenes or scripts helper is on - This + is for scenes only when crossing over + conditions: + - '{{ night_boolean_scenes_scripts != [] }}' + sequence: + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn on the night scenes + action: scene.turn_on + target: + entity_id: '{{ night_scene_entities }}' + data: + transition: '{{ night_light_transition_on }}' + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn on the night scenes + action: scene.turn_on + target: + entity_id: '{{ night_scene_entities }}' + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ night_boolean_scenes_scripts_helper }}' + - alias: Turn on the night switches + action: switch.turn_on target: - entity_id: '{{ night_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 + entity_id: '{{ night_switch_entities }}' + - alias: Turn off crossover night glow switches + action: switch.turn_off 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 + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' + - alias: Turn on the night scripts + action: script.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 }}' + entity_id: '{{ night_script_entities }}' - choose: - - alias: Check if normal lights scenes or scripts helper is on - This is for - scenes only when crossing over - conditions: - - condition: template - value_template: "{% if boolean_scenes_scripts == [] %}\n false\n{% elif - is_state(boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n false\n{% - endif %}" - sequence: - - alias: 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 + - alias: By-pass is enabled & check by-pass option - Turn lights on conditions: - condition: trigger id: t7_on @@ -3157,7 +4265,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -3168,7 +4276,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -3179,7 +4287,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation else: @@ -3194,7 +4302,7 @@ action: sequence: - alias: Wait until motion sensor is off wait_for_trigger: - platform: state + - trigger: state entity_id: !input motion_trigger from: 'on' to: 'off' @@ -3202,51 +4310,129 @@ action: delay: minutes: !input night_time_delay - choose: - - alias: If transition is selected + - alias: If night glow is disabled conditions: - condition: template - value_template: '{{ ''use_transition'' in include_night_light_control }}' + value_template: '{{ include_night_glow == ''night_glow_disabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_light_entities }}' + data: + transition: '{{ night_light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ night_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_light_entities }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off target: - entity_id: '{{ night_light_entities }}' + entity_id: '{{ night_switch_entities }}' + - alias: Turn off the script + action: script.turn_on data: - transition: '{{ night_transition_off_value }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off data: - entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' - - alias: If transition is not selected + entity_id: !input night_boolean_scenes_scripts + - alias: If night glow is enabled conditions: - condition: template - value_template: '{{ ''use_transition'' not in include_night_light_control - }}' + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - alias: Turn on the lights + action: light.turn_on target: - entity_id: '{{ night_light_entities }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ night_glow_light_entities }}' + data: '{{ night_glow_light_data }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn OFF crossover night lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_light }}' + data: + transition: '{{ night_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn OFF crossover night lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_light }}' + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_glow_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + transition: '{{ night_glow_light_transition_on }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn on the scenes + action: scene.turn_on + data: + entity_id: '{{ night_glow_scene_entities }}' + - alias: Turn on the switches + action: switch.turn_on + target: + entity_id: '{{ night_glow_switch_entities }}' + - alias: Turn OFF crossover night switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_lights_to_night_glow_switch }}' + - alias: Turn on the script + action: script.turn_on data: - entity_id: '{{ 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 + entity_id: '{{ night_glow_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts default: - choose: - - alias: By-pass is turned on & check by-pass option - turn lights off + - alias: By-pass is turned on & check by-pass option - Turn lights off conditions: - condition: trigger id: t7_off @@ -3255,101 +4441,286 @@ action: delay: minutes: !input bypass_time_delay - choose: - - alias: If transition is selected + - alias: If night lights are disabled conditions: - condition: template - value_template: '{{ ''use_transition'' in include_light_control }}' + value_template: '{{ include_night_lights == ''night_lights_disabled'' + }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off target: - entity_id: '{{ light_entities }}' + entity_id: '{{ switch_entities }}' + - alias: Turn off the script + action: script.turn_on data: - transition: '{{ transition_off_value }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off data: - entity_id: '{{ end_scene_entities }}' - transition: '{{ transition_off_value }}' - - alias: If transition is not selected + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean + - alias: Check by-pass settings and preform the correct action + if: + - alias: Check if the by-pass auto off is enabled + condition: template + value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) + or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or + (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}' + then: + - alias: Wait the number of minutes set in the by-pass auto off time delay + delay: + minutes: !input bypass_auto_off_delay + - alias: Parallel Actions for the by-pass auto off + parallel: + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass) + and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_on + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass) + and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_off + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_stop'' in include_bypass) + and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_stop + - stop: Stop the automation + else: + - stop: Stop the automation + - alias: If night lights are enabled conditions: - condition: template - value_template: '{{ ''use_transition'' not in include_light_control }}' + value_template: '{{ include_night_lights == ''night_lights_enabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + data: + transition: '{{ light_transition_off }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off target: - entity_id: '{{ light_entities }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ switch_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_lights_switch }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + sequence: + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' + - alias: Turn off the script + action: script.turn_on data: - entity_id: '{{ end_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 + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean + - alias: Check by-pass settings and preform the correct action + if: + - alias: Check if the by-pass auto off is enabled + condition: template + value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) + or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or + (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}' + then: + - alias: Wait the number of minutes set in the by-pass auto off time delay + delay: + minutes: !input bypass_auto_off_delay + - alias: Parallel Actions for the by-pass auto off + parallel: + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass) + and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_on + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass) + and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_off + - sequence: + - choose: + - conditions: + - condition: template + value_template: '{{ (''bypass_enabled_stop'' in include_bypass) + and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) + }}' + sequence: + - alias: Turn off the by-pass + action: homeassistant.turn_off + entity_id: !input motion_bypass_lights_stop + - stop: Stop the automation + else: + - stop: Stop the automation + - alias: By-pass is turned on & check by-pass option - Keep the current lights state conditions: - condition: trigger @@ -3377,7 +4748,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -3388,7 +4759,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -3399,13 +4770,13 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation else: - stop: Stop the automation - choose: - - alias: By-pass is turned off & check if the motion trigger is off + - alias: By-pass is turned off & check if the motion trigger is off conditions: - condition: trigger id: @@ -3498,53 +4869,195 @@ action: delay: minutes: !input bypass_time_delay - choose: - - alias: If transition is selected + - alias: If night lights are disabled 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 + value_template: '{{ include_night_lights == ''night_lights_disabled'' }}' sequence: - - alias: Turn off the lights - service: light.turn_off + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off target: - entity_id: '{{ light_entities }}' - - alias: Turn off the scenes - service: scene.turn_on + entity_id: '{{ switch_entities }}' + - alias: Turn off the script + action: script.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 + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ + is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean + - stop: Stop the automation + - alias: If night lights are enabled + conditions: + - condition: template + value_template: '{{ include_night_lights == ''night_lights_enabled'' + }}' + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the night lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + data: + transition: '{{ light_transition_off }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light + }}' + data: + transition: '{{ light_transition_off }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ light_entities }}' + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light + }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ switch_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_lights_switch }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' + - alias: Turn off the script + action: script.turn_on + data: + entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ + is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean + - stop: Stop the automation - alias: Motion trigger is off and check if any by-passes are on conditions: - condition: or @@ -3663,7 +5176,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -3674,7 +5187,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -3685,7 +5198,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation - alias: By-pass is turned off & check if the motion trigger is on @@ -3701,7 +5214,7 @@ action: state: 'on' sequence: - choose: - - alias: 'Check all by-pass are off and check conditions if enabled ' + - alias: Check all by-pass are off and check conditions if enabled conditions: - condition: or conditions: @@ -3781,15 +5294,15 @@ action: - '{{ (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) }}' + == ''ambient_light_option_disabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) }}' - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options - == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state - | int > ambient_light_value | int) and (expand(light_switch.entity_id) + == ''ambient_light_option_enabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) and (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''off'') | list | count > 0) }}' - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options - == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state - | int > ambient_light_value | int) and (is_state(boolean_scenes_scripts, + == ''ambient_light_option_enabled'') and ((states(ambient_light_sensor) + | int) > (ambient_light_value | int)) and (is_state(boolean_scenes_scripts, ''off'')) }}' - condition: and conditions: @@ -3808,16 +5321,16 @@ action: value_template: '{{ ''use_transition'' in include_light_control }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' data: - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -3825,21 +5338,39 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ switch_entities }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: !input boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean - stop: Stop the automation - alias: Motion trigger is on and check if any by-passes are on conditions: @@ -3959,7 +5490,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -3970,7 +5501,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -3981,11 +5512,158 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation + - alias: By-pass is turned off & reset lights to the site conditions + conditions: + - condition: trigger + id: + - t8_on + - t8_off + - t8_stop + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + data: + transition: '{{ night_light_transition_off }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + data: + transition: '{{ night_glow_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_lights_light }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_light }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_lights_switch }}' + - choose: + - alias: If night glow is selected + conditions: + - condition: template + value_template: '{{ include_night_glow == ''night_glow_enabled'' }}' + sequence: + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ crossover_night_glow_to_night_lights_switch }}' + - choose: + - alias: Check if night lights scenes & scripts - toggle helper is on + conditions: + - condition: template + value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ + is_state(night_boolean_scenes_scripts, 'on') }}\n{% endif %}" + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_light_control + }}' + sequence: + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ night_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_light_control + }}' + sequence: + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the script + action: script.turn_on + data: + entity_id: '{{ end_script_entities }}' + - alias: Turn off the input boolean night lights + action: input_boolean.turn_off + data: + entity_id: !input night_boolean_scenes_scripts + - choose: + - alias: Turn ON lights + conditions: + - alias: Check the dynamic lighting options + condition: or + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting'' + }}' + - alias: Check that dynamic lighting is active and the state control + option is enabled + condition: and + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: '{{ dynamic_lighting_state_control == ''enable_state_control'' + }}' + - condition: template + value_template: '{{ states(dynamic_lighting_state_control_entity) + == dynamic_lighting_state_control_activation_state_inv }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ crossover_lights_light_on }}' + data: '{{ light_data }}' + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ + is_state(dynamic_lighting_boolean, 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean - choose: - - alias: Sun, Ambient Light Sensor & time above setting to turn off + - alias: Sun, ambient & time above setting to turn off conditions: - condition: trigger id: @@ -4000,41 +5678,55 @@ action: value_template: '{{ ''use_transition'' in include_light_control }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' data: - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: If transition is not selected conditions: - condition: template value_template: '{{ ''use_transition'' not in include_light_control }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ switch_entities }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - alias: Turn off the input boolean night lights - service: input_boolean.turn_off + action: input_boolean.turn_off data: entity_id: !input boolean_scenes_scripts + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean - stop: Stop the automation - alias: Turn off night lights when trigger by end night lights conditions conditions: @@ -4045,12 +5737,65 @@ action: - t14 sequence: - choose: + - alias: If the night glow is enabled + conditions: + - '{{ include_night_glow == ''night_glow_enabled'' }}' + - condition: state + entity_id: !input motion_trigger + state: 'off' + for: + minutes: !input night_time_delay + sequence: + - choose: + - alias: If transition is selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' in include_night_glow_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_glow_light_entities }}' + data: + transition: '{{ night_glow_light_transition_off}}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + transition: '{{ night_glow_light_transition_off }}' + - alias: If transition is not selected + conditions: + - condition: template + value_template: '{{ ''use_transition'' not in include_night_glow_light_control + }}' + sequence: + - alias: Turn off the lights + action: light.turn_off + target: + entity_id: '{{ night_glow_light_entities }}' + - alias: Turn off the scenes + action: scene.turn_on + data: + entity_id: '{{ end_scene_entities }}' + - alias: Turn off the switches + action: switch.turn_off + target: + entity_id: '{{ night_glow_switch_entities }}' + - alias: Turn off the script + action: script.turn_on + data: + entity_id: '{{ end_script_entities }}' + - stop: Stop the automation - alias: If transition is selected conditions: - - '{{ (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'')) }}' + - condition: template + value_template: '{{ (expand(light_switch.entity_id) | selectattr(''state'', + ''=='', ''on'') | list | count > 0) or (expand(night_lights.entity_id) + | selectattr(''state'', ''=='', ''on'') | list | count > 0) or (is_state(night_boolean_scenes_scripts, + ''on'')) }} + + ' sequence: - choose: - alias: If transition is selected @@ -4060,11 +5805,11 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ crossover_night_lights_light }}' data: - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -4072,19 +5817,19 @@ action: }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ crossover_night_lights_light }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ crossover_night_lights_switch }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - choose: - - alias: If adjust light settings when crossing over if lights are ON + - alias: Adjust the lights settings when crossing over if lights are ON is selected in night light control conditions: - condition: template @@ -4099,10 +5844,10 @@ action: }}' sequence: - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ night_transition_off_value }}' + transition: '{{ night_light_transition_off }}' - alias: If transition is not selected conditions: - condition: template @@ -4110,101 +5855,41 @@ action: }}' sequence: - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the input boolean night lights - service: input_boolean.turn_off + action: input_boolean.turn_off data: entity_id: !input night_boolean_scenes_scripts - choose: - - alias: Set the transition and brightness for the normal lights switch + - alias: Turn ON lights 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) }}' + - alias: Check the dynamic lighting options + condition: or + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting'' + }}' + - alias: Check that dynamic lighting is active and the state control + option is enabled + condition: and + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: '{{ dynamic_lighting_state_control == ''enable_state_control'' + }}' + - condition: template + value_template: '{{ states(dynamic_lighting_state_control_entity) + == dynamic_lighting_state_control_activation_state_inv }}' sequence: - - service: light.turn_on + - action: 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 + data: '{{ light_data }}' + - alias: If manage scripts is enabled conditions: - '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}' - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''off'') @@ -4213,17 +5898,17 @@ action: ''off'')) }}' sequence: - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - stop: Stop the automation - alias: Safe Guard when HA restarts conditions: - condition: trigger - id: t15 + id: t17 sequence: - choose: - - alias: 'Check all by-pass are off and check conditions if enabled ' + - alias: Check all by-pass are off and check conditions if enabled conditions: - condition: or conditions: @@ -4398,7 +6083,7 @@ action: match: any state: 'on' sequence: - - alias: Check by-pass auto off is enabled and preform the correct + - alias: Check by-pass auto off is enabled and preform the correct action if: - alias: Check if the by-pass auto off is enabled condition: template @@ -4420,7 +6105,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -4431,7 +6116,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -4442,10 +6127,10 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation - - alias: Parallel Actions for dynamic lighting + - alias: Parallel actions for dynamic lighting and normal lights parallel: - sequence: - alias: Check if the dynamic lighting is enabled @@ -4454,326 +6139,313 @@ action: - condition: template value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' }}' + - alias: Check the dynamic lighting state control option + condition: or + conditions: + - condition: template + value_template: '{{ dynamic_lighting_state_control == ''disable_state_control'' + }}' + - alias: Check if the dynamic lighting state control option is enabled + condition: and + conditions: + - condition: template + value_template: '{{ dynamic_lighting_state_control == ''enable_state_control'' + }}' + - condition: state + entity_id: !input dynamic_lighting_state_control_entity + state: !input dynamic_lighting_state_control_activation_state - choose: - - alias: Set the Dynamic Lux Controlled Brightness for the normal lights switch + - alias: Dynamic Lighting - Input Boolean Helper + conditions: + - condition: template + value_template: '{{ dynamic_lighting_boolean != [] }}' + sequence: + - alias: Turn on the boolean for dynamic lighting + action: input_boolean.turn_on + data: + entity_id: !input dynamic_lighting_boolean + - choose: + - alias: 1 - Dynamic Lighting - Lux Controlled Brightness conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness''}}' sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_max_lux - dynamic_lighting_min_lux) %} {% + set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_max_brightness + %} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id') + | list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 * 100 + / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n + \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif lux + >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% elif + (bv > lp) and (dynamic_lighting_max_brightness - lp) <= dynamic_lighting_dead_zone + %}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif + (lp > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif + (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}\n {% + set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n {% set bv = lp %}\n{% elif bv > (lp + dynamic_lighting_step_value) + %}\n {% set bv = lp + dynamic_lighting_step_value %}\n{% elif + bv < (lp - dynamic_lighting_step_value) %}\n {% set bv = lp - + dynamic_lighting_step_value %}\n{% endif %} {{ bv | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_max_lux - dynamic_lighting_min_lux) %} {% + set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_max_brightness + %} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id') + | list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 * 100 + / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n + \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif lux + >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness + - lp) <= dynamic_lighting_dead_zone %}\n false\n{% elif (lp > + bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n true\n{% else %}\n false\n{% endif %}\n" - choose: - - alias: Set the transition and dynamic lighting brightness for the - normal lights switch + - alias: Stop when crossing over 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) - }}' + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' sequence: - - service: light.turn_on + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on target: entity_id: '{{ light_entities }}' - data: - 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" + data: '{{ dynamic_light_data }}' - 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 + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop - condition: template - value_template: '{{ (''use_transition'' in include_light_control) - and (include_dynamic_lighting == ''enable_lux_controled_brightness'') - and (''use_colour_temperature'' in include_light_control) }}' + value_template: '{{ repeat.index == 1 }}' sequence: - - service: light.turn_on + - action: 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - kelvin: '{{temperature_value}}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If dynamic lighting brightness is in the dead zone + conditions: '{{ in_dead_zone }}' + sequence: - alias: Dynamic lighting heartbeat delay: minutes: !input dynamic_lighting_heartbeat - alias: Set the dynamic lighting brightness for the normal lights - 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) + value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness'' }}' sequence: - - service: light.turn_on + - action: 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - - 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - kelvin: '{{temperature_value}}' + data: '{{ dynamic_light_data }}' - alias: Dynamic lighting heartbeat delay: minutes: !input dynamic_lighting_heartbeat - choose: - - alias: Dynamic Lighting - Lux Controlled Brightness - Inverted for the - normal lights switch + - alias: 2 - Dynamic Lighting - Lux Controlled Brightness - Inverted conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness_inv''}}' sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_min_lux - dynamic_lighting_max_lux) %} {% + set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_min_brightness + %} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id') + | list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 * 100 + / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n + \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif lux + >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% elif + (bv > lp) and (dynamic_lighting_max_brightness - lp) <= dynamic_lighting_dead_zone + %}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif + (lp > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif + (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone %}\n {% + set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n {% set bv = lp %}\n{% elif bv > (lp + dynamic_lighting_step_value) + %}\n {% set bv = lp + dynamic_lighting_step_value %}\n{% elif + bv < (lp - dynamic_lighting_step_value) %}\n {% set bv = lp - + dynamic_lighting_step_value %}\n{% endif %} {{ bv | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_min_lux - dynamic_lighting_max_lux) %} {% + set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_min_brightness + %} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id') + | list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 * 100 + / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux %}\n + \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif lux + >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness + - lp) <= dynamic_lighting_dead_zone %}\n true\n{% elif (lp > + bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n true\n{% else %}\n false\n{% endif %}\n" - choose: - - alias: Set the transition and dynamic lighting brightness for the - normal lights switch + - alias: Stop when crossing over 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) + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If dynamic lighting brightness is in the dead zone + conditions: '{{ in_dead_zone }}' + sequence: + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Set dynamic lighting brightness inverted for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness_inv'' }}' sequence: - - service: light.turn_on + - action: 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 %}\n - \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - - 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 %}\n - \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - 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 %}\n - \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - - 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 %}\n - \ {% set bv = dynamic_lighting_min_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - kelvin: '{{temperature_value}}' + data: '{{ dynamic_light_data }}' - alias: Dynamic lighting heartbeat delay: minutes: !input dynamic_lighting_heartbeat - choose: - - alias: Dynamic Lighting - Sun Elevation Lighting - Colour Temp for the normal - lights switch + - alias: 3 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour'' @@ -4781,193 +6453,144 @@ action: sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope = + (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n {% elif elevation <= + dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if 'use_brightness' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'brightness_pct': + light_brightness }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising + - 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising + + 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling + + 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n + \ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising + + 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling + - 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising + - 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n + \ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" - choose: - - alias: Set the transition and dynamic sun elevation colour temperature - for the normal lights switch + - alias: Stop when crossing over 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'') }}' + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - 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 + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control conditions: - condition: template - value_template: '{{ (''use_transition'' in include_light_control) - and (''use_brightness'' in include_light_control) and (include_dynamic_lighting - == ''enable_sun_elevation_colour'') }}' + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 sequence: - - service: light.turn_on + - action: 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - alias: Dynamic lighting heartbeat - delay: - minutes: !input dynamic_lighting_heartbeat - - alias: Set the dynamic sun elevation colour temperature for the - normal lights switch + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If sun elevation is outside the adjustment zone and the lights + are ON + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set dynamic sun elevation colour temperature for the normal + lights conditions: - condition: template - value_template: '{{ (''use_transition'' not in include_light_control) - and (''use_brightness'' not in include_light_control) and (include_dynamic_lighting - == ''enable_sun_elevation_colour'') }}' + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour'' + }}' sequence: - - service: light.turn_on + - action: 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - alias: Dynamic lighting heartbeat - delay: - minutes: !input dynamic_lighting_heartbeat + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation - choose: - - alias: Set the Sun Elevation Lighting - Brightness for the normal lights - switch + - alias: 4 - Dynamic Lighting - Sun Elevation Lighting - Brightness conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness'' @@ -4975,195 +6598,170 @@ action: sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun', + 'elevation') | float %} {% set start_slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_brightness %} {% set end_slope = + (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_brightness %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_max_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + should_wait: "{% set le = light_entities %} {% set lec = expand(le) + | map(attribute='entity_id') | list | length %} {% set lp = (expand(le) + | map(attribute='attributes.brightness') | reject('equalto', None) + | sum | float(default=255) / 255 * 100 / lec) | round(0) %} {% + set elevation = state_attr('sun.sun', 'elevation') | float %} + {% set start_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising) + %} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_brightness %} {% set end_slope = + (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_brightness %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_max_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% endif %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if (brightness_value >= + (lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n + \ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" - choose: - - alias: Set the transition and dynamic sun elevation lighting brightness - for the normal lights switch + - alias: Stop when crossing over 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) + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If lights are ON and the lights are within 1% of the actual + brightness + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set dynamic sun elevation lighting brightness for the normal + lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness'' }}' sequence: - - service: light.turn_on + - action: 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - kelvin: '{{temperature_value}}' - - alias: Dynamic lighting heartbeat - delay: - minutes: !input dynamic_lighting_heartbeat + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation - choose: - - alias: Set the Sun Elevation Lighting - Brightness Inverted for the normal - lights switch + - alias: 5 - Dynamic Lighting - Sun Elevation Lighting - Brightness Inverted conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness_inv'' @@ -5171,195 +6769,170 @@ action: sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun', + 'elevation') | float %} {% set start_slope = (dynamic_lighting_max_brightness + - dynamic_lighting_min_brightness) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_min_brightness %} {% set end_slope = + (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_max_brightness %} {% if elevation > -10 + %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_min_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + should_wait: "{% set le = light_entities %} {% set lec = expand(le) + | map(attribute='entity_id') | list | length %} {% set lp = (expand(le) + | map(attribute='attributes.brightness') | reject('equalto', None) + | sum | float(default=255) / 255 * 100 / lec) | round(0) %} {% + set elevation = state_attr('sun.sun', 'elevation') | float %} + {% set start_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising) + %} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_min_brightness %} {% set end_slope = + (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_max_brightness %} {% if elevation > -10 + %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_min_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if (brightness_value >= + (lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n + \ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" - choose: - - alias: Set the transition and dynamic sun elevation lighting brightness - inverted for the normal lights switch + - alias: Stop when crossing over 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) + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If lights are ON and the lights are within 1% of the actual + brightness + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set dynamic sun elevation lighting brightness inverted for + the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness_inv'' }}' sequence: - - service: light.turn_on + - action: 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - - 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_max_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - kelvin: '{{temperature_value}}' - - alias: Dynamic lighting heartbeat - delay: - minutes: !input dynamic_lighting_heartbeat + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation - choose: - - alias: Set the Sun Elevation Lighting - Colour Temp + Brightness for the - normal lights switch + - alias: 6 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Brightness conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'' @@ -5367,206 +6940,602 @@ action: sequence: - alias: Dynamic Lighting Control repeat: - until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='', - ''off'') | list | count > 0 }}' + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' sequence: + - variables: + dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope = + (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n {% elif elevation <= + dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun', + 'elevation') | float %} {% set start_slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_brightness %} {% set end_slope = + (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_brightness %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_max_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin + }) %} {% set light.data = dict(light.data, **{ 'brightness_pct': + dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set le = light_entities %} {% set lec = expand(le) + | map(attribute='entity_id') | list | length %} {% set lp = (expand(le) + | map(attribute='attributes.brightness') | reject('equalto', None) + | sum | float(default=255) / 255 * 100 / lec) | round(0) %} {% + set elevation = state_attr('sun.sun', 'elevation') | float %} + {% set start_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising) + %} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_brightness %} {% set end_slope = + (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_brightness %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_max_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% endif %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if (brightness_value >= + (lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n + \ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" - choose: - - alias: Set the transition, dynamic sun elevation lighting brightness - and dynamic sun elevation colour temperature for the normal lights - switch + - alias: Stop when crossing over conditions: - condition: template - value_template: '{{ (''use_transition'' in include_light_control) - and (include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'') - }}' + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') - | float %} {% set start_slope = (dynamic_lighting_min_colour_temp - - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising - - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak - = (( start_slope * dynamic_lighting_sun_elevation_end_rising) - * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope - = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) - / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) - %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) - * -1) + dynamic_lighting_min_colour_temp %} {% if elevation - >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - 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 + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control conditions: - condition: template - value_template: '{{ (''use_transition'' not in include_light_control) - and (include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'') - }}' + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 sequence: - - service: light.turn_on + - action: 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 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set brightness_value = dynamic_lighting_max_brightness - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - brightness_value = dynamic_lighting_min_brightness %}\n {% - endif %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness - %}\n{% endif %} {{ brightness_value | round(0) }}\n" - kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') - | float %} {% set start_slope = (dynamic_lighting_min_colour_temp - - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising - - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak - = (( start_slope * dynamic_lighting_sun_elevation_end_rising) - * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope - = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) - / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) - %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) - * -1) + dynamic_lighting_min_colour_temp %} {% if elevation - >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" - - alias: Dynamic lighting heartbeat - delay: - minutes: !input dynamic_lighting_heartbeat + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If lights are ON and the lights are within 1% of the actual + brightness + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set dynamic sun elevation lighting brightness and dynamic + sun elevation colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation - choose: - - alias: Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness - for the normal lights switch + - alias: 7 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Brightness + Inverted + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness_inv'' + }}' + sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' + sequence: + - variables: + dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope = + (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %} {% if elevation >= + -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n {% elif elevation <= + dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + dynamic_brightness_pct: "{% set elevation = state_attr('sun.sun', + 'elevation') | float %} {% set start_slope = (dynamic_lighting_max_brightness + - dynamic_lighting_min_brightness) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_min_brightness %} {% set end_slope = + (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_max_brightness %} {% if elevation > -10 + %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_min_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin + }) %} {% set light.data = dict(light.data, **{ 'brightness_pct': + dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set le = light_entities %} {% set lec = expand(le) + | map(attribute='entity_id') | list | length %} {% set lp = (expand(le) + | map(attribute='attributes.brightness') | reject('equalto', None) + | sum | float(default=255) / 255 * 100 / lec) | round(0) %} {% + set elevation = state_attr('sun.sun', 'elevation') | float %} + {% set start_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising) + %} {% set start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_min_brightness %} {% set end_slope = + (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_max_brightness %} {% if elevation > -10 + %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising and + is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = ((start_slope * elevation) + start_ak) | round(1) %}\n {% elif + elevation <= dynamic_lighting_sun_elevation_start_falling and + elevation >= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', + 'rising', false) %}\n {% set brightness_value = ((end_slope + * elevation) + end_ak) | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n {% else %}\n {% set + brightness_value = dynamic_lighting_min_brightness %}\n {% endif + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if (brightness_value >= + (lp * 0.99) and brightness_value <= (lp * 1.01)) %}\n true\n + \ {% else %}\n false\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If lights are ON and the lights are within 1% of the actual + brightness + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set dynamic sun elevation lighting brightness and dynamic + sun elevation colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness_inv'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - choose: + - alias: 8 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux + Controlled Brightness conditions: - condition: template value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'' }}' sequence: - - alias: 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'') - }}' + - alias: Parallel actions for dynamic lighting + parallel: + - sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) + or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean, + ''off''))) }}' sequence: - - service: light.turn_on - target: - entity_id: '{{ light_entities }}' - data: - transition: '{{ transition_on_value }}' - brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor) + - variables: + dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor) | float %} {% set slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux) * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities %} {% set lec = expand(le) | map(attribute='entity_id') | - list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness') + 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif + * 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux + %}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') + elif (bv > lp) and (dynamic_lighting_max_brightness - lp) + <= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% elif (lp > bv) and (lp - dynamic_lighting_min_brightness) + <= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_min_brightness + %}\n{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) <= + dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% elif + bv > (lp + dynamic_lighting_step_value) %}\n {% set bv = + lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - dynamic_lighting_step_value) + %}\n {% set bv = lp - dynamic_lighting_step_value %}\n{% + endif %} {{ bv | round(0) }}\n" + dynamic_kelvin: "{% if expand(light_entities) | selectattr('state', + '==', 'off') | list | count > 0 %}\n {% set elevation = state_attr('sun.sun', + 'elevation') | float %}\n {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %}\n {% set + start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %}\n {% set end_slope + = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %}\n {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %}\n {% if elevation + >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% + set colour_temp_value = ((start_slope * elevation) + start_ak) + | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling + and elevation >= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% + set colour_temp_value = ((end_slope * elevation) + end_ak) + | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% + set colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% + set colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n {% else %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n {% endif %}\n {{ + colour_temp_value | round(0) }}\n{% endif %}\n" + dynamic_light_off_data: "{% set light = namespace(data={}) %} + {% set light.data = dict(light.data, **{ 'brightness_pct': + dynamic_brightness_pct }) %} {% set light.data = dict(light.data, + **{ 'color_temp_kelvin': dynamic_kelvin }) %} {% if 'use_transition' + in include_light_control %}\n {% set light.data = dict(light.data, + **{ 'transition': light_transition_on }) %}\n{% endif %} {{ + light.data }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% + set light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n + \ {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {{ light.data }}\n" + in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux + - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux) + * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities + %} {% set lec = expand(le) | map(attribute='entity_id') | + list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 + * 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux + %}\n {% set bv = dynamic_lighting_max_brightness %}\n{% elif + lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness + - lp) <= dynamic_lighting_dead_zone %}\n false\n{% elif (lp + > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n true\n{% else %}\n false\n{% endif %}\n" + - choose: + - alias: Check if the light is off + conditions: '{{ expand(light_entities) | selectattr(''state'', + ''=='', ''off'') | list | count > 0 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is off + delay: + milliseconds: 100 + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights + are ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is on + delay: + milliseconds: 100 + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or + state control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is on + delay: + milliseconds: 100 + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If dynamic lighting brightness is in the dead zone + conditions: '{{ in_dead_zone }}' + sequence: + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Set dynamic lighting lux brightness and dynamic sun elevation + colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'' + }}' + - '{{ expand(light_entities) | selectattr(''state'', ''=='', + ''off'') | list | count > 0 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_off_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Set dynamic lighting lux brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) + or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean, + ''off''))) }}' + sequence: + - variables: + dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') | float %} {% set start_slope = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak @@ -5593,186 +7562,1249 @@ action: \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling and is_state_attr('sun.sun', 'rising', false) %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + \ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n{% else %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n{% endif %} {{ colour_temp_value + | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% + set light.data = dict(light.data, **{ 'color_temp_kelvin': + dynamic_kelvin }) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': + light_transition_on }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising + - 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising + + 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling + + 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n + \ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising + + 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling + - 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising + - 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n + \ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights + are ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or + state control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If sun elevation is outside the adjustment zone and the + lights are ON + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If the lights are OFF + conditions: '{{ expand(light_entities) | selectattr(''state'', + ''=='', ''off'') | list | count > 0 }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set sun elevation colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - choose: + - alias: 9 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux + Controlled Brightness Inverted + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv'' + }}' + sequence: + - alias: Parallel actions for dynamic lighting + parallel: + - sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) + or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean, + ''off''))) }}' + sequence: + - variables: + dynamic_brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (dynamic_lighting_min_lux + - dynamic_lighting_max_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux) + * -1) + dynamic_lighting_min_brightness %} {% set le = light_entities + %} {% set lec = expand(le) | map(attribute='entity_id') | + list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 + * 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux + %}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif + lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% + elif (bv > lp) and (dynamic_lighting_max_brightness - lp) + <= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% elif (lp > bv) and (lp - dynamic_lighting_min_brightness) + <= dynamic_lighting_dead_zone %}\n {% set bv = dynamic_lighting_min_brightness + %}\n{% elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) + <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% + elif bv > (lp + dynamic_lighting_step_value) %}\n {% set + bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp + - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value + %}\n{% endif %} {{ bv | round(0) }}\n" + dynamic_kelvin: "{% if expand(light_entities) | selectattr('state', + '==', 'off') | list | count > 0 %}\n {% set elevation = state_attr('sun.sun', + 'elevation') | float %}\n {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %}\n {% set + start_ak = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %}\n {% set end_slope + = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %}\n {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %}\n {% if elevation + >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% + set colour_temp_value = ((start_slope * elevation) + start_ak) + | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling + and elevation >= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% + set colour_temp_value = ((end_slope * elevation) + end_ak) + | round(1) %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% + set colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% + set colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n {% else %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n {% endif %}\n {{ + colour_temp_value | round(0) }}\n{% endif %}\n" + dynamic_light_off_data: "{% set light = namespace(data={}) %} + {% set light.data = dict(light.data, **{ 'brightness_pct': + dynamic_brightness_pct }) %} {% set light.data = dict(light.data, + **{ 'color_temp_kelvin': dynamic_kelvin }) %} {% if 'use_transition' + in include_light_control %}\n {% set light.data = dict(light.data, + **{ 'transition': light_transition_on }) %}\n{% endif %} {{ + light.data }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% + set light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n + \ {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {{ light.data }}\n" + in_dead_zone: "{% set lux = states(dynamic_lighting_lux_sensor) + | float %} {% set slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (dynamic_lighting_min_lux + - dynamic_lighting_max_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux) + * -1) + dynamic_lighting_min_brightness %} {% set le = light_entities + %} {% set lec = expand(le) | map(attribute='entity_id') | + list | length %} {% set lp = (expand(le) | map(attribute='attributes.brightness') + | reject('equalto', None) | sum | float(default=255) / 255 + * 100 / lec) | round(0) %} {% if lux <= dynamic_lighting_min_lux + %}\n {% set bv = dynamic_lighting_min_brightness %}\n{% elif + lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_max_brightness + %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) + %}\n{% endif %} {% if (bv > lp) and (dynamic_lighting_max_brightness + - lp) <= dynamic_lighting_dead_zone %}\n true\n{% elif (lp + > bv) and (lp - dynamic_lighting_min_brightness) <= dynamic_lighting_dead_zone + %}\n false\n{% elif (bv >= lp) and (bv - lp) <= dynamic_lighting_dead_zone + %}\n true\n{% elif (lp >= bv) and (lp - bv) <= dynamic_lighting_dead_zone + %}\n true\n{% else %}\n false\n{% endif %}\n" + - choose: + - alias: Check if the light is off + conditions: '{{ expand(light_entities) | selectattr(''state'', + ''=='', ''off'') | list | count > 0 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is off + delay: + milliseconds: 100 + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights + are ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is on + delay: + milliseconds: 100 + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or + state control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - alias: Delay for parallel actions needed for when the light + is on + delay: + milliseconds: 100 + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If dynamic lighting brightness is in the dead zone + conditions: '{{ in_dead_zone }}' + sequence: + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Set dynamic lighting lux brightness and dynamic sun elevation + colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv'' + }}' + - '{{ expand(light_entities) | selectattr(''state'', ''=='', + ''off'') | list | count > 0 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_off_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Set dynamic lighting lux brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) + or ((dynamic_lighting_boolean != []) and (is_state(dynamic_lighting_boolean, + ''off''))) }}' + sequence: + - variables: + dynamic_kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising + - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak + = (( start_slope * dynamic_lighting_sun_elevation_end_rising) + * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope + = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) + %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) + * -1) + dynamic_lighting_min_colour_temp %} {% if elevation + >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising + and elevation <= dynamic_lighting_sun_elevation_end_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set + colour_temp_value = ((start_slope * elevation) + start_ak) + | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling + and elevation >= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set + colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) + %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising + and elevation >= dynamic_lighting_sun_elevation_start_falling + \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising + and is_state_attr('sun.sun', 'rising', true) %}\n {% set + colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling + and is_state_attr('sun.sun', 'rising', false) %}\n {% set + colour_temp_value = dynamic_lighting_min_colour_temp %}\n + \ {% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n {% endif %}\n{% else %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n{% endif %} {{ colour_temp_value + | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% + set light.data = dict(light.data, **{ 'color_temp_kelvin': + dynamic_kelvin }) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': + light_transition_on }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set elevation = state_attr('sun.sun', 'elevation') + | float %} {% if expand(light_entities) | selectattr('state', + '==', 'on') | list | count > 0 %}\n {% if elevation >= (dynamic_lighting_sun_elevation_start_rising + - 2) and elevation <= (dynamic_lighting_sun_elevation_end_rising + + 2) and is_state_attr('sun.sun', 'rising', true) %}\n false\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_start_falling + + 2) and elevation >= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n false\n + \ {% elif elevation >= (dynamic_lighting_sun_elevation_end_rising + + 2) and elevation >= (dynamic_lighting_sun_elevation_start_falling + - 2) %}\n true\n {% elif elevation <= (dynamic_lighting_sun_elevation_start_rising + - 2) and is_state_attr('sun.sun', 'rising', true) %}\n true\n + \ {% elif elevation <= (dynamic_lighting_sun_elevation_end_falling + - 2) and is_state_attr('sun.sun', 'rising', false) %}\n true\n + \ {% else %}\n true\n {% endif %}\n{% else %}\n false\n{% + endif %}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights + are ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Adjust the light settings when all bypasses are off or + state control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If sun elevation is outside the adjustment zone and the + lights are ON + conditions: '{{ should_wait }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: If the lights are OFF + conditions: '{{ expand(light_entities) | selectattr(''state'', + ''=='', ''off'') | list | count > 0 }}' + sequence: + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - alias: Set sun elevation colour temperature for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness_inv'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Wait for sun elevation to change + wait_for_trigger: + - trigger: state + entity_id: sun.sun + attribute: elevation + - choose: + - alias: 10 - Dynamic Lighting - Time Controlled - Colour Temp + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour'' + }}' + sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' + sequence: + - variables: + dynamic_kelvin: "{% set current_time = now().hour + (now().minute + / 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (start_time_morning - end_time_morning) + %} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_colour_temp + %} {% set end_slope = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope + * (-end_time_evening)) + dynamic_lighting_min_colour_temp %} {% + if current_time >= start_time_morning and current_time <= end_time_morning + %}\n {% set colour_temp_value = (start_slope * current_time + + start_ak) | round(1) %}\n{% elif current_time >= start_time_evening + and current_time <= end_time_evening %}\n {% set colour_temp_value + = (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time + > end_time_morning and current_time < start_time_evening %}\n + \ {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n{% elif current_time < start_time_morning %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n{% elif current_time > + end_time_evening %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if 'use_brightness' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'brightness_pct': + light_brightness }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set current_time = now().hour + (now().minute / + 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities) + | selectattr('state', '==', 'on') | list | count > 0 %} {% set + in_morning = start_time_morning <= current_time <= end_time_morning + %} {% set in_evening = start_time_evening <= current_time <= end_time_evening + %} {{ lights_on and not (in_morning or in_evening) }}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' - alias: Dynamic lighting heartbeat delay: minutes: !input dynamic_lighting_heartbeat - - alias: Set the dynamic lighting lux brightness and dynamic sun elevation - colour temperature for the normal lights switch + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop - condition: template - value_template: '{{ (''use_transition'' not in include_light_control) - and (include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'') - }}' + value_template: '{{ repeat.index == 1 }}' sequence: - - service: light.turn_on + - action: 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 %}\n - \ {% set bv = dynamic_lighting_max_brightness %}\n{% elif - lux >= dynamic_lighting_max_lux %}\n {% set bv = dynamic_lighting_min_brightness - %}\n{% else %}\n {% set bv = ((slope * lux) + ak) | round(1) - %}\n{% endif %} {% if lp <= 0 %}\n {% set bv = bv %}\n{% - elif (bv > lp) and (bv - lp) <= dynamic_lighting_dead_zone - %}\n {% set bv = lp %}\n{% elif (lp > bv) and (lp - bv) - <= dynamic_lighting_dead_zone %}\n {% set bv = lp %}\n{% - elif bv > (lp + dynamic_lighting_step_value) %}\n {% set - bv = lp + dynamic_lighting_step_value %}\n{% elif bv < (lp - - dynamic_lighting_step_value) %}\n {% set bv = lp - dynamic_lighting_step_value - %}\n{% endif %} {{ bv | round(0) }}\n" - kelvin: "{% set elevation = state_attr('sun.sun', 'elevation') - | float %} {% set start_slope = (dynamic_lighting_min_colour_temp - - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising - - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak - = (( start_slope * dynamic_lighting_sun_elevation_end_rising) - * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope - = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) - / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling) - %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling) - * -1) + dynamic_lighting_min_colour_temp %} {% if elevation - >= -10 %}\n {% if elevation >= dynamic_lighting_sun_elevation_start_rising - and elevation <= dynamic_lighting_sun_elevation_end_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = ((start_slope * elevation) + start_ak) - | round(1) %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_falling - and elevation >= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = ((end_slope * elevation) + end_ak) | round(1) - %}\n {% elif elevation >= dynamic_lighting_sun_elevation_end_rising - and elevation >= dynamic_lighting_sun_elevation_start_falling - \ %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp - %}\n {% elif elevation <= dynamic_lighting_sun_elevation_start_rising - and is_state_attr('sun.sun', 'rising', true) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% elif elevation <= dynamic_lighting_sun_elevation_end_falling - and is_state_attr('sun.sun', 'rising', false) %}\n {% set - colour_temp_value = dynamic_lighting_min_colour_temp %}\n - \ {% endif %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp - %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If time is outside the adjustment zone and the lights are + ON + conditions: '{{ should_wait }}' + sequence: + - choose: + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_morning + before: !input dynamic_lighting_time_start_evening + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_evening + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_evening + before: !input dynamic_lighting_time_start_morning + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_morning + - alias: Set the dynamic lighting brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - choose: + - alias: 11 - Dynamic Lighting - Time Controlled - Brightness + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness'' + }}' + sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' + sequence: + - variables: + dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute + / 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (start_time_morning - end_time_morning) + %} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_brightness + %} {% set end_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope + * (-end_time_evening)) + dynamic_lighting_min_brightness %} {% + if current_time >= start_time_morning and current_time <= end_time_morning + %}\n {% set brightness_value = (start_slope * current_time + + start_ak) | round(1) %}\n{% elif current_time >= start_time_evening + and current_time <= end_time_evening %}\n {% set brightness_value + = (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time + > end_time_morning and current_time < start_time_evening %}\n + \ {% set brightness_value = dynamic_lighting_max_brightness %}\n{% + elif current_time < start_time_morning %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n{% elif current_time > end_time_evening + %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + should_wait: "{% set current_time = now().hour + (now().minute / + 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities) + | selectattr('state', '==', 'on') | list | count > 0 %} {% set + in_morning = start_time_morning <= current_time <= end_time_morning + %} {% set in_evening = start_time_evening <= current_time <= end_time_evening + %} {{ lights_on and not (in_morning or in_evening) }}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If time is outside the adjustment zone and the lights are + ON + conditions: '{{ should_wait }}' + sequence: + - choose: + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_morning + before: !input dynamic_lighting_time_start_evening + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_evening + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_evening + before: !input dynamic_lighting_time_start_morning + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_morning + - alias: Set the dynamic lighting brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - choose: + - alias: 12 - Dynamic Lighting - Time Controlled - Brightness Inverted + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness_inv'' + }}' + sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' + sequence: + - variables: + dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute + / 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_max_brightness + - dynamic_lighting_min_brightness) / (start_time_morning - end_time_morning) + %} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_min_brightness + %} {% set end_slope = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness) + / (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope + * (-end_time_evening)) + dynamic_lighting_max_brightness %} {% + if current_time >= start_time_morning and current_time <= end_time_morning + %}\n {% set brightness_value = (start_slope * current_time + + start_ak) | round(1) %}\n{% elif current_time >= start_time_evening + and current_time <= end_time_evening %}\n {% set brightness_value + = (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time + > end_time_morning and current_time < start_time_evening %}\n + \ {% set brightness_value = dynamic_lighting_min_brightness %}\n{% + elif current_time < start_time_morning %}\n {% set brightness_value + = dynamic_lighting_max_brightness %}\n{% elif current_time > end_time_evening + %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'brightness_pct': dynamic_brightness_pct + }) %} {% if 'use_transition' in include_light_control %}\n {% + set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {% if include_light_colour_control == 'use_colour_temperature' + %}\n {% set light.data = dict(light.data, **{ 'color_temp_kelvin': + light_colour_temperature }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgb_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgb_color': light_rgb_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbw_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbw_color': light_rgbw_colour }) %}\n{% endif %} {% if include_light_colour_control + == 'use_rgbww_colour' %}\n {% set light.data = dict(light.data, + **{ 'rgbww_color': light_rgbww_colour }) %}\n{% endif %} {{ light.data + }}\n" + should_wait: "{% set current_time = now().hour + (now().minute / + 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities) + | selectattr('state', '==', 'on') | list | count > 0 %} {% set + in_morning = start_time_morning <= current_time <= end_time_morning + %} {% set in_evening = start_time_evening <= current_time <= end_time_evening + %} {{ lights_on and not (in_morning or in_evening) }}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If time is outside the adjustment zone and the lights are + ON + conditions: '{{ should_wait }}' + sequence: + - choose: + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_morning + before: !input dynamic_lighting_time_start_evening + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_evening + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_evening + before: !input dynamic_lighting_time_start_morning + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_morning + - alias: Set the dynamic lighting brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_brightness_inv'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - choose: + - alias: 13 - Dynamic Lighting - Time Controlled - Colour Temp & Brightness + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour_brightness'' + }}' + sequence: + - alias: Dynamic Lighting Control + repeat: + until: '{{ ((dynamic_lighting_boolean == []) and (expand(light_entities) + | selectattr(''state'', ''=='', ''off'') | list | count > 0)) or ((dynamic_lighting_boolean + != []) and (is_state(dynamic_lighting_boolean, ''off''))) }}' + sequence: + - variables: + dynamic_brightness_pct: "{% set current_time = now().hour + (now().minute + / 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_brightness + - dynamic_lighting_max_brightness) / (start_time_morning - end_time_morning) + %} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_brightness + %} {% set end_slope = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness) + / (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope + * (-end_time_evening)) + dynamic_lighting_min_brightness %} {% + if current_time >= start_time_morning and current_time <= end_time_morning + %}\n {% set brightness_value = (start_slope * current_time + + start_ak) | round(1) %}\n{% elif current_time >= start_time_evening + and current_time <= end_time_evening %}\n {% set brightness_value + = (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time + > end_time_morning and current_time < start_time_evening %}\n + \ {% set brightness_value = dynamic_lighting_max_brightness %}\n{% + elif current_time < start_time_morning %}\n {% set brightness_value + = dynamic_lighting_min_brightness %}\n{% elif current_time > end_time_evening + %}\n {% set brightness_value = dynamic_lighting_min_brightness + %}\n{% else %}\n {% set brightness_value = dynamic_lighting_max_brightness + %}\n{% endif %} {{ brightness_value | round(0) }}\n" + dynamic_kelvin: "{% set current_time = now().hour + (now().minute + / 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set start_slope = (dynamic_lighting_min_colour_temp + - dynamic_lighting_max_colour_temp) / (start_time_morning - end_time_morning) + %} {% set start_ak = (start_slope * (-end_time_morning)) + dynamic_lighting_max_colour_temp + %} {% set end_slope = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp) + / (end_time_evening - start_time_evening) %} {% set end_ak = (end_slope + * (-end_time_evening)) + dynamic_lighting_min_colour_temp %} {% + if current_time >= start_time_morning and current_time <= end_time_morning + %}\n {% set colour_temp_value = (start_slope * current_time + + start_ak) | round(1) %}\n{% elif current_time >= start_time_evening + and current_time <= end_time_evening %}\n {% set colour_temp_value + = (end_slope * current_time + end_ak) | round(1) %}\n{% elif current_time + > end_time_morning and current_time < start_time_evening %}\n + \ {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n{% elif current_time < start_time_morning %}\n {% set colour_temp_value + = dynamic_lighting_min_colour_temp %}\n{% elif current_time > + end_time_evening %}\n {% set colour_temp_value = dynamic_lighting_min_colour_temp + %}\n{% else %}\n {% set colour_temp_value = dynamic_lighting_max_colour_temp + %}\n{% endif %} {{ colour_temp_value | round(0) }}\n" + dynamic_light_data: "{% set light = namespace(data={}) %} {% set + light.data = dict(light.data, **{ 'color_temp_kelvin': dynamic_kelvin + }) %} {% set light.data = dict(light.data, **{ 'brightness_pct': + dynamic_brightness_pct }) %} {% if 'use_transition' in include_light_control + %}\n {% set light.data = dict(light.data, **{ 'transition': light_transition_on + }) %}\n{% endif %} {{ light.data }}\n" + should_wait: "{% set current_time = now().hour + (now().minute / + 60) %} {% set start_time_morning = dynamic_lighting_time_start_morning.split(':')[0] + | int + (dynamic_lighting_time_start_morning.split(':')[1] | int + / 60) %} {% set end_time_morning = dynamic_lighting_time_end_morning.split(':')[0] + | int + (dynamic_lighting_time_end_morning.split(':')[1] | int + / 60) %} {% set start_time_evening = dynamic_lighting_time_start_evening.split(':')[0] + | int + (dynamic_lighting_time_start_evening.split(':')[1] | int + / 60) %} {% set end_time_evening = dynamic_lighting_time_end_evening.split(':')[0] + | int + (dynamic_lighting_time_end_evening.split(':')[1] | int + / 60) %} {% if end_time_morning < start_time_morning %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_morning + = end_time_morning + 24 %}\n {% set start_time_evening = start_time_evening + + 24 %}\n {% set end_time_evening = end_time_evening + 24 %}\n{% + endif %} {% if end_time_evening < start_time_evening %}\n {% + if current_time < end_time_evening %}\n {% set current_time + = current_time + 24 %}\n {% endif %}\n {% set end_time_evening + = end_time_evening + 24 %}\n{% endif %} {% set lights_on = expand(light_entities) + | selectattr('state', '==', 'on') | list | count > 0 %} {% set + in_morning = start_time_morning <= current_time <= end_time_morning + %} {% set in_evening = start_time_evening <= current_time <= end_time_evening + %} {{ lights_on and not (in_morning or in_evening) }}\n" + - choose: + - alias: Stop when crossing over + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + not in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - stop: Stop the automation + - alias: Adjust the lights settings when crossing over if lights are + ON is selected in night light control + conditions: + - condition: template + value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over'' + in include_night_light_control }}' + - condition: trigger + id: + - t12 + - t13 + - t14 + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: Adjust the light settings when all bypasses are off or state + control is enabled, and the entity is turned ON + conditions: + - condition: trigger + id: + - t15 + - t8_on + - t8_off + - t8_stop + - condition: template + value_template: '{{ repeat.index == 1 }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' + - alias: Dynamic lighting heartbeat + delay: + minutes: !input dynamic_lighting_heartbeat + - alias: If time is outside the adjustment zone and the lights are + ON + conditions: '{{ should_wait }}' + sequence: + - choose: + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_morning + before: !input dynamic_lighting_time_start_evening + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_evening + - conditions: + - condition: time + after: !input dynamic_lighting_time_end_evening + before: !input dynamic_lighting_time_start_morning + sequence: + - wait_for_trigger: + - trigger: time + at: !input dynamic_lighting_time_start_morning + - alias: Set the dynamic lighting brightness for the normal lights + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''enable_time_controled_colour_brightness'' + }}' + sequence: + - action: light.turn_on + target: + entity_id: '{{ light_entities }}' + data: '{{ dynamic_light_data }}' - alias: Dynamic lighting heartbeat delay: minutes: !input dynamic_lighting_heartbeat - stop: Stop the automation - sequence: - choose: - - alias: Set the transition for the normal lights switch + - alias: Turn ON lights 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) }}' + - alias: Check the dynamic lighting options + condition: or + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting == ''disable_dynamic_lighting'' + }}' + - alias: Check that dynamic lighting is active and the state control option + is enabled + condition: and + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: '{{ dynamic_lighting_state_control == ''enable_state_control'' + }}' + - condition: template + value_template: '{{ states(dynamic_lighting_state_control_entity) + == dynamic_lighting_state_control_activation_state_inv }}' sequence: - - service: light.turn_on + - action: 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 + data: '{{ light_data }}' + - choose: + - alias: Dynamic Lighting State Control Turning OFF conditions: + - condition: trigger + id: t16 - 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) }}' + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' sequence: - - service: light.turn_on + - action: 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 }}' + entity_id: '{{ light_entities }}' + data: '{{ light_data }}' + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean - choose: - alias: Check if normal lights scenes or scripts helper is on - This is for scenes only when crossing over @@ -5782,19 +8814,33 @@ action: elif is_state(night_boolean_scenes_scripts, 'on') %}\n true\n{% else %}\n false\n{% endif %}" sequence: + - alias: Turn off the boolean for scenes and scripts + action: input_boolean.turn_off + data: + entity_id: '{{ night_boolean_scenes_scripts }}' + - choose: + - alias: Check if normal lights scenes or scripts helper is on - This + is for scenes only when crossing over + conditions: + - '{{ boolean_scenes_scripts != [] }}' + sequence: + - alias: Turn on the boolean for scenes and scripts + action: input_boolean.turn_on + data: + entity_id: '{{ boolean_scenes_scripts_helper }}' - alias: If transition is selected conditions: - condition: template value_template: '{{ ''use_transition'' in include_light_control }}' sequence: - alias: Turn on the scenes - service: scene.turn_on + action: scene.turn_on target: entity_id: '{{ scene_entities }}' data: - transition: '{{ transition_on_value }}' + transition: '{{ light_transition_on }}' - alias: Turn on the boolean for scenes and scripts - service: input_boolean.turn_on + action: input_boolean.turn_on data: entity_id: '{{ boolean_scenes_scripts_helper }}' - alias: If transition is not selected @@ -5803,23 +8849,23 @@ action: value_template: '{{ ''use_transition'' not in include_light_control }}' sequence: - alias: Turn on the scenes - service: scene.turn_on + action: scene.turn_on target: entity_id: '{{ scene_entities }}' - alias: Turn on the boolean for scenes and scripts - service: input_boolean.turn_on + action: input_boolean.turn_on data: entity_id: '{{ boolean_scenes_scripts_helper }}' - alias: Turn on the switches - service: switch.turn_on + action: switch.turn_on target: entity_id: '{{ switch_entities_off }}' - alias: Turn on the scripts - service: script.turn_on + action: script.turn_on target: entity_id: '{{ script_entities }}' - choose: - - alias: By-pass is enabled & check by-pass option - turn lights on + - alias: By-pass is enabled & check by-pass option - Turn lights on conditions: - condition: trigger id: t7_on @@ -5846,7 +8892,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_on - sequence: - choose: @@ -5857,7 +8903,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_off - sequence: - choose: @@ -5868,7 +8914,7 @@ action: }}' sequence: - alias: Turn off the by-pass - service: homeassistant.turn_off + action: homeassistant.turn_off entity_id: !input motion_bypass_lights_stop - stop: Stop the automation else: @@ -5883,13 +8929,27 @@ action: sequence: - alias: Wait until motion sensor is off wait_for_trigger: - platform: state + - trigger: state entity_id: !input motion_trigger from: 'on' to: 'off' - alias: Wait the number of minutes set in the normal lights time delay delay: minutes: !input time_delay + - choose: + - alias: Dynamic Lighting - Check if Input Boolean Helper is ON + conditions: + - condition: template + value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting'' + }}' + - condition: template + value_template: "{% if dynamic_lighting_boolean != [] %}\n {{ is_state(dynamic_lighting_boolean, + 'on') }}\n{% endif %}" + sequence: + - alias: Turn off the boolean for dynamic lighting + action: input_boolean.turn_off + data: + entity_id: !input dynamic_lighting_boolean - choose: - alias: If transition is selected conditions: @@ -5897,38 +8957,38 @@ action: value_template: '{{ ''use_transition'' in include_light_control }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' data: - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - transition: '{{ transition_off_value }}' + transition: '{{ light_transition_off }}' - alias: If transition is not selected conditions: - condition: template value_template: '{{ ''use_transition'' not in include_light_control }}' sequence: - alias: Turn off the lights - service: light.turn_off + action: light.turn_off target: entity_id: '{{ light_entities }}' - alias: Turn off the scenes - service: scene.turn_on + action: scene.turn_on data: entity_id: '{{ end_scene_entities }}' - alias: Turn off the switches - service: switch.turn_off + action: switch.turn_off target: entity_id: '{{ switch_entities }}' - alias: Turn off the script - service: script.turn_on + action: script.turn_on data: entity_id: '{{ end_script_entities }}' - alias: Turn off the boolean for scenes and scripts - service: input_boolean.turn_off + action: input_boolean.turn_off data: entity_id: !input boolean_scenes_scripts