diff --git a/blueprints/automation/Blackshome/sensor-light.yaml b/blueprints/automation/Blackshome/sensor-light.yaml
new file mode 100644
index 0000000..a691da9
--- /dev/null
+++ b/blueprints/automation/Blackshome/sensor-light.yaml
@@ -0,0 +1,5934 @@
+blueprint:
+ name: Sensor Light
+ description: "# \U0001F4A1 Sensor Light\n**Version: 6.5**\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/)
+ or [schedules](https://www.home-assistant.io/integrations/schedule) to trigger
+ the automation.\n - A trigger sensor, such as a Motion Sensor, will activate
+ lights, switches, scenes, and scripts when the automation is triggered.\n -
+ A time delay begins the turning OFF process after all triggers are clear. See
+ [grouping](https://community.home-assistant.io/t/481048/34) sensors for more information.\n
+ \ - If triggers are activated again before the time delay ends, the automation
+ resets for continuous lighting.\n\n - **Scene and Script Integration:**\n -
+ Scenes or scripts offer additional customization for your spaces.\n\n - **Light
+ Control Options:**\n - Utilize \"Light Control\" to adjust brightness, colour
+ temperature, 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)
+ 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"
+ domain: automation
+ input:
+ motion_trigger:
+ name: Trigger Sensor - Binary Sensors - Schedule *
+ description: 'The trigger sensors are responsible for turning the lights, switches,
+ scenes, and scripts ON and OFF. You can choose any [binary sensors](https://www.home-assistant.io/integrations/binary_sensor/)
+ you prefer as triggers. Alternatively, if you prefer a time-based trigger,
+ you can also add a [schedule helper](https://community.home-assistant.io/t/481048/1616).
+
+
+ When using multiple trigger sensors, it''s advisable to group them together
+ using a group helper. This ensures smoother automation execution and prevents
+ conflicts.
+
+
+ For more information on grouping your trigger sensors [Click Here](https://community.home-assistant.io/t/481048/34)'
+ selector:
+ entity:
+ filter:
+ - domain:
+ - binary_sensor
+ - schedule
+ multiple: true
+ light_switch:
+ name: Lights - Switches - Scenes - Scripts *
+ description: 'The lights, switches, scenes, and scripts that will be activated
+ by the trigger sensor/s. If adding a scene or script, please refer to the
+ ''Scenes & Scripts - Toggle Helper'' section and the ''Scenes - Scripts To
+ Turn OFF'' section below.
+
+
+ For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595)
+
+
+ **NOTE** - You can only use entities. Areas and devices are not supported.'
+ selector:
+ target:
+ entity:
+ - domain:
+ - light
+ - switch
+ - scene
+ - script
+ boolean_scenes_scripts:
+ name: Scenes & Scripts - Toggle Helper
+ description: To ensure the smooth operation of the automation, it's recommended
+ to create an independent toggle helper when selecting a scene or script in
+ "Lights - Switches - Scenes - Scripts" above and then enter it here.
+ default: []
+ selector:
+ entity:
+ filter:
+ - domain:
+ - input_boolean
+ 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.
+
+
+ 1 - Lux Controlled Brightness
+
+ 2 - Lux Controlled Brightness - Inverted
+
+ 3 - Sun Elevation Lighting - Colour Temp
+
+ 4 - Sun Elevation Lighting - Brightness
+
+ 5 - Sun Elevation Lighting - Brightness - Inverted
+
+ 6 - Sun Elevation Lighting - Colour Temp + Brightness
+
+ 7 - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness
+
+
+ A numbering system has been implemented to facilitate navigation within the
+ dropdown selections. Each number corresponds to a specific configuration,
+ aiding users in identifying and adjusting the settings used within each selection.
+ For instance, when selecting "3 - Sun Elevation Lighting - Colour Temp" as
+ a dropdown option, settings marked "Used in options 3, 6 or 7" are required
+ for that respective selection because number 3 is included in those options.
+
+
+ For more information on dynamic lighting settings [Click Here](https://community.home-assistant.io/t/481048/837)'
+ default: disable_dynamic_lighting
+ selector:
+ select:
+ mode: dropdown
+ options:
+ - label: Disable Dynamic Lighting
+ value: disable_dynamic_lighting
+ - label: 1 - Lux Controlled Brightness
+ value: enable_lux_controled_brightness
+ - label: 2 - Lux Controlled Brightness - Inverted
+ value: enable_lux_controled_brightness_inv
+ - label: 3 - Sun Elevation Lighting - Colour Temp
+ value: enable_sun_elevation_colour
+ - label: 4 - Sun Elevation Lighting - Brightness
+ value: enable_sun_elevation_brightness
+ - label: 5 - Sun Elevation Lighting - Brightness - Inverted
+ value: enable_sun_elevation_brightness_inv
+ - label: 6 - Sun Elevation Lighting - Colour Temp + Brightness
+ value: enable_sun_elevation_colour_brightness
+ - label: 7 - Sun Elevation Lighting - Colour Temp + Lux Brightness
+ value: enable_sun_elevation_colour_lux_brightness
+ 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 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.
+
+
+ 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 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.
+
+
+ **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.
+
+
+ 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:
+ name: Night Lights
+ description: 'The lights, switches, scenes, and scripts that will be activated
+ by the trigger sensor/s. If adding a scene or script, please refer to the
+ ''Night Lights - Scenes & Scripts - Toggle Helper'' section below and the
+ ''Scenes - Scripts To Turn OFF'' section above.
+
+
+ For more information on how to use scenes & scripts [Click Here](https://community.home-assistant.io/t/481048/1595)
+
+
+ **NOTE** - You can only use entities. Areas and devices are not supported.'
+ default: {}
+ selector:
+ target:
+ entity:
+ - domain:
+ - light
+ - switch
+ - scene
+ - script
+ night_boolean_scenes_scripts:
+ name: Night Lights - Scenes & Scripts - Toggle Helper
+ description: To ensure the smooth operation of the automation, it's recommended
+ to create an independent toggle helper when selecting a scene or script in
+ "Night Lights" above and then enter it here.
+ default: []
+ selector:
+ entity:
+ filter:
+ - domain:
+ - input_boolean
+ 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.
+
+
+ Selecting ''If lights are ON, adjust the lights when crossing over'' option
+ ensures that the light control settings will be applied to any lights that
+ are already ON during the transition from normal lights to night lights and
+ vice versa.
+
+
+ Selecting ''Yes - Manage OFF script when crossing over'' is beneficial for
+ scripts containing if-then-else actions that toggle various functions on and
+ off during the transition from normal lights to night lights and vice versa.'
+ default: []
+ selector:
+ select:
+ multiple: true
+ options:
+ - label: Use brightness
+ value: use_brightness
+ - label: Use colour temperature
+ value: use_colour_temperature
+ - label: Use transition
+ value: use_transition
+ - label: If lights are ON, adjust the lights when crossing over
+ value: if_lights_are_on_adjust_when_crossing_over
+ - label: Yes - Manage OFF script when crossing over
+ value: manage_scripts_crossing_over
+ 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.
+
+
+ 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
+ source_url: https://gist.github.com/Blackshome/6edfec0ff6a25c5da0d07b88dc908238
+mode: restart
+max_exceeded: silent
+variables:
+ motion_trigger: !input motion_trigger
+ light_switch: !input light_switch
+ boolean_scenes_scripts: !input boolean_scenes_scripts
+ end_scenes: !input end_scenes
+ time_delay: !input time_delay
+ include_light_control: !input include_light_control
+ light_brightness: !input light_brightness
+ brightness_value: '{{ iif (''use_brightness'' in include_light_control , light_brightness,
+ ) }}'
+ light_colour_temperature: !input light_colour_temperature
+ temperature_value: '{{ iif (''use_colour_temperature'' in include_light_control
+ , light_colour_temperature, [] ) }}'
+ light_transition_on: !input light_transition_on
+ light_transition_off: !input light_transition_off
+ transition_on_value: '{{ iif (''use_transition'' in include_light_control, light_transition_on,
+ ) }}'
+ transition_off_value: '{{ iif (''use_transition'' in include_light_control, light_transition_off,
+ ) }}'
+ include_dynamic_lighting: !input include_dynamic_lighting
+ dynamic_lighting_lux_sensor: !input dynamic_lighting_lux_sensor
+ dynamic_lighting_max_lux: !input dynamic_lighting_max_lux
+ dynamic_lighting_min_lux: !input dynamic_lighting_min_lux
+ dynamic_lighting_max_brightness: !input dynamic_lighting_max_brightness
+ dynamic_lighting_min_brightness: !input dynamic_lighting_min_brightness
+ dynamic_lighting_max_colour_temp: !input dynamic_lighting_max_colour_temp
+ dynamic_lighting_min_colour_temp: !input dynamic_lighting_min_colour_temp
+ dynamic_lighting_sun_elevation_start_rising: !input dynamic_lighting_sun_elevation_start_rising
+ dynamic_lighting_sun_elevation_end_rising: !input dynamic_lighting_sun_elevation_end_rising
+ dynamic_lighting_sun_elevation_start_falling: !input dynamic_lighting_sun_elevation_start_falling
+ dynamic_lighting_sun_elevation_end_falling: !input dynamic_lighting_sun_elevation_end_falling
+ dynamic_lighting_heartbeat: !input dynamic_lighting_heartbeat
+ dynamic_lighting_step_value: !input dynamic_lighting_step_value
+ dynamic_lighting_dead_zone: !input dynamic_lighting_dead_zone
+ include_bypass: !input include_bypass
+ motion_bypass_lights_on: !input motion_bypass_lights_on
+ motion_bypass_lights_off: !input motion_bypass_lights_off
+ motion_bypass_lights_stop: !input motion_bypass_lights_stop
+ bypass_time_delay: !input bypass_time_delay
+ include_bypass_auto_off: !input include_bypass_auto_off
+ bypass_auto_off_delay: !input bypass_auto_off_delay
+ include_sun: !input include_sun
+ sun_elevation: !input sun_elevation
+ sun_elevation_rising: !input sun_elevation_rising
+ include_ambient: !input include_ambient
+ ambient_light_sensor: !input ambient_light_sensor
+ ambient_light_options: !input ambient_light_options
+ ambient_light_value: !input ambient_light_value
+ ambient_light_high_value: !input ambient_light_high_value
+ include_time: !input include_time
+ after_time: !input after_time
+ before_time: !input before_time
+ weekday_options: !input weekday_options
+ include_device_tracker: !input include_device_tracker
+ zone: !input zone
+ people: !input people
+ include_night_lights: !input include_night_lights
+ night_lights: !input night_lights
+ night_boolean_scenes_scripts: !input night_boolean_scenes_scripts
+ night_time_delay: !input night_time_delay
+ include_night_light_control: !input include_night_light_control
+ night_light_brightness: !input night_light_brightness
+ night_brightness_value: '{{ iif (''use_brightness'' in include_night_light_control
+ , night_light_brightness, ) }}'
+ night_light_colour_temperature: !input night_light_colour_temperature
+ night_temperature_value: '{{ iif (''use_colour_temperature'' in include_night_light_control
+ , night_light_colour_temperature, [] ) }}'
+ night_light_transition_on: !input night_light_transition_on
+ night_light_transition_off: !input night_light_transition_off
+ night_transition_on_value: '{{ iif (''use_transition'' in include_night_light_control,
+ night_light_transition_on, ) }}'
+ night_transition_off_value: '{{ iif (''use_transition'' in include_night_light_control,
+ night_light_transition_off, ) }}'
+ night_lights_conditions: !input night_lights_conditions
+ night_lights_entity_state: !input night_lights_entity_state
+ night_lights_after_time: !input night_lights_after_time
+ night_lights_before_time: !input night_lights_before_time
+ night_lights_sun_elevation: !input night_lights_sun_elevation
+ night_lights_sun_elevation_rising: !input night_lights_sun_elevation_rising
+ 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 }}'
+ scene_entities: "{% set a = light_switch.entity_id %} {% if boolean_scenes_scripts
+ == [] %}\n {{ expand(a) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id')
+ | list }}\n{% elif is_state(boolean_scenes_scripts, 'off') %}\n {{ expand(a)
+ | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id') | list }}\n{%
+ else %}\n []\n{% endif %}"
+ script_entities: "{% set a = light_switch.entity_id %} {% if boolean_scenes_scripts
+ == [] %}\n {{ expand(a) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id')
+ | list }}\n{% elif is_state(boolean_scenes_scripts, 'off') %}\n {{ expand(a)
+ | selectattr('domain', 'eq', 'script') | map(attribute='entity_id') | list }}\n{%
+ else %}\n []\n{% endif %}"
+ boolean_scenes_scripts_helper: "{% if boolean_scenes_scripts | length > 0 and states(boolean_scenes_scripts)
+ == 'off' %}\n {{ boolean_scenes_scripts }}\n{% else %}\n []\n{% endif %}"
+ end_scene_entities: '{{ end_scenes | select(''match'', ''^scene\..*'') | list }}'
+ end_script_entities: '{{ end_scenes | select(''match'', ''^script\..*'') | list
+ }}'
+ night_light_entities_off: "{% set b = night_lights and night_lights.entity_id %}
+ {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state',
+ 'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
+ %}"
+ night_switch_entities_off: "{% set b = night_lights and night_lights.entity_id
+ %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | selectattr('state',
+ 'eq', 'off') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
+ %}"
+ night_light_entities: "{% set b = night_lights and night_lights.entity_id %} {%
+ if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id')
+ | list }}\n{% else %}\n []\n{% endif %}"
+ night_switch_entities: "{% set b = night_lights and night_lights.entity_id %} {%
+ if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'switch') | map(attribute='entity_id')
+ | list }}\n{% else %}\n []\n{% endif %}"
+ night_scene_entities: "{% set b = night_lights and night_lights.entity_id %} {%
+ if night_boolean_scenes_scripts == [] %}\n {{ expand(b) | selectattr('domain',
+ 'eq', 'scene') | map(attribute='entity_id') | list }}\n{% elif is_state(night_boolean_scenes_scripts,
+ 'off') %}\n {{ expand(b) | selectattr('domain', 'eq', 'scene') | map(attribute='entity_id')
+ | list }}\n{% else %}\n []\n{% endif %}"
+ night_script_entities: "{% set b = night_lights and night_lights.entity_id %} {%
+ if night_boolean_scenes_scripts == [] %}\n {{ expand(b) | selectattr('domain',
+ 'eq', 'script') | map(attribute='entity_id') | list }}\n{% elif is_state(night_boolean_scenes_scripts,
+ 'off') %}\n {{ expand(b) | selectattr('domain', 'eq', 'script') | map(attribute='entity_id')
+ | list }}\n{% else %}\n []\n{% endif %}"
+ night_boolean_scenes_scripts_helper: "{% if night_boolean_scenes_scripts | length
+ > 0 and states(night_boolean_scenes_scripts) == 'off' %}\n {{ night_boolean_scenes_scripts
+ }}\n{% else %}\n []\n{% endif %}"
+ 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')
+ | 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')
+ | list }}\n{% else %}\n []\n{% endif %}"
+ crossover_night_lights_light_on: "{% set b = night_lights and night_lights.entity_id
+ %} {% if b %}\n {{ expand(b) | selectattr('domain', 'eq', 'light') | selectattr('state',
+ 'eq', 'on') | map(attribute='entity_id') | list }}\n{% else %}\n []\n{% endif
+ %}"
+ crossover_night_lights_light: "{% set a = light_switch.entity_id %} {% set b = night_lights
+ and night_lights.entity_id %} {% if a and b %}\n {{ expand(b) | reject('in',
+ expand(a)) | selectattr('domain', 'eq', 'light') | 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 %}"
+ 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
+ id: t0
+ entity_id: !input motion_trigger
+ from: 'off'
+ to: 'on'
+- platform: numeric_state
+ id: t1
+ entity_id: sun.sun
+ attribute: elevation
+ below: !input sun_elevation
+- platform: numeric_state
+ id: t2
+ entity_id: !input ambient_light_sensor
+ below: !input ambient_light_value
+- platform: time
+ id: t3
+ at: !input after_time
+- platform: state
+ id: t4
+ entity_id: !input night_lights_entity_state
+ from: 'off'
+ to: 'on'
+- platform: time
+ id: t5
+ at: !input night_lights_after_time
+- platform: numeric_state
+ id: t6
+ entity_id: sun.sun
+ attribute: elevation
+ below: !input night_lights_sun_elevation
+- platform: state
+ id: t7_on
+ entity_id: !input motion_bypass_lights_on
+ from: 'off'
+ to: 'on'
+- platform: state
+ id: t7_off
+ entity_id: !input motion_bypass_lights_off
+ from: 'off'
+ to: 'on'
+- platform: state
+ id: t7_stop
+ entity_id: !input motion_bypass_lights_stop
+ from: 'off'
+ to: 'on'
+- platform: state
+ id: t8_on
+ entity_id: !input motion_bypass_lights_on
+ from: 'on'
+ to: 'off'
+- platform: state
+ id: t8_off
+ entity_id: !input motion_bypass_lights_off
+ from: 'on'
+ to: 'off'
+- platform: state
+ id: t8_stop
+ entity_id: !input motion_bypass_lights_stop
+ from: 'on'
+ to: 'off'
+- platform: numeric_state
+ id: t9
+ entity_id: sun.sun
+ attribute: elevation
+ above: !input sun_elevation_rising
+- platform: numeric_state
+ id: t10
+ entity_id: !input ambient_light_sensor
+ above: !input ambient_light_high_value
+- platform: time
+ id: t11
+ at: !input before_time
+- platform: state
+ id: t12
+ entity_id: !input night_lights_entity_state
+ from: 'on'
+ to: 'off'
+- platform: time
+ id: t13
+ at: !input night_lights_before_time
+- platform: numeric_state
+ id: t14
+ entity_id: sun.sun
+ attribute: elevation
+ above: !input night_lights_sun_elevation_rising
+- platform: homeassistant
+ id: t15
+ event: start
+condition:
+- condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ match: any
+ state: 'on'
+ - condition: trigger
+ id: t0
+ - condition: and
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ state: 'on'
+ match: any
+ - '{{ include_sun == ''sun_enabled'' }}'
+ - condition: trigger
+ id: t1
+ - condition: and
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ state: 'on'
+ match: any
+ - '{{ include_ambient == ''ambient_enabled'' }}'
+ - condition: trigger
+ id: t2
+ - condition: and
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ state: 'on'
+ match: any
+ - '{{ include_time == ''time_enabled'' }}'
+ - condition: trigger
+ id: t3
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t4
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''entity_state_enabled'' in night_lights_conditions }}'
+ - condition: state
+ entity_id: !input night_lights_entity_state
+ match: any
+ state: 'on'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t5
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''time_enabled'' in night_lights_conditions }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t6
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''sun_enabled'' in night_lights_conditions }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t7_on
+ - '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t7_off
+ - '{{ ''bypass_enabled_turn_off'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t7_stop
+ - '{{ ''bypass_enabled_stop'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t8_on
+ - '{{ ''bypass_enabled_turn_on'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t8_off
+ - '{{ ''bypass_enabled_turn_off'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t8_stop
+ - '{{ ''bypass_enabled_stop'' in include_bypass }}'
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t9
+ - '{{ include_sun == ''sun_enabled'' }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - 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: and
+ conditions:
+ - condition: trigger
+ id: t10
+ - '{{ include_ambient == ''ambient_enabled'' }}'
+ - '{{ ambient_light_options == ''ambient_light_option_disabled'' }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - 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: and
+ conditions:
+ - condition: trigger
+ id: t11
+ - '{{ include_time == ''time_enabled'' }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - 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: and
+ conditions:
+ - condition: trigger
+ id: t12
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''entity_state_enabled'' in night_lights_conditions }}'
+ - condition: state
+ entity_id: !input night_lights_entity_state
+ state: 'off'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t13
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''time_enabled'' in night_lights_conditions }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t14
+ - '{{ include_night_lights == ''night_lights_enabled'' }}'
+ - '{{ ''sun_enabled'' in night_lights_conditions }}'
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: t15
+ - condition: or
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) }}'
+ - '{{ (include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\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: and
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ match: any
+ state: 'on'
+ - condition: trigger
+ id: t15
+ - condition: and
+ conditions:
+ - '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_off''
+ in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ - condition: trigger
+ id: t15
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+- condition: or
+ conditions:
+ - '{{ include_bypass == [] }}'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass) }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: trigger
+ id:
+ - t7_on
+ - t7_off
+ - t7_stop
+ - t8_on
+ - t8_off
+ - t8_stop
+ - t15
+- condition: or
+ conditions:
+ - '{{ include_sun == ''sun_disabled'' }}'
+ - '{{ include_sun == ''sun_enabled_night_lights'' }}'
+ - '{{ (include_sun == ''sun_enabled'') and (is_state_attr(''sun.sun'', ''rising'',
+ false)) and (state_attr(''sun.sun'',''elevation'') <= sun_elevation | float(90))
+ }}'
+ - '{{ (include_sun == ''sun_enabled'') and (is_state_attr(''sun.sun'', ''rising'',
+ true)) and (state_attr(''sun.sun'',''elevation'') <= sun_elevation_rising | float(90))
+ }}'
+ - condition: trigger
+ id:
+ - t7_on
+ - t7_off
+ - t7_stop
+ - t8_on
+ - t8_off
+ - t8_stop
+ - t9
+- condition: or
+ conditions:
+ - '{{ include_ambient == ''ambient_disabled'' }}'
+ - '{{ ambient_light_sensor == [] }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (states[ambient_light_sensor].state
+ | int < ambient_light_value | int) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (states[ambient_light_sensor].state
+ | int < ambient_light_high_value | int) and (expand(light_switch.entity_id) |
+ selectattr(''state'', ''=='', ''on'') | list | count > 0) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (states[ambient_light_sensor].state
+ | int < ambient_light_high_value | int) and ((include_night_lights == ''night_lights_enabled'')
+ and (expand(night_lights.entity_id) | selectattr(''state'', ''=='', ''on'') |
+ list | count > 0)) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options == ''ambient_light_option_enabled'')
+ and (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'') |
+ list | count > 0) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options == ''ambient_light_option_enabled'')
+ and ((include_night_lights == ''night_lights_enabled'') and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''on'') | list | count > 0)) }}'
+ - condition: and
+ conditions:
+ - '{{ (include_ambient == ''ambient_enabled'') and (states[ambient_light_sensor].state
+ | int < ambient_light_high_value | int) }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\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) }}'
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - '{{ (include_ambient == ''ambient_enabled'') and ( ambient_light_options ==
+ ''ambient_light_option_enabled'' ) }}'
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts != [] %}\n {{ is_state(boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: and
+ conditions:
+ - '{{ (include_ambient == ''ambient_enabled'') and ( ambient_light_options ==
+ ''ambient_light_option_enabled'' ) }}'
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts != [] %}\n {{ is_state(night_boolean_scenes_scripts,
+ 'on') }}\n{% endif %}"
+ - condition: trigger
+ id:
+ - t7_on
+ - t7_off
+ - t7_stop
+ - t8_on
+ - t8_off
+ - t8_stop
+ - t10
+- condition: or
+ conditions:
+ - '{{ include_time == ''time_disabled'' }}'
+ - condition: and
+ conditions:
+ - condition: time
+ after: !input after_time
+ before: !input before_time
+ weekday: !input weekday_options
+ - '{{ include_time == ''time_enabled'' }}'
+ - condition: trigger
+ id:
+ - t7_on
+ - t7_off
+ - t7_stop
+ - t8_on
+ - t8_off
+ - t8_stop
+ - t11
+- condition: or
+ conditions:
+ - '{{ include_device_tracker == ''device_tracker_disabled'' }}'
+ - condition: and
+ conditions:
+ - condition: numeric_state
+ entity_id: !input zone
+ above: 0
+ - '{{ include_device_tracker == ''zone_enabled'' }}'
+ - condition: and
+ conditions:
+ - '{{ (state_attr(zone, ''persons'') + people) | count != dict.fromkeys(state_attr(zone,
+ ''persons'') + people) | count }}'
+ - '{{ include_device_tracker == ''zone_people_enabled'' }}'
+ - condition: trigger
+ id:
+ - t7_on
+ - t7_off
+ - t7_stop
+ - t8_on
+ - t8_off
+ - t8_stop
+action:
+- choose:
+ - alias: Check if the night lights are enabled and within the night lights conditions
+ conditions:
+ - condition: and
+ conditions:
+ - alias: Check if night lights is enabled
+ condition: or
+ conditions:
+ - '{{ ''night_lights_enabled'' in include_night_lights }}'
+ - alias: Check if night lights entity state is enabled
+ condition: or
+ conditions:
+ - '{{ (''time_enabled'' in night_lights_conditions) and not (''entity_state_enabled''
+ in night_lights_conditions) }}'
+ - '{{ (''sun_enabled'' in night_lights_conditions) and not (''entity_state_enabled''
+ in night_lights_conditions) }}'
+ - condition: and
+ conditions:
+ - '{{ ''entity_state_enabled'' in night_lights_conditions }}'
+ - condition: state
+ entity_id: !input night_lights_entity_state
+ state: 'on'
+ match: any
+ - alias: Check if night lights time is enabled
+ condition: or
+ conditions:
+ - '{{ (''entity_state_enabled'' in night_lights_conditions) and not (''time_enabled''
+ in night_lights_conditions) }}'
+ - '{{ (''sun_enabled'' in night_lights_conditions) and not (''time_enabled''
+ in night_lights_conditions) }}'
+ - condition: and
+ conditions:
+ - '{{ ''time_enabled'' in night_lights_conditions }}'
+ - condition: time
+ after: !input night_lights_after_time
+ before: !input night_lights_before_time
+ - alias: Check if night lights sun is enabled
+ condition: or
+ conditions:
+ - '{{ (''entity_state_enabled'' in night_lights_conditions) and not (''sun_enabled''
+ in night_lights_conditions) }}'
+ - '{{ (''time_enabled'' in night_lights_conditions) and not (''sun_enabled''
+ in night_lights_conditions) }}'
+ - '{{ (''sun_enabled'' in night_lights_conditions) and (((is_state_attr(''sun.sun'',
+ ''rising'', false)) and (state_attr(''sun.sun'',''elevation'') <= night_lights_sun_elevation
+ | float(90))) or ((is_state_attr(''sun.sun'', ''rising'', true)) and (state_attr(''sun.sun'',''elevation'')
+ <= night_lights_sun_elevation_rising | float(90)))) }}'
+ sequence:
+ - choose:
+ - alias: By-pass is turned on & check by-pass option - turn lights off
+ conditions:
+ - condition: trigger
+ id: t7_off
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ night_switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
+ in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - alias: By-pass is turned on & check by-pass option - Keep the current lights
+ state
+ conditions:
+ - condition: trigger
+ id: t7_stop
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
+ in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - choose:
+ - alias: By-pass is turned off & check if the motion trigger is off
+ conditions:
+ - condition: trigger
+ id:
+ - t8_on
+ - t8_off
+ - t8_stop
+ - condition: state
+ entity_id: !input motion_trigger
+ match: all
+ state: 'off'
+ sequence:
+ - choose:
+ - alias: Check all by-pass are off
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ night_switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - stop: Stop the automation
+ - alias: Motion trigger is off and check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time
+ delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - alias: By-pass is turned off & check if the motion trigger is on
+ conditions:
+ - condition: trigger
+ id:
+ - t8_on
+ - t8_off
+ - t8_stop
+ - condition: state
+ entity_id: !input motion_trigger
+ match: any
+ state: 'on'
+ sequence:
+ - choose:
+ - alias: 'Check all by-pass are off and check conditions if enabled '
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: or
+ conditions:
+ - '{{ (include_sun == ''sun_enabled'') and (state_attr(''sun.sun'',''elevation'')
+ >= sun_elevation | float(90)) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_disabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) and (expand(night_lights.entity_id)
+ | selectattr(''state'', ''=='', ''off'') | list | count > 0) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) and (is_state(night_boolean_scenes_scripts,
+ ''off'')) }}'
+ - condition: and
+ conditions:
+ - condition: time
+ after: !input before_time
+ before: !input after_time
+ - '{{ include_time == ''time_enabled'' }}'
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ night_switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - stop: Stop the automation
+ - alias: Motion trigger is on and check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time
+ delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - choose:
+ - alias: Sun, Ambient Light Sensor & time above setting to turn off
+ conditions:
+ - condition: trigger
+ id:
+ - t9
+ - t10
+ - t11
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ night_switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the input boolean night lights
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - stop: Stop the automation
+ - alias: Turn off normal lights when trigger by start night lights conditions
+ conditions:
+ - condition: trigger
+ id:
+ - t4
+ - t5
+ - t6
+ sequence:
+ - choose:
+ - alias: light - switch - scene - script is ON
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''on'') | list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
+ ''=='', ''on'') | list | count > 0) or (is_state(boolean_scenes_scripts,
+ ''on'')) }}'
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ crossover_lights_light }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ crossover_lights_light }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ crossover_lights_switch }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - choose:
+ - alias: If adjust light settings when crossing over if lights are ON
+ is selected in night light control
+ conditions:
+ - condition: template
+ value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
+ in include_night_light_control }}'
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the input boolean normal lights
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - choose:
+ - alias: Set the transition and brightness for the night lights
+ switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and
+ (''use_colour_temperature'' not in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ brightness_pct: '{{ night_brightness_value }}'
+ - alias: Set the transition and colour temperature for the night
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control)
+ and (''use_colour_temperature'' in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the transition, brightness and colour temperature for
+ the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and
+ (''use_colour_temperature'' in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ brightness_pct: '{{ night_brightness_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the brightness for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and
+ (''use_colour_temperature'' not in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ brightness_pct: '{{ night_brightness_value }}'
+ - alias: Set the colour temperature for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control)
+ and (''use_colour_temperature'' in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the brightness and colour temperature for the night
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and
+ (''use_colour_temperature'' in include_night_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_night_lights_light_on }}'
+ data:
+ brightness_pct: '{{ night_brightness_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: light - switch - scene - script is ON
+ conditions:
+ - '{{ ''manage_scripts_crossing_over'' in include_night_light_control
+ }}'
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
+ ''=='', ''off'') | list | count > 0) or (is_state(boolean_scenes_scripts,
+ ''off'')) }}'
+ sequence:
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - stop: Stop the automation
+ - alias: Safe Guard when HA restarts
+ conditions:
+ - condition: trigger
+ id: t15
+ sequence:
+ - choose:
+ - alias: 'Check all by-pass are off and check conditions if enabled '
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ sequence:
+ - alias: Small time delay required
+ delay:
+ seconds: 1
+ - alias: Check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass auto off is enabled and preform the correct
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time
+ delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - choose:
+ - alias: Set the transition for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control) and (''use_colour_temperature''
+ not in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ - alias: Set the transition and brightness for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and (''use_colour_temperature''
+ not in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ brightness_pct: '{{ night_brightness_value }}'
+ - alias: Set the transition and colour temperature for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control) and (''use_colour_temperature''
+ in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the transition, brightness and colour temperature for the night
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and (''use_colour_temperature''
+ in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ transition: '{{ night_transition_on_value }}'
+ brightness_pct: '{{ night_brightness_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the brightness for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and (''use_colour_temperature''
+ not in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ brightness_pct: '{{ night_brightness_value }}'
+ - alias: Set the colour temperature for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control) and (''use_colour_temperature''
+ in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the brightness and colour temperature for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' in include_night_light_control) and (''use_colour_temperature''
+ in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ data:
+ brightness_pct: '{{ night_brightness_value }}'
+ kelvin: '{{ night_temperature_value }}'
+ - alias: Set the default for the night lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_night_light_control)
+ and (''use_brightness'' not in include_night_light_control) and (''use_colour_temperature''
+ not in include_night_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ night_light_entities_off }}'
+ - choose:
+ - alias: Check if normal lights scenes or scripts helper is on - This is for
+ scenes only when crossing over
+ conditions:
+ - condition: template
+ value_template: "{% if boolean_scenes_scripts == [] %}\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
+ conditions:
+ - condition: trigger
+ id: t7_on
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
+ in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - choose:
+ - alias: Check if the trigger is on and wait for it to go off
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ state: 'on'
+ match: any
+ sequence:
+ - alias: Wait until motion sensor is off
+ wait_for_trigger:
+ platform: state
+ entity_id: !input motion_trigger
+ from: 'on'
+ to: 'off'
+ - alias: Wait the number of minutes set in the night lights time delay
+ delay:
+ minutes: !input night_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ night_light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ night_switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ default:
+ - choose:
+ - alias: By-pass is turned on & check by-pass option - turn lights off
+ conditions:
+ - condition: trigger
+ id: t7_off
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
+ in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - alias: By-pass is turned on & check by-pass option - Keep the current lights
+ state
+ conditions:
+ - condition: trigger
+ id: t7_stop
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or (''bypass_auto_off_enabled_stop''
+ in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - choose:
+ - alias: By-pass is turned off & check if the motion trigger is off
+ conditions:
+ - condition: trigger
+ id:
+ - t8_on
+ - t8_off
+ - t8_stop
+ - condition: state
+ entity_id: !input motion_trigger
+ match: all
+ state: 'off'
+ sequence:
+ - choose:
+ - alias: Check all by-pass are off
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - stop: Stop the automation
+ - alias: Motion trigger is off and check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
+ (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - alias: By-pass is turned off & check if the motion trigger is on
+ conditions:
+ - condition: trigger
+ id:
+ - t8_on
+ - t8_off
+ - t8_stop
+ - condition: state
+ entity_id: !input motion_trigger
+ match: any
+ state: 'on'
+ sequence:
+ - choose:
+ - alias: 'Check all by-pass are off and check conditions if enabled '
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: or
+ conditions:
+ - '{{ (include_sun == ''sun_enabled'') and (state_attr(''sun.sun'',''elevation'')
+ >= sun_elevation | float(90)) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_disabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) and (expand(light_switch.entity_id)
+ | selectattr(''state'', ''=='', ''off'') | list | count > 0) }}'
+ - '{{ (include_ambient == ''ambient_enabled'') and (ambient_light_options
+ == ''ambient_light_option_enabled'') and (states[ambient_light_sensor].state
+ | int > ambient_light_value | int) and (is_state(boolean_scenes_scripts,
+ ''off'')) }}'
+ - condition: and
+ conditions:
+ - condition: time
+ after: !input before_time
+ before: !input after_time
+ - '{{ include_time == ''time_enabled'' }}'
+ sequence:
+ - alias: Wait the number of minutes set in the by-pass time delay
+ delay:
+ minutes: !input bypass_time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - stop: Stop the automation
+ - alias: Motion trigger is on and check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
+ (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - choose:
+ - alias: Sun, Ambient Light Sensor & time above setting to turn off
+ conditions:
+ - condition: trigger
+ id:
+ - t9
+ - t10
+ - t11
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the input boolean night lights
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
+ - stop: Stop the automation
+ - alias: Turn off night lights when trigger by end night lights conditions
+ conditions:
+ - condition: trigger
+ id:
+ - t12
+ - t13
+ - t14
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''on'')
+ | list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
+ ''=='', ''on'') | list | count > 0) or (is_state(night_boolean_scenes_scripts,
+ ''on'')) }}'
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ crossover_night_lights_light }}'
+ data:
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ crossover_night_lights_light }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ crossover_night_lights_switch }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - choose:
+ - alias: If adjust light settings when crossing over if lights are ON
+ is selected in night light control
+ conditions:
+ - condition: template
+ value_template: '{{ ''if_lights_are_on_adjust_when_crossing_over''
+ in include_night_light_control }}'
+ sequence:
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ night_transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_night_light_control
+ }}'
+ sequence:
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the input boolean night lights
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input night_boolean_scenes_scripts
+ - choose:
+ - alias: Set the transition and brightness for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (''use_brightness'' in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ not in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: '{{ brightness_value }}'
+ - alias: Set the transition and colour temperature for the normal
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: Set the transition, brightness and colour temperature for
+ the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (''use_brightness'' in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: '{{ brightness_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: Set the brightness for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ not in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ brightness_pct: '{{ brightness_value }}'
+ - alias: Set the colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ kelvin: '{{temperature_value}}'
+ - alias: Set the brightness and colour temperature for the normal
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' in include_light_control) and (''enable_lux_controled_brightness''
+ not in include_dynamic_lighting) and (''use_colour_temperature''
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ crossover_lights_light_on }}'
+ data:
+ brightness_pct: '{{ brightness_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: If transition is selected
+ conditions:
+ - '{{ ''manage_scripts_crossing_over'' in include_night_light_control }}'
+ - '{{ (expand(light_switch.entity_id) | selectattr(''state'', ''=='', ''off'')
+ | list | count > 0) or (expand(night_lights.entity_id) | selectattr(''state'',
+ ''=='', ''off'') | list | count > 0) or (is_state(night_boolean_scenes_scripts,
+ ''off'')) }}'
+ sequence:
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - stop: Stop the automation
+ - alias: Safe Guard when HA restarts
+ conditions:
+ - condition: trigger
+ id: t15
+ sequence:
+ - choose:
+ - alias: 'Check all by-pass are off and check conditions if enabled '
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ state: 'off'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ state: 'off'
+ sequence:
+ - alias: Small time delay required
+ delay:
+ seconds: 1
+ - alias: Check if any by-passes are on
+ conditions:
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_on
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ in include_bypass) and (''bypass_enabled_stop'' not in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_off
+ match: any
+ state: 'on'
+ - condition: and
+ conditions:
+ - '{{ (''bypass_enabled_turn_on'' not in include_bypass) and (''bypass_enabled_turn_off''
+ not in include_bypass) and (''bypass_enabled_stop'' in include_bypass)
+ }}'
+ - condition: state
+ entity_id: !input motion_bypass_lights_stop
+ match: any
+ state: 'on'
+ sequence:
+ - alias: Check by-pass auto off is enabled and preform the correct
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
+ (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ - alias: Parallel Actions for dynamic lighting
+ parallel:
+ - sequence:
+ - alias: Check if the dynamic lighting is enabled
+ condition: and
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting != ''disable_dynamic_lighting''
+ }}'
+ - choose:
+ - alias: Set the Dynamic Lux Controlled Brightness for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness''}}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition and dynamic lighting brightness for the
+ normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_lux_controled_brightness'')
+ and (''use_colour_temperature'' not in include_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
+ - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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 transition, dynamic lighting brightness and colour
+ temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_lux_controled_brightness'')
+ and (''use_colour_temperature'' in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
+ - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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}}'
+ - alias: Dynamic lighting heartbeat
+ delay:
+ minutes: !input dynamic_lighting_heartbeat
+ - alias: Set the dynamic lighting brightness for the normal lights
+ switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (include_dynamic_lighting == ''enable_lux_controled_brightness'')
+ and (''use_colour_temperature'' not in include_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
+ - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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}}'
+ - alias: Dynamic lighting heartbeat
+ delay:
+ minutes: !input dynamic_lighting_heartbeat
+ - choose:
+ - alias: Dynamic Lighting - Lux Controlled Brightness - Inverted for the
+ normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_lux_controled_brightness_inv''}}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition and dynamic lighting brightness for the
+ normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_lux_controled_brightness_inv'')
+ and (''use_colour_temperature'' not in include_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_min_lux
+ - dynamic_lighting_max_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_min_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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}}'
+ - alias: Dynamic lighting heartbeat
+ delay:
+ minutes: !input dynamic_lighting_heartbeat
+ - choose:
+ - alias: Dynamic Lighting - Sun Elevation Lighting - Colour Temp for the normal
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour''
+ }}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition and dynamic sun elevation colour temperature
+ for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''enable_sun_elevation_colour'') }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_colour_temp
+ - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope
+ = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_colour_temp %} {% if elevation
+ >= -10 %}\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
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (''use_brightness'' in include_light_control) and (include_dynamic_lighting
+ == ''enable_sun_elevation_colour'') }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: '{{ brightness_value }}'
+ kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_colour_temp
+ - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope
+ = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_colour_temp %} {% if elevation
+ >= -10 %}\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
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''enable_sun_elevation_colour'') }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ kelvin: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_colour_temp
+ - dynamic_lighting_max_colour_temp) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_colour_temp %} {% set end_slope
+ = (dynamic_lighting_min_colour_temp - dynamic_lighting_max_colour_temp)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_colour_temp %} {% if elevation
+ >= -10 %}\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
+ - choose:
+ - alias: Set the Sun Elevation Lighting - Brightness for the normal lights
+ switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness''
+ }}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition and dynamic sun elevation lighting brightness
+ for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_brightness'')
+ and (''use_colour_temperature'' not in include_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_brightness %} {% set end_slope
+ = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_brightness %} {% if elevation
+ >= -10 %}\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
+ - choose:
+ - alias: Set the Sun Elevation Lighting - Brightness Inverted for the normal
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_brightness_inv''
+ }}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition and dynamic sun elevation lighting brightness
+ inverted for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_brightness_inv'')
+ and (''use_colour_temperature'' not in include_light_control)
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_max_brightness
+ - dynamic_lighting_min_brightness) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_min_brightness %} {% set end_slope
+ = (dynamic_lighting_max_brightness - dynamic_lighting_min_brightness)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_max_brightness %} {% if elevation
+ > -10 %}\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
+ - choose:
+ - alias: Set the Sun Elevation Lighting - Colour Temp + Brightness for the
+ normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_brightness''
+ }}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition, dynamic sun elevation lighting brightness
+ and dynamic sun elevation colour temperature for the normal lights
+ switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'')
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_brightness %} {% set end_slope
+ = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_brightness %} {% if elevation
+ >= -10 %}\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
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_colour_brightness'')
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ brightness_pct: "{% set elevation = state_attr('sun.sun', 'elevation')
+ | float %} {% set start_slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_sun_elevation_start_rising
+ - dynamic_lighting_sun_elevation_end_rising) %} {% set start_ak
+ = (( start_slope * dynamic_lighting_sun_elevation_end_rising)
+ * -1) + dynamic_lighting_max_brightness %} {% set end_slope
+ = (dynamic_lighting_min_brightness - dynamic_lighting_max_brightness)
+ / (dynamic_lighting_sun_elevation_end_falling - dynamic_lighting_sun_elevation_start_falling)
+ %} {% set end_ak = (( end_slope * dynamic_lighting_sun_elevation_end_falling)
+ * -1) + dynamic_lighting_min_brightness %} {% if elevation
+ >= -10 %}\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
+ - choose:
+ - alias: Set the Sun Elevation Lighting - Colour Temp + LUX Controled Brightness
+ for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness''
+ }}'
+ sequence:
+ - alias: Dynamic Lighting Control
+ repeat:
+ until: '{{ expand(light_switch.entity_id) | selectattr(''state'', ''=='',
+ ''off'') | list | count > 0 }}'
+ sequence:
+ - choose:
+ - alias: Set the transition, dynamic lighting lux brightness and dynamic
+ sun elevation colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'')
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
+ - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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"
+ - alias: Dynamic lighting heartbeat
+ delay:
+ minutes: !input dynamic_lighting_heartbeat
+ - alias: Set the dynamic lighting lux brightness and dynamic sun elevation
+ colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (include_dynamic_lighting == ''enable_sun_elevation_colour_lux_brightness'')
+ }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ brightness_pct: "{% set lux = states(dynamic_lighting_lux_sensor)
+ | float %} {% set slope = (dynamic_lighting_min_brightness
+ - dynamic_lighting_max_brightness) / (dynamic_lighting_max_lux
+ - dynamic_lighting_min_lux) %} {% set ak = (( slope * dynamic_lighting_min_lux)
+ * -1) + dynamic_lighting_max_brightness %} {% set le = light_entities
+ %} {% set lec = expand(le) | map(attribute='entity_id') |
+ list | length %} {% set lp = expand(le) | map(attribute='attributes.brightness')
+ | reject('equalto', None) | sum | float(default=255) / 255
+ * 100 / lec %} {% if lux <= dynamic_lighting_min_lux %}\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"
+ - alias: Dynamic lighting heartbeat
+ delay:
+ minutes: !input dynamic_lighting_heartbeat
+ - stop: Stop the automation
+ - sequence:
+ - choose:
+ - alias: Set the transition for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control) and
+ (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' not
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ - alias: Set the transition and brightness for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control) and
+ (''use_brightness'' in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' not
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: '{{ brightness_value }}'
+ - alias: Set the transition and colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control) and
+ (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' in
+ include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: Set the transition, brightness and colour temperature for the normal
+ lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' in include_light_control) and
+ (''use_brightness'' in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' in
+ include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ brightness_pct: '{{ brightness_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: Set the brightness for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' not
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ brightness_pct: '{{ brightness_value }}'
+ - alias: Set the colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' in
+ include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ kelvin: '{{temperature_value}}'
+ - alias: Set the brightness and colour temperature for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' in
+ include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ data:
+ brightness_pct: '{{ brightness_value }}'
+ kelvin: '{{temperature_value}}'
+ - alias: Set the default for the normal lights switch
+ conditions:
+ - condition: template
+ value_template: '{{ (''use_transition'' not in include_light_control)
+ and (''use_brightness'' not in include_light_control) and (include_dynamic_lighting
+ == ''disable_dynamic_lighting'') and (''use_colour_temperature'' not
+ in include_light_control) }}'
+ sequence:
+ - service: light.turn_on
+ target:
+ entity_id: '{{ light_entities_off }}'
+ - choose:
+ - alias: Check if normal lights scenes or scripts helper is on - This is for
+ scenes only when crossing over
+ conditions:
+ - condition: template
+ value_template: "{% if night_boolean_scenes_scripts == [] %}\n false\n{%
+ elif is_state(night_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_light_control }}'
+ sequence:
+ - alias: Turn on the scenes
+ service: scene.turn_on
+ target:
+ entity_id: '{{ scene_entities }}'
+ data:
+ transition: '{{ transition_on_value }}'
+ - alias: Turn on the boolean for scenes and scripts
+ service: input_boolean.turn_on
+ data:
+ entity_id: '{{ boolean_scenes_scripts_helper }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control }}'
+ sequence:
+ - alias: Turn on the scenes
+ service: scene.turn_on
+ target:
+ entity_id: '{{ scene_entities }}'
+ - alias: Turn on the boolean for scenes and scripts
+ service: input_boolean.turn_on
+ data:
+ entity_id: '{{ boolean_scenes_scripts_helper }}'
+ - alias: Turn on the switches
+ service: switch.turn_on
+ target:
+ entity_id: '{{ switch_entities_off }}'
+ - alias: Turn on the scripts
+ service: script.turn_on
+ target:
+ entity_id: '{{ script_entities }}'
+ - choose:
+ - alias: By-pass is enabled & check by-pass option - turn lights on
+ conditions:
+ - condition: trigger
+ id: t7_on
+ sequence:
+ - alias: Check by-pass settings and preform the correct action
+ if:
+ - alias: Check if the by-pass auto off is enabled
+ condition: template
+ value_template: '{{ (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ or (''bypass_auto_off_enabled_off'' in include_bypass_auto_off) or
+ (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off) }}'
+ then:
+ - alias: Wait the number of minutes set in the by-pass auto off time delay
+ delay:
+ minutes: !input bypass_auto_off_delay
+ - alias: Parallel Actions for the by-pass auto off
+ parallel:
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_on'' in include_bypass)
+ and (''bypass_auto_off_enabled_on'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_on
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_turn_off'' in include_bypass)
+ and (''bypass_auto_off_enabled_off'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_off
+ - sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ (''bypass_enabled_stop'' in include_bypass)
+ and (''bypass_auto_off_enabled_stop'' in include_bypass_auto_off)
+ }}'
+ sequence:
+ - alias: Turn off the by-pass
+ service: homeassistant.turn_off
+ entity_id: !input motion_bypass_lights_stop
+ - stop: Stop the automation
+ else:
+ - stop: Stop the automation
+ - choose:
+ - alias: Check if the trigger is on and wait for it to go off
+ conditions:
+ - condition: state
+ entity_id: !input motion_trigger
+ state: 'on'
+ match: any
+ sequence:
+ - alias: Wait until motion sensor is off
+ wait_for_trigger:
+ platform: state
+ entity_id: !input motion_trigger
+ from: 'on'
+ to: 'off'
+ - alias: Wait the number of minutes set in the normal lights time delay
+ delay:
+ minutes: !input time_delay
+ - choose:
+ - alias: If transition is selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ data:
+ transition: '{{ transition_off_value }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ transition: '{{ transition_off_value }}'
+ - alias: If transition is not selected
+ conditions:
+ - condition: template
+ value_template: '{{ ''use_transition'' not in include_light_control }}'
+ sequence:
+ - alias: Turn off the lights
+ service: light.turn_off
+ target:
+ entity_id: '{{ light_entities }}'
+ - alias: Turn off the scenes
+ service: scene.turn_on
+ data:
+ entity_id: '{{ end_scene_entities }}'
+ - alias: Turn off the switches
+ service: switch.turn_off
+ target:
+ entity_id: '{{ switch_entities }}'
+ - alias: Turn off the script
+ service: script.turn_on
+ data:
+ entity_id: '{{ end_script_entities }}'
+ - alias: Turn off the boolean for scenes and scripts
+ service: input_boolean.turn_off
+ data:
+ entity_id: !input boolean_scenes_scripts
diff --git a/blueprints/automation/Raukze/contact-sensor-left-open-notification.yaml b/blueprints/automation/Raukze/contact-sensor-left-open-notification.yaml
new file mode 100644
index 0000000..a775e8e
--- /dev/null
+++ b/blueprints/automation/Raukze/contact-sensor-left-open-notification.yaml
@@ -0,0 +1,297 @@
+blueprint:
+ name: "\U0001F6AA Contact Sensor Left Open Notification by Malte"
+ description: "\U0001F4F2 Notifies you when a door or window is left open.\n\nAre
+ you tired of worrying about open doors or windows? This blueprint has got you
+ covered! It's designed to send you a prompt notification when a door or window
+ remains open for a specified duration.\n\n\U0001F4D6 For Details see this [Blog
+ post](https://community.home-assistant.io/t/contact-sensor-door-or-window-left-open-notification/652571)\n"
+ domain: automation
+ source_url: https://gist.github.com/Raukze/27fe0c6bf6d91b8ae2ab5e11880509ba
+ input:
+ trigger_entity:
+ name: "\U0001F916 Entity"
+ description: 'The entity that will trigger the automation. This must be a binary
+ sensor or input_boolean. (e.g., binary_sensor.fridge)
+
+ '
+ selector:
+ entity:
+ domain:
+ - binary_sensor
+ - input_boolean
+ multiple: false
+ friendly_name:
+ name: "\U0001F3F7️ Device Friendly Name"
+ description: What should we call the entity in the notification? (e.g. Fridge)
+ default: ''
+ selector:
+ text: {}
+ issue_state:
+ name: ⚠️ Issue State
+ description: 'The state that triggers the automation. Because this is a binary
+ sensor, it can only be on or off. Use the developer tools to find the correct
+ setting.
+
+ '
+ default: 'on'
+ selector:
+ select:
+ options:
+ - 'on'
+ - 'off'
+ multiple: false
+ sort: false
+ custom_value: false
+ duration_issue_state:
+ name: ⏰ Time before alert
+ description: The amount of time that the device can be in the issue state before
+ an alert is triggered.
+ default:
+ minutes: 10
+ selector:
+ duration:
+ enable_day: true
+ condition_send_notification:
+ name: "\U0001F50D Additional condition"
+ description: Define a condition that is checked after the initial trigger before
+ the notification is sent.
+ default: []
+ selector:
+ condition: {}
+ delete_notification:
+ name: "\U0001F5D1️ Delete notification when not in issue state anymore."
+ description: 'Do you want the notification to be deleted automatically when
+ the device state is not in the issue state anymore.
+
+ '
+ default: true
+ selector:
+ boolean: {}
+ duration_from_issue_state:
+ name: ⏰ Time from issue state before alert removal
+ description: 'The amount of time that the device has not been in the issue state
+ before the alert gets removed.
+
+ '
+ default:
+ seconds: 5
+ selector:
+ duration:
+ enable_day: true
+ notify_services_string:
+ name: "\U0001F4F2 Notify Services"
+ description: 'The service that will be called to deliver the notification. (e.g.,
+ notify.mobile_app_my_phone).
+
+ It also supports multiple services, separated by a comma. (e.g., notify.mobile_app_my_phone,notify.mobile_app_my_spouse_phone).
+
+ '
+ default: notify.mobile_app_
+ selector:
+ text: {}
+ notification_click_url:
+ name: "\U0001F517 Click URL"
+ description: 'Where the user will be taken if they tap the notification. (e.g.,
+ /lovelace/kitchen)
+
+ '
+ default: /lovelace/ROOM
+ selector:
+ text: {}
+ notification_title:
+ name: "\U0001F4E2 Notification Title"
+ description: The title of the notification.
+ default: The {{ friendly_name }} was left open
+ selector:
+ text: {}
+ notification_message:
+ name: "\U0001F4EC Notification Message"
+ description: 'The message of the notification.
+
+ '
+ default: The {{ friendly_name }} was left open at {{ as_timestamp(now()) | timestamp_custom('%T',
+ True) }}.
+ selector:
+ text: {}
+ repeat_notification:
+ name: "\U0001F501 Repeat Notification"
+ description: Whether or not a notification should be repeated after a certain
+ time.
+ default: false
+ selector:
+ boolean: {}
+ time_between_repeat_notification:
+ name: ⏳ Time Between Repeat
+ description: Time period after which the repeat notification is triggered.
+ default:
+ minutes: 10
+ selector:
+ duration:
+ enable_day: true
+ notification_icon_warning:
+ name: "\U0001F6A8 Notification Icon (Android Only)"
+ description: 'The icon that is shown when the issue is reported. (e.g., mdi:fridge-alert)
+
+ '
+ default: alert
+ selector:
+ select:
+ options:
+ - alert
+ - alert-circle
+ - door
+ - door-open
+ - motion-sensor
+ - fridge
+ - fridge-alert
+ - home
+ - home-alert
+ - home-assistant
+ - window-closed
+ - window-open
+ - window-open-variant
+ multiple: false
+ sort: false
+ custom_value: false
+ notification_color:
+ name: "\U0001F308 Notification Color (Android Only)"
+ description: The color of the notification.
+ default: red
+ selector:
+ select:
+ options:
+ - red
+ - orange
+ - yellow
+ - green
+ - blue
+ - purple
+ multiple: false
+ sort: false
+ custom_value: false
+ notification_persistent:
+ name: "\U0001F4CC Persistent Notification (Android Only)"
+ description: The notification cannot be closed manually.
+ default: false
+ selector:
+ boolean: {}
+ notification_interruption_level:
+ name: "\U0001F514 Interruption Level (iOS Only)"
+ description: 'The intrusiveness of the notification received. This also determines
+ whether the notification will be delivered while the device is in a focus
+ mode.
+
+ '
+ default: active
+ selector:
+ select:
+ options:
+ - passive
+ - active
+ - time-sensitive
+ - critical
+ multiple: false
+ sort: false
+ custom_value: false
+ custom_action_issue_state:
+ name: ⚙️ Custom Action Issue State
+ description: Custom actions that are executed when the device state enters the
+ issue state.
+ default: []
+ selector:
+ action: {}
+ custom_action_from_issue_state:
+ name: ⚙️ Custom Action From Issue State
+ description: Custom actions that are executed when the device state exits the
+ issue state.
+ default: []
+ selector:
+ action: {}
+mode: restart
+max_exceeded: silent
+variables:
+ friendly_name: !input friendly_name
+ trigger_entity: !input trigger_entity
+ issue_state: !input issue_state
+ duration_issue_state: !input duration_issue_state
+ condition_send_notification: !input condition_send_notification
+ delete_notification: !input delete_notification
+ duration_from_issue_state: !input duration_from_issue_state
+ notify_services_string: !input notify_services_string
+ notification_click_url: !input notification_click_url
+ notification_title: !input notification_title
+ notification_message: !input notification_message
+ repeat_notification: !input repeat_notification
+ time_between_repeat_notification: !input time_between_repeat_notification
+ notification_icon_warning: !input notification_icon_warning
+ notification_color: !input notification_color
+ notification_interruption_level: !input notification_interruption_level
+ custom_action_issue_state: !input custom_action_issue_state
+ custom_action_from_issue_state: !input custom_action_from_issue_state
+trigger:
+- platform: state
+ entity_id: !input trigger_entity
+ to: !input issue_state
+ for: !input duration_issue_state
+ id: send_notification
+- platform: state
+ entity_id: !input trigger_entity
+ from: !input issue_state
+ for: !input duration_from_issue_state
+ id: delete_notification
+action:
+- variables:
+ notify_services_list: '{{ notify_services_string.split('','') }}'
+ number_of_notify_services: '{{ notify_services_list | count }}'
+ notification_tag: '{{ trigger_entity[-20:] }}-{{ friendly_name[-20:] }}-{{ notify_services_string[-20:]
+ }}'
+- choose:
+ - conditions:
+ - condition: trigger
+ id: send_notification
+ - condition: !input condition_send_notification
+ sequence:
+ - repeat:
+ sequence:
+ - parallel:
+ - repeat:
+ count: '{{ number_of_notify_services }}'
+ sequence:
+ - service: '{{ notify_services_list[repeat.index-1] }}'
+ data:
+ message: !input notification_message
+ title: !input notification_title
+ data:
+ clickAction: !input notification_click_url
+ url: !input notification_click_url
+ tag: '{{ notification_tag }}'
+ color: !input notification_color
+ notification_icon: mdi:{{ notification_icon_warning }}
+ push:
+ interruption-level: !input notification_interruption_level
+ persistent: !input notification_persistent
+ sticky: !input notification_persistent
+ - choose: []
+ default: !input custom_action_issue_state
+ - if:
+ - '{{ repeat_notification }}'
+ then:
+ - delay: '{{ time_between_repeat_notification }}'
+ until:
+ - '{{ not repeat_notification }}'
+ - conditions:
+ - condition: trigger
+ id: delete_notification
+ - '{{ delete_notification }}'
+ sequence:
+ - parallel:
+ - repeat:
+ count: '{{ number_of_notify_services }}'
+ sequence:
+ - service: '{{ notify_services_list[repeat.index-1] }}'
+ data:
+ message: clear_notification
+ data:
+ tag: '{{ notification_tag }}'
+ - choose: []
+ default: !input custom_action_from_issue_state
diff --git a/blueprints/automation/Twanne/smart_lux_dimmer.yaml b/blueprints/automation/Twanne/smart_lux_dimmer.yaml
new file mode 100644
index 0000000..476f205
--- /dev/null
+++ b/blueprints/automation/Twanne/smart_lux_dimmer.yaml
@@ -0,0 +1,413 @@
+blueprint:
+ name: Smart Lux Dimmer
+ author: AntonH
+ description: 'Version 4.1
+
+ Switch or dim lights based on the value of a light sensor.
+
+ Light colors or temperature can be set to a fixed value when inside or outside
+ the measuring range (different values are possible).
+
+ Settings for brightness, color or temperature outside min and max values of the
+ sensor can be set.
+
+ To smoothen out transitions, a time can be set where the light will move from
+ the current to the new brightness.
+
+ '
+ source_url: https://gist.github.com/Twanne/02dfb154084a8b9bf927c29160df4af3
+ domain: automation
+ input:
+ light_sensor_entity:
+ name: Light Sensor
+ description: Which light sensor do you want to use to measure the ambient light
+ value?
+ selector:
+ entity:
+ domain:
+ - sensor
+ device_class:
+ - illuminance
+ multiple: false
+ target_light:
+ name: Target lights
+ description: Which lights do you want to control?
+ selector:
+ target:
+ entity:
+ - domain:
+ - light
+ run_conditions:
+ name: Conditions
+ description: 'Only run when these conditions are met.
+
+ (Remove Time Condition if not needed)
+
+ '
+ default:
+ - condition: time
+ selector:
+ condition: {}
+ max_brightness_value:
+ name: Maximum ambient light value
+ description: Dynamically change the light so long as the ambient light stays
+ under this value.
+ default: 500
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ min_brightness_value:
+ name: Minimum ambient light value
+ description: Dynamically change the light so long as the ambient light stays
+ above this value.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ light_value_1:
+ name: Brightness at maximum light level
+ description: Brightness of the light at maximum ambient light.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_value_2:
+ name: Brightness at minimum light level
+ description: Brightness of the light at minimum ambient light.
+ default: 100
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ transition_time:
+ name: Transition time
+ description: 'The time it takes for the light to transition from the set value
+ to the next.
+
+ WARNING: this can smoothen the transition, but your light needs to support
+ it.
+
+ '
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 300.0
+ step: 1.0
+ unit_of_measurement: s
+ mode: slider
+ include_color_or_temp:
+ name: Include color or temperature
+ description: Do you want to set a color or temperature value for the light?
+ default: include_no_color_temp
+ selector:
+ select:
+ options:
+ - label: I don't want to set color or temperature
+ value: include_no_color_temp
+ - label: Set color
+ value: include_color
+ - label: Set temperature
+ value: include_temp
+ multiple: false
+ sort: false
+ custom_value: false
+ light_color:
+ name: Light color
+ description: Color of the light when between minimum and maximum ambient light
+ values.
+ selector:
+ color_rgb: {}
+ default:
+ - 255
+ - 255
+ - 255
+ light_temp:
+ name: Light temperature
+ description: Temperature of the light when between minimum and maximum ambient
+ light values.
+ default: 2000
+ selector:
+ color_temp: {}
+ include_brightness_over_under:
+ name: Include brightness values when outside range
+ description: I want the automation to set a brightness when the ambient light
+ goes outside of the set range. (Over maximum and under minimum ambient)
+ default: false
+ selector:
+ boolean: {}
+ light_brightness_over_max:
+ name: Brightness when ambient light value over max.
+ description: Brightness of the light when the ambient light is higher than the
+ set maximum value.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_brightness_under_min:
+ name: Brightness when ambient light value under min.
+ description: Brightness of the light when the ambient light is lower than the
+ set minimum value.
+ default: 100
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ include_color_or_temp_over_under:
+ name: Include color or temperature values when outside range
+ description: 'Set a color or temperature value for the light when over maximum
+ or under minimum ambient light value?
+
+ **''Include values for under min and over max'' MUST BE TRUE**
+
+ '
+ default: include_no_color_temp_outside_range
+ selector:
+ select:
+ options:
+ - label: I don't want to set color or temperature when outside range
+ value: include_no_color_temp_outside_range
+ - label: Set color when outside range
+ value: include_color_outside_range
+ - label: Set temperature when outside range
+ value: include_temp_outside_range
+ multiple: false
+ sort: false
+ custom_value: false
+ light_color_over_max:
+ name: Color when ambient light value over max.
+ description: Color of the light when the ambient light is higher than the set
+ maximum value.
+ selector:
+ color_rgb: {}
+ default:
+ - 255
+ - 255
+ - 255
+ light_color_under_min:
+ name: Color when ambient light value under min.
+ description: Color of the light when the ambient light is lower than the set
+ minimum value.
+ selector:
+ color_rgb: {}
+ default:
+ - 255
+ - 255
+ - 255
+ light_temp_over_max:
+ name: Temperature when ambient light value over max.
+ description: Temperature of the light when the ambient light is higher than
+ the set maximum value.
+ default: 2000
+ selector:
+ color_temp: {}
+ light_temp_under_min:
+ name: Temperature when ambient light value under min.
+ description: Temperature of the light when the ambient light is lower than the
+ set minimum value.
+ default: 2000
+ selector:
+ color_temp: {}
+mode: single
+variables:
+ include_color_or_temp: !input include_color_or_temp
+ include_brightness_over_under: !input include_brightness_over_under
+ include_color_or_temp_over_under: !input include_color_or_temp_over_under
+ light_sensor: !input light_sensor_entity
+ maxB: !input max_brightness_value
+ minB: !input min_brightness_value
+ light1: !input light_value_1
+ light2: !input light_value_2
+ slope: '{{ ( light1 - light2 ) / ( maxB - minB ) }}'
+ constant: '{{ light1 - ( slope * maxB ) }}'
+trigger:
+ platform: state
+ entity_id: !input light_sensor_entity
+condition:
+- condition: !input run_conditions
+action:
+- choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ include_brightness_over_under is false }}'
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp == "include_no_color_temp" }}'
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ target: !input target_light
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp == "include_color" }}'
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ rgb_color: !input light_color
+ target: !input target_light
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp == "include_temp" }}'
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ color_temp: !input light_temp
+ target: !input target_light
+ - conditions:
+ - condition: template
+ value_template: '{{ include_brightness_over_under is true }}'
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp_over_under == "include_no_color_temp_outside_range"
+ }}'
+ sequence:
+ - choose:
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ above: !input max_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_over_max
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_under_min
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input max_brightness_value
+ above: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ target: !input target_light
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp_over_under == "include_color_outside_range"
+ }}'
+ sequence:
+ - choose:
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ above: !input max_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_over_max
+ rgb_color: !input light_color_over_max
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_under_min
+ rgb_color: !input light_color_under_min
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input max_brightness_value
+ above: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ rgb_color: !input light_color
+ target: !input target_light
+ - conditions:
+ - condition: template
+ value_template: '{{ include_color_or_temp_over_under == "include_temp_outside_range"
+ }}'
+ sequence:
+ - choose:
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ above: !input max_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_over_max
+ color_temp: !input light_temp_over_max
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: !input light_brightness_under_min
+ color_temp: !input light_temp_under_min
+ target: !input target_light
+ - conditions:
+ - condition: numeric_state
+ entity_id: !input light_sensor_entity
+ below: !input max_brightness_value
+ above: !input min_brightness_value
+ sequence:
+ - service: light.turn_on
+ data:
+ transition: !input transition_time
+ brightness_pct: '{{ (( slope * states(light_sensor)|int ) + constant)|round
+ }}'
+ color_temp: !input light_temp
+ target: !input target_light
diff --git a/blueprints/automation/Twanne/smart_lux_dimmer_basic.yaml b/blueprints/automation/Twanne/smart_lux_dimmer_basic.yaml
new file mode 100644
index 0000000..d11079d
--- /dev/null
+++ b/blueprints/automation/Twanne/smart_lux_dimmer_basic.yaml
@@ -0,0 +1,119 @@
+blueprint:
+ name: Smart Lux Dimmer (BASIC)
+ description: 'Version 2.0
+
+ Dim or turn off light based on the value of a light sensor
+
+ '
+ source_url: https://gist.github.com/Twanne/b942a7885e5a062dc9b6acfe9d6fe3db
+ domain: automation
+ input:
+ schedule_start:
+ name: Schedule start time
+ description: Automation only runs after this time.
+ selector:
+ time: {}
+ schedule_stop:
+ name: Schedule stop time
+ description: Automation does not run after this time.
+ selector:
+ time: {}
+ schedule_days:
+ name: Run on these days
+ description: 'Days on which the automation will run.
+
+ Write days in short form, seperated by punctuation marks and/or spaces.
+
+ (i.e.: mon, tue, wed,...)
+
+ '
+ selector:
+ text: {}
+ light_sensor_entity:
+ name: Light Sensor
+ selector:
+ entity:
+ domain:
+ - sensor
+ device_class:
+ - illuminance
+ multiple: false
+ max_brightness_value:
+ name: Maximum ambient light value
+ description: Light is turned off above this value.
+ default: 500
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ min_brightness_value:
+ name: Minimum ambient light value
+ description: The light does not change brightness further under this value.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ light_value_1:
+ name: Dimming value 1
+ description: Brightness of the light at maximum ambient light.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_value_2:
+ name: Dimming value 2
+ description: Brightness of the light at minimum ambient light.
+ default: 100
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ target_light:
+ name: Target lights
+ selector:
+ target:
+ entity:
+ - domain:
+ - light
+mode: single
+variables:
+ light_sensor: !input light_sensor_entity
+ maxB: !input max_brightness_value
+ minB: !input min_brightness_value
+ light1: !input light_value_1
+ light2: !input light_value_2
+ slope: '{{ ( light1 - light2 ) / ( maxB - minB ) }}'
+ constant: '{{ light1 - ( slope * maxB ) }}'
+ days: !input schedule_days
+trigger:
+ platform: state
+ entity_id: !input light_sensor_entity
+condition:
+- condition: numeric_state
+ entity_id: !input light_sensor_entity
+ above: !input min_brightness_value
+- condition: time
+ after: !input schedule_start
+ before: !input schedule_stop
+- condition: template
+ value_template: '{{ now().strftime(''%a'') | lower in days }}'
+action:
+- service: light.turn_on
+ data:
+ brightness_pct: "{% if states(light_sensor)|int > maxB %}\n 0\n{% else %}\n {{
+ (( slope * states(light_sensor)|int ) + constant)|round }}\n{% endif %}\n"
+ target: !input target_light
diff --git a/blueprints/automation/Twanne/the_everything_light.yaml b/blueprints/automation/Twanne/the_everything_light.yaml
new file mode 100644
index 0000000..742faab
--- /dev/null
+++ b/blueprints/automation/Twanne/the_everything_light.yaml
@@ -0,0 +1,430 @@
+blueprint:
+ name: The Everything Light
+ author: AntonH
+ description: "**Version 2.5**\nThe Everything Light: select any trigger and turn
+ on your light in multiple ways:\n - just turn the light on in it's default state\n
+ \ - turn it on with a set brightness, color and/or temperature value\n - turn
+ it on dynamically with a brightness value that changes according to an ambient
+ light sensor\n\nThe blueprint also allows you to turn the light off again in 3
+ ways:\n - at a set time\n - with 1 or more triggers\n - with a staircase function
+ (turn off the light after a set time has passed)\n\n Conditions can be set to
+ prevent both turn on and turn off functions.\n\n**The dynamic lighting logic is
+ based of the Smart Lux Dimmer Blueprint:**\n - [Find it on the Home Assistant
+ Community forums:](https://community.home-assistant.io/t/smart-lux-dimmer-adjust-light-brightness-depending-on-light-sensor-value/403646)\n
+ \ - [See the source on Github:](https://gist.github.com/Twanne/02dfb154084a8b9bf927c29160df4af3)\n"
+ source_url: https://gist.github.com/Twanne/8003f5d00da69ae3260e9a69864e5ff5
+ domain: automation
+ input:
+ triggers:
+ name: Triggers
+ description: Choose what turns your light on
+ default: []
+ selector:
+ trigger: {}
+ run_conditions:
+ name: Conditions
+ description: Only turn the light on when these conditions are met.
+ default:
+ - condition: time
+ alias: Run only at these times ( - Remove me if not needed - )
+ selector:
+ condition: {}
+ target_light:
+ name: Target lights
+ description: "Which lights do you want to control?\n\nSupported entity types
+ are:\n - light\n - switch (Only **DEFAULT** & **TOGGLE** modes are supported)\n"
+ default: []
+ selector:
+ target:
+ entity:
+ - domain:
+ - light
+ - switch
+ mode:
+ name: Mode
+ description: 'How do you want the light to turn on?
+
+
+ - **DEFAULT MODE:**
+
+ The light will turn on at it''s default setting.
+
+
+ - **TOGGLE MODE:**
+
+ Toggle the light.
+
+
+ - **FIXED MODE: **
+
+ The light will turn on at a set brightness percentage, optionally color or
+ temperature can be set.
+
+
+ - **DYNAMIC MODE**
+
+ The light will be assigned a brightness value based on the value of a ambient
+ light sensor, optionally color or temperature can be set.
+
+ '
+ default: default
+ selector:
+ select:
+ mode: dropdown
+ options:
+ - label: DEFAULT MODE
+ value: default
+ - label: TOGGLE
+ value: toggle
+ - label: FIXED MODE
+ value: fixed
+ - label: DYNAMIC MODE
+ value: dynamic
+ multiple: false
+ sort: false
+ custom_value: false
+ transition_time:
+ name: Transition time (FIXED & DYNAMIC MODE)
+ description: "The time it takes for the light to transition to the assigned
+ value when it's triggered.\n\nWARNING!: \n This can smoothen the transition,
+ but your light needs to support it.\n Leave at 0 if you don't need it or
+ if your light doesn't support it.\n"
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 300.0
+ step: 1.0
+ unit_of_measurement: s
+ mode: slider
+ include_color_or_temp:
+ name: Include color or temperature (FIXED & DYNAMIC MODE)
+ description: Do you want to set a color or temperature value for the light?
+ default: include_no_color_temp
+ selector:
+ select:
+ options:
+ - label: I don't want to set color or temperature
+ value: include_no_color_temp
+ - label: Set color
+ value: include_color
+ - label: Set temperature
+ value: include_temperature
+ multiple: false
+ sort: false
+ custom_value: false
+ light_color:
+ name: Light color (FIXED & DYNAMIC MODE)
+ description: Color of the light when between minimum and maximum ambient light
+ values.
+ default:
+ - 255
+ - 255
+ - 255
+ selector:
+ color_rgb: {}
+ light_temperature:
+ name: Light temperature (FIXED & DYNAMIC MODE)
+ description: Temperature of the light when between minimum and maximum ambient
+ light values.
+ default: 2000
+ selector:
+ color_temp: {}
+ brightness:
+ name: Brightness (FIXED BRIGHTNESS MODE)
+ description: Set the brightness value the light needs to turn on at
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_sensor_entity:
+ name: Light Sensor (DYNAMIC MODE)
+ description: Which light sensor do you want to use to measure the ambient light
+ value?
+ default:
+ selector:
+ entity:
+ filter:
+ - domain:
+ - sensor
+ device_class:
+ - illuminance
+ multiple: false
+ max_brightness_value:
+ name: Maximum ambient light value (DYNAMIC MODE)
+ description: Dynamically change the light so long as the ambient light stays
+ under this value.
+ default: 500
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ min_brightness_value:
+ name: Minimum ambient light value (DYNAMIC MODE)
+ description: Dynamically change the light so long as the ambient light stays
+ above this value.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 1000.0
+ step: 10.0
+ unit_of_measurement: lx
+ mode: slider
+ light_value_1:
+ name: Brightness at maximum light level (DYNAMIC MODE)
+ description: Brightness of the light at maximum ambient light.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_value_2:
+ name: Brightness at minimum light level (DYNAMIC MODE)
+ description: Brightness of the light at minimum ambient light.
+ default: 100
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_brightness_over_max:
+ name: Brightness when ambient light value over max (DYNAMIC MODE)
+ description: Brightness of the light when the ambient light is higher than the
+ set maximum value.
+ default: 0
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ light_brightness_under_min:
+ name: Brightness when ambient light value under min (DYNAMIC MODE)
+ description: Brightness of the light when the ambient light is lower than the
+ set minimum value.
+ default: 100
+ selector:
+ number:
+ min: 0.0
+ max: 100.0
+ step: 1.0
+ mode: slider
+ unit_of_measurement: '%'
+ include_color_or_temp_over_under:
+ name: Include color or temperature values when outside range (DYNAMIC MODE)
+ description: 'Set a color or temperature value for the light when over maximum
+ or under minimum ambient light value?
+
+ *''Include values for under min and over max''* **MUST BE TRUE**
+
+ '
+ default: include_no_color_temp_outside_range
+ selector:
+ select:
+ options:
+ - label: I don't want to set color or temperature when outside range
+ value: include_no_color_temp_outside_range
+ - label: Set color when outside range
+ value: include_color_outside_range
+ - label: Set temperature when outside range
+ value: include_temp_outside_range
+ multiple: false
+ sort: false
+ custom_value: false
+ light_color_over_max:
+ name: Color when ambient light value over max (DYNAMIC MODE)
+ description: Color of the light when the ambient light is higher than the set
+ maximum value.
+ default:
+ - 255
+ - 255
+ - 255
+ selector:
+ color_rgb: {}
+ light_color_under_min:
+ name: Color when ambient light value under min (DYNAMIC MODE)
+ description: Color of the light when the ambient light is lower than the set
+ minimum value.
+ default:
+ - 255
+ - 255
+ - 255
+ selector:
+ color_rgb: {}
+ light_temp_over_max:
+ name: Temperature when ambient light value over max (DYNAMIC MODE)
+ description: Temperature of the light when the ambient light is higher than
+ the set maximum value.
+ default: 2000
+ selector:
+ color_temp: {}
+ light_temp_under_min:
+ name: Temperature when ambient light value under min (DYNAMIC MODE)
+ description: Temperature of the light when the ambient light is lower than the
+ set minimum value.
+ default: 2000
+ selector:
+ color_temp: {}
+ include_turn_off:
+ name: Include light turn off function
+ description: 'Select if the light needs to turn back off again and how you want
+ to do it.
+
+ (Multiple options are possible)
+
+
+ - **TURN OFF WITH TRIGGER:**
+
+ Select triggers that turn off the light.
+
+
+ - **STAIRCASE FUNCTION:**
+
+ Waits after the light has been turned on and then turns it back off after
+ the set duration.
+
+ '
+ default: []
+ selector:
+ select:
+ multiple: true
+ options:
+ - label: Turn off with trigger
+ value: trigger
+ - label: Staircase function
+ value: staircase
+ sort: false
+ custom_value: false
+ turn_off_triggers:
+ name: Turn off triggers
+ description: Triggers that turn the light off
+ default:
+ selector:
+ trigger: {}
+ staircase_duration:
+ name: Staircase light
+ description: Turns the light off again after a set time (staircase function).
+ default:
+ hours: 0
+ minutes: 0
+ seconds: 0
+ days: 0
+ selector:
+ duration:
+ enable_day: true
+ turn_off_conditions:
+ name: Turn off Conditions
+ description: 'Only turn the light off when these conditions are met.
+
+ (Only works with the turn off functions, DYNAMIC MODE is not impacted by this)
+
+ '
+ default: []
+ selector:
+ condition: {}
+mode: restart
+variables:
+ mode: !input mode
+ transition_time: !input transition_time
+ include_color_or_temp: !input include_color_or_temp
+ light_color: !input light_color
+ light_temperature: !input light_temperature
+ light_brightness: !input brightness
+ light_sensor: !input light_sensor_entity
+ maxB: !input max_brightness_value
+ minB: !input min_brightness_value
+ light1: !input light_value_1
+ light2: !input light_value_2
+ slope: '{{ ( light1 - light2 ) / ( maxB - minB ) }}'
+ constant: '{{ light1 - ( slope * maxB ) }}'
+ dynamic_brightness_pct: "{% if mode == \"dynamic\" %}\n {{ (( slope * states(light_sensor)|int
+ ) + constant)|round }}\n{% else %}\n 0\n{% endif %}\n"
+ include_color_or_temp_over_under: !input include_color_or_temp_over_under
+ light_brightness_over_max: !input light_brightness_over_max
+ light_color_over_max: !input light_color_over_max
+ light_temp_over_max: !input light_temp_over_max
+ light_brightness_under_min: !input light_brightness_under_min
+ light_color_under_min: !input light_color_under_min
+ light_temp_under_min: !input light_temp_under_min
+ include_turn_off: !input include_turn_off
+trigger: !input triggers
+condition:
+- condition: !input run_conditions
+action:
+- choose:
+ - conditions: '{{ mode == "toggle" }}'
+ sequence:
+ - service: homeassistant.toggle
+ target: !input target_light
+ - conditions: '{{ mode == "default" }}'
+ sequence:
+ - service: homeassistant.turn_on
+ target: !input target_light
+ - conditions: '{{ mode == "fixed" }}'
+ sequence:
+ - service: light.turn_on
+ data: "{% if include_color_or_temp == \"include_color\" %}\n {{ { \"transition\":
+ transition_time, \"brightness_pct\": light_brightness, \"rgb_color\": light_color
+ } }}\n{% elif include_color_or_temp == \"include_temperature\" %}\n {{ {
+ \"transition\": transition_time, \"brightness_pct\": light_brightness, \"color_temp\":
+ light_temperature } }}\n{% else %}\n {{ { \"transition\": transition_time,
+ \"brightness_pct\": light_brightness } }}\n{% endif %}\n"
+ target: !input target_light
+ - conditions: '{{ mode == "dynamic" }}'
+ sequence:
+ - service: light.turn_on
+ data: "{% if states(light_sensor)|int > maxB %}\n {% if include_color_or_temp_over_under
+ == \"include_color_outside_range\" %}\n {{ { \"transition\": transition_time,
+ \"brightness_pct\": light_brightness_over_max, \"rgb_color\": light_color_over_max
+ } }}\n {% elif include_color_or_temp_over_under == \"include_temp_outside_range\"
+ %}\n {{ { \"transition\": transition_time, \"brightness_pct\": light_brightness_over_max,
+ \"color_temp\": light_temp_over_max } }}\n {% else %}\n {{ { \"transition\":
+ transition_time, \"brightness_pct\": light_brightness_over_max } }}\n {%
+ endif %}\n{% elif states(light_sensor)|int < minB %}\n {% if include_color_or_temp_over_under
+ == \"include_color_outside_range\" %}\n {{ { \"transition\": transition_time,
+ \"brightness_pct\": light_brightness_under_min, \"rgb_color\": light_color_under_min
+ } }}\n {% elif include_color_or_temp_over_under == \"include_temp_outside_range\"
+ %}\n {{ { \"transition\": transition_time, \"brightness_pct\": light_brightness_under_min,
+ \"color_temp\": light_temp_under_min } }}\n {% else %}\n {{ { \"transition\":
+ transition_time, \"brightness_pct\": light_brightness_under_min } }}\n {%
+ endif %}\n{% else %}\n {% if include_color_or_temp == \"include_color\" %}\n
+ \ {{ { \"transition\": transition_time, \"brightness_pct\": light_brightness,
+ \"rgb_color\": light_color } }}\n {% elif include_color_or_temp == \"include_temperature\"
+ %}\n {{ { \"transition\": transition_time, \"brightness_pct\": dynamic_brightness_pct,
+ \"color_temp\": light_temperature } }}\n {% else %}\n {{ { \"transition\":
+ transition_time, \"brightness_pct\": dynamic_brightness_pct } }}\n {% endif
+ %}\n{% endif %}\n"
+ target: !input target_light
+- if: !input turn_off_conditions
+ then:
+ - choose:
+ - conditions: '{{ "staircase" in include_turn_off }}'
+ sequence:
+ - if: '{{ "trigger" in include_turn_off }}'
+ then:
+ - wait_for_trigger: !input turn_off_triggers
+ timeout: !input staircase_duration
+ else:
+ - delay: !input staircase_duration
+ - service: homeassistant.turn_off
+ target: !input target_light
+ - conditions: '{{ "trigger" in include_turn_off and not "staircase" in include_turn_off
+ }}'
+ sequence:
+ - wait_for_trigger: !input turn_off_triggers
+ - service: homeassistant.turn_off
+ target: !input target_light