Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active June 29, 2025 11:30
Show Gist options
  • Select an option

  • Save Blackshome/70349658a0c7543dbaa5f2e69e10cce0 to your computer and use it in GitHub Desktop.

Select an option

Save Blackshome/70349658a0c7543dbaa5f2e69e10cce0 to your computer and use it in GitHub Desktop.
Toilet Exhaust Fan
blueprint:
name: Toilet Exhaust Fan
description: >
# 🚽 Toilet Exhaust Fan
**Version: 2.9**
🚽 Let it go, let it blow - Enjoy a breath of fresh air with your smart fan control 💩🌱
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) 🙂
<details>
<summary><b>The Automation Process:</b> 👈</summary>
- **Triggering:**
- When a light is turned ON or a binary sensor is activated, it will turn on the exhaust fan.
- If the trigger is activated again before the time delay ends, the automation resets.
- **Safeguard:**
- If your trigger is a light and it remains ON (keeping the fan ON), you can set a maximum run time to automatically turn both the light and fan OFF.
- **Time Delay:**
- When the light is turned OFF or the binary sensor is clear, a time delay is activated, which automatically turns the exhaust fan OFF.
- **Invert Trigger Option:**
- The option to invert the trigger allows the exhaust fan to turn ON when the light is turned OFF.
- **Trigger Wait Options:**
Controls how the fan responds based on how long the trigger (e.g., a light) stays ON.
- **Use the wait time** — The fan will only turn ON if the trigger remains ON for the full wait time. Ideal for longer use where the fan isn't needed during brief activity.
- **Turn ON but use the wait time** — The fan turns ON, but if the trigger turns OFF before the full wait time, the fan will turn OFF after a brief delay. Great for both short visits (with a short fan delay) and longer stays (with a longer delay if needed).
- **Lights Option:**
- If your trigger is a light, you can set the brightness, colour temperature, or colour.
- You can also enable night lights to apply different settings, such as lower brightness, warmer colour temperature, or a specific colour, ideal for late-night trips to the toilet.
- **Manual Fan Switch Option:**
- Provides independent control over the fan (ON/OFF) while maintaining automation trigger.
- Opt to use the auto-off feature for manual control.
- **Time-Based Options:**
- Specify precise start and end times along with weekday selections to define when the automation should run.
- This is a good option if you would like to disable the fan at night when everyone is sleeping, so the fan noise doesn't wake anyone up.
- **Bypass Options:**
- Use "Bypass Options" for manual bypassing of trigger sensors, providing manual control and additional customization.
- **Custom Conditions:**
- Enter any custom conditions to further customize the automation process.
- **Blueprint Add-On Integration:**
- 🚿 [Bathroom Humidity Exhaust Fan](https://community.home-assistant.io/t/509992) - Step into the future of freshness - customize it your way and let the automated fan system handle the humidity control for you!
- **HA Restart Safeguard:**
- An option for safeguarding the automation process in case of a Home Assistant restart.
</details>
Need help?
- FAQ: [Click Here](https://community.home-assistant.io/t/478954/7)
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/478954)
Required = *
domain: automation
input:
trigger_settings:
name: "Triggers *"
icon: mdi:cog-outline
collapsed: true
input:
entity_trigger:
name: Trigger Sensor *
description: >
The trigger is typically either a light, a switch or a motion sensor. However, any entity capable of toggling between an ON and OFF state can serve as the trigger.
default: []
selector:
entity:
trigger_options:
name: Trigger Options
description: >
Select the mode that aligns with your specific needs.
**Normal Mode (Default)** - This feature initiates the fan operation when the trigger switches from an OFF to ON state. Example, when the light is switched ON when entering the toilet.
**Inverted Mode** - This feature initiates the fan operation when the trigger switches from an ON to OFF state. Example, when the light is switched OFF when leaving the toilet.
**Note** - Using a motion sensor as the trigger might introduce operational difficulties.
default: normal_mode_trigger
selector:
select:
options:
- label: Normal Mode (Default)
value: "normal_mode_trigger"
- label: Invert Mode
value: "inverted_trigger"
trigger_wait_option:
name: Trigger Wait Option (Optional)
description: >
Choose how the fan should respond when the trigger (e.g., Light) turns ON.
**Use the wait time** — The fan turns ON only if the trigger stays ON for the full wait time. Ideal for longer stays where brief use doesn't require fan activation.
**Turn ON but use the wait time** — The fan turns ON, but will turn OFF early if the trigger doesn't stay ON for the full wait time.
In this mode, a Brief Use Delay can be set to prevent the fan from turning OFF too quickly.
**Don't use the wait time** — The fan turns ON as soon as the trigger activates, regardless of how long the trigger stays ON.
If you selected **Use the wait time**, set the duration in the **Trigger Wait Time** field below.
If you selected **Turn ON but use the wait time**, set the durations in both the **Trigger Wait Time** and **Brief Use Delay** fields below.
default: fire_on_trigger
selector:
select:
options:
- label: Use the wait time
value: "wait_for_trigger"
- label: Turn ON but use the wait time
value: "turn_on_and_wait_for_trigger"
- label: Dont use the wait time
value: "fire_on_trigger"
trigger_wait_time:
name: Trigger Wait Time
description: >
Defines how long the trigger (e.g., Light) must stay ON to satisfy the wait condition.
• If **Use the wait time** is selected, the fan will turn ON only *after* this time is reached.
• If **Turn ON but use the wait time** is selected, the fan turns ON, but will turn OFF after the Brief Use Delay if the trigger doesn't stay ON for this full duration.
default: 3
selector:
number:
min: 0
max: 10
step: 0.2
unit_of_measurement: minutes
brief_use_delay:
name: Brief Use Delay
description: >
Only applies when **Turn ON but use the wait time** is selected.
If the trigger turns OFF before the full Trigger Wait Time is reached, this sets a short delay before the fan turns OFF.
Helps avoid the fan turning OFF too quickly during brief use.
default: 1
selector:
number:
min: 0
max: 5
step: 0.2
unit_of_measurement: minutes
safeguard_option:
name: Safeguard Option (Optional)
description: >
This safeguard is active only in **Normal Mode (Default)** and sets a maximum runtime to prevent the fan from running indefinitely.
If the automation turns the fan **ON** and the initial trigger condition (e.g., light remains **ON**) does not revert to **OFF** within the safeguard time frame, the safeguard will activate and proceed directly to the **Fan Time Delay** stage.
If selecting this setting, please specify the safeguard maximum run time below.
This option is intended for use when a light switch is the trigger.
default: disable_safeguard
selector:
select:
options:
- label: Use the safeguard
value: "enable_safeguard"
- label: Use the safeguard + Turn trigger OFF
value: "enable_safeguard_and_trigger"
- label: Dont use safeguard
value: "disable_safeguard"
safeguard:
name: Safeguard - Maximum Run Time
description: >
The safeguard maximum run time.
default: 20
selector:
number:
min: 5
max: 60
step: 0.5
unit_of_measurement: minutes
fan_settings:
name: "Fan *"
icon: mdi:fan
collapsed: true
input:
fan_switch:
name: Fan *
description: >
The fan that gets turned ON by the trigger sensor.
default: []
selector:
entity:
time_delay:
name: Time Delay
description: >
The delay time to leave the fan ON after the light is turned OFF or the last motion is detected.
default: 2.5
selector:
number:
min: 0
max: 10
step: 0.5
unit_of_measurement: minutes
lights:
name: "Lights"
icon: mdi:lightbulb-on-outline
collapsed: true
input:
include_lights:
name: Use The Lights Options (Optional)
description: >
This option is typically used together with night lights.
It allows you to set a higher brightness (e.g., 100%) during the day, while the night lights option lets you set a lower brightness (e.g., 10%) at night.
**NOTE** - This option **can only** be used if your light is selected in the **Trigger Sensor** input.
⚠️ If you're not using a light as the trigger and still want to control your lights, please use my 💡[Sensor Light](https://community.home-assistant.io/t/481048) blueprint instead.
default: lights_disabled
selector:
select:
options:
- label: Enable the lights options
value: "lights_enabled"
- label: Disable the lights options
value: "lights_disabled"
include_light_control:
name: Light Control Options (Optional)
description: >
Select if you would like to use brightness or transition.
These settings will only affect a 'light' entity that supports each selected option.
The settings for brightness and transition are provided below.
default: []
selector:
select:
multiple: true
options:
- label: Use Brightness
value: "use_brightness"
- label: Use Transition
value: "use_transition"
light_brightness:
name: Brightness
description: >
The brightness setting for the lights when they are turned ON.
default: 100
selector:
number:
min: 1
max: 100
mode: slider
step: 1
unit_of_measurement: '%'
light_transition_on:
name: Transition - ON
description: >
The transition setting for the lights when they are turned ON.
default: 1
selector:
number:
min: 0
max: 5
mode: slider
step: 0.5
unit_of_measurement: seconds
light_transition_off:
name: Transition - OFF
description: >
The transition setting for the lights when they are turned OFF.
default: 1
selector:
number:
min: 0
max: 30
mode: slider
step: 1
unit_of_measurement: seconds
include_light_colour_control:
name: Light Colour Control Options (Optional)
description: >
Select if you would like to use colour temperature, RGB, RGBW or RGBWW colour.
These settings will only affect a 'light' entity that supports each selected option.
The settings for colour temperature, RGB, RGBW and RGBWW colour are provided below.
default: disable_colour_control
selector:
select:
options:
- label: Use Colour Temperature
value: "use_colour_temperature"
- label: Use RGB Colour
value: "use_rgb_colour"
- label: Use RGBW Colour
value: "use_rgbw_colour"
- label: Use RGBWW Colour
value: "use_rgbww_colour"
- label: Disable Colour Control
value: "disable_colour_control"
light_colour_temperature:
name: Colour Temperature
description: >
The colour temperature setting for the lights when they are turned ON.
default: 5000
selector:
number:
min: 2000
max: 8000
mode: slider
step: 100
unit_of_measurement: 'kelvin'
light_rgb_colour:
name: RGB Colour
description: >
The RGB colour setting for the lights when they are turned ON.
default: [255, 255, 255]
selector:
color_rgb:
light_rgbw_colour:
name: RGBW Colour
description: >
The RGBW colour setting for the lights when they are turned ON.
Enter four integers between 0 and 255 to define the values for Red, Green, Blue, and White.
default: [255, 255, 255, 255]
selector:
object:
light_rgbww_colour:
name: RGBWW Colour
description: >
The RGBWW colour setting for the lights when they are turned ON.
Enter five integers between 0 and 255 to define the values for Red, Green, Blue, Cold White and Warm White.
default: [255, 255, 255, 255, 255]
selector:
object:
night_lights:
name: "Night Lights"
icon: mdi:lightbulb-night-outline
collapsed: true
input:
include_night_lights:
name: Use The Night Lights Options (Optional)
description: >
Enabling the night lights options allows for separate and customizable lighting control when the night lights conditions are met.
Night light condition options include entity state, time, or sun elevation. Please choose the condition option you would like to use below.
This feature is particularly beneficial for creating a soothing ambiance with softer lighting at night.
The flexibility of these options allows for personalized adjustments, enhancing your night time ambiance and comfort, especially when moving around during the night.
**NOTE** - This option **can only** be used if your light is selected in the **Trigger Sensor** input.
If you're using the Night Lights option, it's recommended to also enable the Lights option above to ensure your lights reset to their daytime settings.
⚠️ If you're not using a light as the trigger and still want to control your lights, please use my 💡[Sensor Light](https://community.home-assistant.io/t/481048) blueprint instead.
default: night_lights_disabled
selector:
select:
options:
- label: Enable the night lights options
value: "night_lights_enabled"
- label: Disable the night lights options
value: "night_lights_disabled"
night_lights_conditions:
name: Night Lights Conditions (Required For Night Lights)
description: >
Select any night light condition from the options provided and ensure that **Use Night Lights Options** is enabled in the section above.
You must choose at least one 'Night Light Condition' for the night lights to operate, and the settings for each condition are provided below.
If you select two or more conditions, all selected conditions must be met for the night lights to activate.
default: []
selector:
select:
multiple: true
options:
- label: Enable entity state option
value: "entity_state_enabled"
- label: Enable time option
value: "time_enabled"
- label: Enable sun elevation option
value: "sun_enabled"
night_lights_entity_state:
name: Night Lights - Entity State
description: >
Select an entity that will trigger the activation of night lights when turned ON. This could be your phone on 'Do Not Disturb', a helper, a bed sensor, etc.
Please note that the selected entity cannot be included in the 'Lights - Switches - Scenes - Scripts' or 'Night Lights' selections.
For more information on entity state [Click Here](https://community.home-assistant.io/t/481048/663)
default: []
selector:
entity:
multiple: true
night_lights_after_time:
name: Night Lights - Start Time
description: >
Set the start time.
default: 00:00:00
selector:
time:
night_lights_before_time:
name: Night Lights - End Time
description: >
Set the end time.
default: 00:00:00
selector:
time:
night_lights_sun_elevation:
name: Night Lights - Sun Elevation Falling
description: >
The sun elevation falling refers to the angle between the sun and the horizon when the sun is setting.
A negative value indicates that the sun is BELOW the horizon. For example, a setting guide of -1.5 corresponds to dusk.
default: -1.5
selector:
number:
min: -10
max: 5
step: 0.5
unit_of_measurement: degrees
night_lights_sun_elevation_rising:
name: Night Lights - Sun Elevation Rising
description: >
The sun elevation rising refers to the angle between the sun and the horizon during sunrise.
A negative value indicates that the sun is BELOW the horizon. For example, a setting guide of -4.0 corresponds to dawn.
default: -4.0
selector:
number:
min: -10
max: 5
step: 0.5
unit_of_measurement: degrees
include_night_light_control:
name: Night Lights - Light Control Options (Optional)
description: >
Select if you would like to use brightness or transition.
These settings will only affect a 'light' entity that supports each selected option.
The settings for brightness and transition are provided below.
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 transition
value: "use_transition"
night_light_brightness:
name: Night Lights - Brightness
description: >
The brightness setting of the lights when they are turned ON.
default: 10
selector:
number:
min: 1
max: 100
mode: slider
step: 1
unit_of_measurement: '%'
night_light_transition_on:
name: Night Lights - Transition - ON
description: >
The transition of the lights when they are turned ON.
default: 1
selector:
number:
min: 0
max: 5
mode: slider
step: 0.5
unit_of_measurement: seconds
night_light_transition_off:
name: Night Lights - Transition - OFF
description: >
The transition of the lights when they are turned OFF.
default: 1
selector:
number:
min: 0
max: 30
mode: slider
step: 1
unit_of_measurement: seconds
include_night_light_colour_control:
name: Night Lights - Light Colour Control Options (Optional)
description: >
Select if you would like to use colour temperature, RGB, RGBW or RGBWW colour.
These settings will only affect a 'light' entity that supports each selected option.
The settings for colour temperature, RGB, RGBW and RGBWW colour are provided below
default: disable_colour_control
selector:
select:
options:
- label: Use Colour Temperature
value: "use_colour_temperature"
- label: Use RGB Colour
value: "use_rgb_colour"
- label: Use RGBW Colour
value: "use_rgbw_colour"
- label: Use RGBWW Colour
value: "use_rgbww_colour"
- label: Disable Colour Control
value: "disable_colour_control"
night_light_colour_temperature:
name: Night Lights - Colour Temperature
description: >
The colour temperature setting for the lights when they are turned ON.
default: 5000
selector:
number:
min: 2000
max: 8000
mode: slider
step: 100
unit_of_measurement: 'kelvin'
night_light_rgb_colour:
name: Night Lights - RGB Colour
description: >
The RGB colour setting for the lights when they are turned ON.
default: [255, 255, 255]
selector:
color_rgb:
night_light_rgbw_colour:
name: Night Lights - RGBW Colour
description: >
The RGBW colour setting for the lights when they are turned ON.
Enter four integers between 0 and 255 to define the values for Red, Green, Blue, and White.
default: [255, 255, 255, 255]
selector:
object:
night_light_rgbww_colour:
name: Night Lights - RGBWW Colour
description: >
The RGBWW colour setting for the lights when they are turned ON.
Enter five integers between 0 and 255 to define the values for Red, Green, Blue, Cold White and Warm White.
default: [255, 255, 255, 255, 255]
selector:
object:
manual_settings:
name: "Manual Fan Switch"
icon: mdi:toggle-switch-outline
collapsed: true
input:
include_manual_fan_switch:
name: Use The Manual Fan Switch Option (Optional)
description: >
This feature enables manual control of the fan, allowing you to turn it ON or OFF independently, while also retaining the automation trigger capability. If automation is triggered the manual fan switch will be turned OFF.
Option 2 may assist you to never overlook turning the fan OFF or can also serve as a manual timer.
**NOTE** - Please note that the manual fan switch entity cannot be connected to either your actual fan switch or the trigger.
It must function as a completely independent switch; otherwise, the automation will not operate.
default: disable_manual_fan_switch
selector:
select:
options:
- label: 1 - Enable manual fan switch option
value: "enable_manual_fan_switch"
- label: 2 - Enable manual fan switch + auto off option
value: "enable_manual_fan_switch_auto_off"
- label: Disable manual fan switch
value: "disable_manual_fan_switch"
manual_fan_switch:
name: Manual Fan Switch
description: >
Enter a switch that will turn ON / OFF the fan.
default: []
selector:
entity:
filter:
domain:
- switch
- binary_sensor
- input_boolean
manual_fan_switch_time_delay:
name: Manual Fan Switch Auto OFF - Time Delay
description: >
If you have enabled option 2 above, then set the auto OFF time delay.
default: 10
selector:
number:
min: 0
max: 40
step: 0.5
unit_of_measurement: minutes
notify_time_restrictions_settings:
name: "Time Restrictions"
icon: mdi:clock-outline
collapsed: true
input:
include_time:
name: Use the Time Restriction Option (Optional)
description: >
Restrict automation to the specified start and end times on the selected days.
Triggers outside this time range will be skipped.
This is useful for disableing the fan that could wake you while you're asleep, such as going to the toilet at night.
default: time_disabled
selector:
select:
options:
- label: Enable notify time restrictions
value: "time_enabled"
- label: Disable notify time restrictions
value: "time_disabled"
after_time:
name: Start Time
description: >
Set the time when fan is allowed to run.
default: 00:00:00
selector:
time:
before_time:
name: End Time
description: >
Set the time when fan should be stopped.
default: 00:00:00
selector:
time:
weekday_options:
name: Weekdays
description: >
Select which days the fan is allowed to run.
To activate this, you must enable the Time Restriction option above.
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"
bypass_settings:
name: "Bypass"
icon: mdi:cog-pause-outline
collapsed: true
input:
include_bypass:
name: Use The By-pass Options (Optional)
description: >
Select enable or disable. All of the three enable options will allow manual control of your fan.
The three enable options are only for selecting what should happen when you turn the by-pass ON.
When enabling an option, please enter the by-pass switch into the corresponding input below.
default: []
selector:
select:
options:
- label: 1 - Enable the By-pass - Turn fan ON
value: "bypass_enabled_turn_on"
- label: 2 - Enable the By-pass - Turn fan OFF
value: "bypass_enabled_turn_off"
- label: 3 - Enable the By-pass - Keep the fan current state
value: "bypass_enabled_stop"
multiple: true
bypass_fan_on:
name: By-pass Switch - Turn Fan ON
description: >
Select the switches that will turn your fan ON, By-pass the trigger sensor and make your fan function as normal.
The entity cannot be included in the "Fan" selections.
default: []
selector:
entity:
multiple: true
bypass_fan_off:
name: By-pass Switch - Turn Fan OFF
description: >
Select the switches that will turn your fan OFF, By-pass the trigger sensor and make your fan function as normal.
The entity cannot be included in the "Fan" selections.
default: []
selector:
entity:
multiple: true
bypass_fan_stop:
name: By-pass Switch - Keep The Fan Current State
description: >
Select the switches that will pause your fan, By-pass the trigger sensor and make your fan function as normal.
The entity cannot be included in the "Fan" selections.
default: []
selector:
entity:
multiple: true
include_bypass_auto_off:
name: Use The By-pass Auto OFF Option (Optional)
description: >
This is used when you turn the by-pass ON and you would like the by-pass to automatically turn OFF in a set time delay.
It can also be used as a timer to turn the fan ON and then OFF if you have chosen to use "Enable the By-pass - Turn fan ON" above.
default: []
selector:
select:
options:
- label: Enable the by-pass auto off - Turn fan ON option
value: "bypass_auto_off_enabled_on"
- label: Enable the by-pass auto off - Turn fan OFF option
value: "bypass_auto_off_enabled_off"
- label: Enable the by-pass auto off - Keep the fan current state
value: "bypass_auto_off_enabled_stop"
multiple: true
bypass_auto_off_delay:
name: By-pass Auto OFF - Time Delay
description: >
Set the by-pass auto OFF time delay. The time delay starts from the last by-pass that was turned ON.
default: 60
selector:
number:
min: 1
max: 240
step: 1
unit_of_measurement: minutes
global_conditions_settings:
name: "Global Conditions"
icon: mdi:earth
collapsed: true
input:
global_conditions:
name: Global Conditions
description: >
Enter any global conditions you would like to apply to the automation.
default: []
selector:
condition:
ha_restart:
name: "HA Restart"
icon: mdi:restart
collapsed: true
input:
include_ha_restart:
name: Use The HA Restart Option (Optional)
description: >
Select this option to activate the Home Assistant restart option.
**Note -** If you're using my "Bathroom Humidity Exhaust Fan" blueprint with the same fan, don't turn on this option.
The "Bathroom Humidity Exhaust Fan" blueprint already has its own restart safeguard. This avoids conflicts - that's why it's an option to enable or disable.
default: disable_ha_restart
selector:
select:
options:
- label: Enable the HA Restart option
value: "enable_ha_restart"
- label: Disable the HA Restart option
value: "disable_ha_restart"
# If light or motion sensor turns ON again within the time delay, it will restart the script.
mode: restart
max_exceeded: silent
variables:
entity_trigger: !input entity_trigger
trigger_options: !input trigger_options
trigger_wait_option: !input trigger_wait_option
trigger_wait_time: !input trigger_wait_time
brief_use_delay: !input brief_use_delay
safeguard_option: !input safeguard_option
safeguard: !input safeguard
fan_switch: !input fan_switch
time_delay: !input time_delay
include_lights: !input include_lights
include_light_control: !input include_light_control
light_brightness: !input light_brightness
light_transition_on: !input light_transition_on
light_transition_off: !input light_transition_off
include_light_colour_control: !input include_light_colour_control
light_colour_temperature: !input light_colour_temperature
light_rgb_colour: !input light_rgb_colour
light_rgbw_colour: !input light_rgbw_colour
light_rgbww_colour: !input light_rgbww_colour
include_night_lights: !input include_night_lights
night_lights_conditions: !input night_lights_conditions
night_lights_entity_state: !input night_lights_entity_state
night_lights_after_time: !input night_lights_after_time
night_lights_before_time: !input night_lights_before_time
night_lights_sun_elevation: !input night_lights_sun_elevation
night_lights_sun_elevation_rising: !input night_lights_sun_elevation_rising
include_night_light_control: !input include_night_light_control
night_light_brightness: !input night_light_brightness
night_light_transition_on: !input night_light_transition_on
night_light_transition_off: !input night_light_transition_off
include_night_light_colour_control: !input include_night_light_colour_control
night_light_colour_temperature: !input night_light_colour_temperature
night_light_rgb_colour: !input night_light_rgb_colour
night_light_rgbw_colour: !input night_light_rgbw_colour
night_light_rgbww_colour: !input night_light_rgbww_colour
include_manual_fan_switch: !input include_manual_fan_switch
manual_fan_switch: !input manual_fan_switch
manual_fan_switch_time_delay: !input manual_fan_switch_time_delay
include_time: !input include_time
after_time: !input after_time
before_time: !input before_time
weekday_options: !input weekday_options
include_bypass: !input include_bypass
bypass_fan_on: !input bypass_fan_on
bypass_fan_off: !input bypass_fan_off
bypass_fan_stop: !input bypass_fan_stop
include_bypass_auto_off: !input include_bypass_auto_off
bypass_auto_off_delay: !input bypass_auto_off_delay
global_conditions: !input global_conditions
include_ha_restart: !input include_ha_restart
# Split domains for light switch targets
light_entities: >
{{ expand(entity_trigger)
| selectattr('domain', 'eq', 'light')
| map(attribute='entity_id')
| list }}
# For light control - Light data
light_data: >-
{% set light = namespace(data={}) %}
{% if 'use_transition' in include_light_control %}
{% set light.data = dict(light.data, **{ 'transition': light_transition_on }) %}
{% endif %}
{% if 'use_brightness' in include_light_control %}
{% set light.data = dict(light.data, **{ 'brightness_pct': light_brightness }) %}
{% endif %}
{% if include_light_colour_control == 'use_colour_temperature' %}
{% set light.data = dict(light.data, **{ 'color_temp_kelvin': light_colour_temperature }) %}
{% endif %}
{% if include_light_colour_control == 'use_rgb_colour' %}
{% set light.data = dict(light.data, **{ 'rgb_color': light_rgb_colour }) %}
{% endif %}
{% if include_light_colour_control == 'use_rgbw_colour' %}
{% set light.data = dict(light.data, **{ 'rgbw_color': light_rgbw_colour }) %}
{% endif %}
{% if include_light_colour_control == 'use_rgbww_colour' %}
{% set light.data = dict(light.data, **{ 'rgbww_color': light_rgbww_colour }) %}
{% endif %}
{{ light.data }}
# For night light control - Light data
night_light_data: >-
{% set light = namespace(data={}) %}
{% if 'use_transition' in include_night_light_control %}
{% set light.data = dict(light.data, **{ 'transition': night_light_transition_on }) %}
{% endif %}
{% if 'use_brightness' in include_night_light_control %}
{% set light.data = dict(light.data, **{ 'brightness_pct': night_light_brightness }) %}
{% endif %}
{% if include_night_light_colour_control == 'use_colour_temperature' %}
{% set light.data = dict(light.data, **{ 'color_temp_kelvin': night_light_colour_temperature }) %}
{% endif %}
{% if include_night_light_colour_control == 'use_rgb_colour' %}
{% set light.data = dict(light.data, **{ 'rgb_color': night_light_rgb_colour }) %}
{% endif %}
{% if include_night_light_colour_control == 'use_rgbw_colour' %}
{% set light.data = dict(light.data, **{ 'rgbw_color': night_light_rgbw_colour }) %}
{% endif %}
{% if include_night_light_colour_control == 'use_rgbww_colour' %}
{% set light.data = dict(light.data, **{ 'rgbww_color': night_light_rgbww_colour }) %}
{% endif %}
{{ light.data }}
trigger:
- trigger: state
id: "t1"
entity_id: !input entity_trigger
from: "off"
to: "on"
- trigger: state
id: "t3_on"
entity_id: !input bypass_fan_on
from: "off"
to: "on"
- trigger: state
id: "t3_off"
entity_id: !input bypass_fan_off
from: "off"
to: "on"
- trigger: state
id: "t3_stop"
entity_id: !input bypass_fan_stop
from: "off"
to: "on"
- trigger: state
id: "t4_on"
entity_id: !input bypass_fan_on
from: "on"
to: "off"
- trigger: state
id: "t4_off"
entity_id: !input bypass_fan_off
from: "on"
to: "off"
- trigger: state
id: "t4_stop"
entity_id: !input bypass_fan_stop
from: "on"
to: "off"
- trigger: state
id: "t5"
entity_id: !input manual_fan_switch
from: "off"
to: "on"
- trigger: homeassistant
id: "t6"
event: start
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger normal mode
conditions:
- condition: trigger
id: 't1'
- condition: and # trigger by by-pass turning on
conditions:
- condition: trigger
id: 't3_on'
- "{{ 'bypass_enabled_turn_on' in include_bypass }}"
- condition: and # trigger by by-pass turning off
conditions:
- condition: trigger
id: 't3_off'
- "{{ 'bypass_enabled_turn_off' in include_bypass }}"
- condition: and # trigger by by-pass stop
conditions:
- condition: trigger
id: 't3_stop'
- "{{ 'bypass_enabled_stop' in include_bypass }}"
- condition: and # trigger by by-pass turning on
conditions:
- condition: trigger
id: 't4_on'
- "{{ 'bypass_enabled_turn_on' in include_bypass }}"
- condition: and # trigger by by-pass turning off
conditions:
- condition: trigger
id: 't4_off'
- "{{ 'bypass_enabled_turn_off' in include_bypass }}"
- condition: and # trigger by by-pass stop
conditions:
- condition: trigger
id: 't4_stop'
- "{{ 'bypass_enabled_stop' in include_bypass }}"
- condition: and # trigger by manual fan switch option
conditions:
- condition: trigger
id: 't5'
- condition: state
entity_id: !input manual_fan_switch
match: any
state: 'on'
- "{{ ( include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off') }}"
- condition: and # trigger by HA Restart & check if trigger sensor or manual fan switch is on
conditions:
- condition: trigger
id: 't6'
- "{{ (is_state(fan_switch, 'on')) or ((is_state(entity_trigger, 'on')) and (trigger_options == 'normal_mode_trigger')) or (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ include_ha_restart == 'enable_ha_restart' }}"
# Check The Time Options
- condition: or
conditions:
- "{{ include_time == 'time_disabled' }}"
- "{{ include_lights == 'lights_enabled' }}"
- "{{ include_night_lights == 'night_lights_enabled' }}"
- condition: and
conditions:
- condition: time
after: !input after_time
before: !input before_time
weekday: !input weekday_options
- "{{ include_time == 'time_enabled' }}"
- condition: trigger
id:
- 't3_on'
- 't3_off'
- 't3_stop'
- 't4_on'
- 't4_off'
- 't4_stop'
- 't6'
# Check Manual By-pass Options
- 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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
state: 'off'
- condition: trigger
id:
- 't3_on'
- 't3_off'
- 't3_stop'
- 't4_on'
- 't4_off'
- 't4_stop'
# Global Conditions
- condition: and
conditions: !input global_conditions
action:
- choose:
- alias: "Check if the manual fan switch option is enabled, switch is on and the trigger is off"
conditions:
- condition: trigger
id: 't5'
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ is_state(entity_trigger, 'off') }}"
sequence:
- choose:
- alias: "Check if the manual fan switch auto off is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch_auto_off' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off or the time delay passes"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
timeout:
minutes: !input manual_fan_switch_time_delay
- alias: "Turn off the manual fan switch"
action: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- alias: "Check if the manual fan switch is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Check if the manual fan switch option is enabled, switch is on and the trigger is on"
conditions:
- condition: trigger
id: 't5'
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ is_state(entity_trigger, 'on') }}"
sequence:
- choose:
- alias: "Check if the manual fan switch auto off is enabled"
conditions:
- "{{ trigger_wait_option == 'wait_for_trigger' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "By-pass is turned on & check by-pass option - turn fan off"
conditions:
- condition: trigger
id: 't3_off'
sequence:
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- 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
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_on' in include_bypass) and ('bypass_auto_off_enabled_on' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_on
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_off' in include_bypass) and ('bypass_auto_off_enabled_off' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_off
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_stop' in include_bypass) and ('bypass_auto_off_enabled_stop' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_stop
- stop: "Stop the automation"
else:
- stop: "Stop the automation"
- alias: "By-pass is turned on & check by-pass option - Keep the current fan state"
conditions:
- condition: trigger
id: 't3_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
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_on' in include_bypass) and ('bypass_auto_off_enabled_on' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_on
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_off' in include_bypass) and ('bypass_auto_off_enabled_off' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_off
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_stop' in include_bypass) and ('bypass_auto_off_enabled_stop' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_stop
- stop: "Stop the automation"
else:
- stop: "Stop the automation"
- alias: "Normal Mode - By-pass is turned off & check if the trigger sensor and manual fan switch is off"
conditions:
- condition: template
value_template: "{{ trigger_options == 'normal_mode_trigger' }}"
- condition: trigger
id:
- 't4_on'
- 't4_off'
- 't4_stop'
- condition: and
conditions:
- "{{ is_state(entity_trigger, 'off') }}"
- condition: or
conditions:
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch') and (is_state(manual_fan_switch, 'off')) }}"
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off') and (is_state(manual_fan_switch, 'off')) }}"
- "{{ include_manual_fan_switch == 'disable_manual_fan_switch' }}"
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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
state: 'off'
sequence:
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "trigger sensor 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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
match: any
state: 'on'
sequence:
- stop: "Stop the automation"
- alias: "Normal Mode - By-pass is turned off & check if the trigger sensor or the manual fan switch is on"
conditions:
- condition: template
value_template: "{{ trigger_options == 'normal_mode_trigger' }}"
- condition: trigger
id:
- 't4_on'
- 't4_off'
- 't4_stop'
- condition: or
conditions:
- "{{ is_state(entity_trigger, 'on') }}"
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch') and (is_state(manual_fan_switch, 'on')) }}"
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off') and (is_state(manual_fan_switch, '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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
state: 'off'
- condition: or
conditions:
- condition: and
conditions:
- condition: time
after: !input before_time
before: !input after_time
- "{{ include_time == 'time_enabled' }}"
sequence:
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Trigger sensor 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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
match: any
state: 'on'
sequence:
- stop: "Stop the automation"
- alias: "Check if the manual fan switch option is enabled, manual fan switch is on and the trigger is off"
conditions:
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ not is_state(entity_trigger, 'on') }}"
sequence:
- choose:
- alias: "Check if the manual fan switch auto off is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch_auto_off' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off or the time delay passes"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
timeout:
minutes: !input manual_fan_switch_time_delay
- alias: "Turn off the manual fan switch"
action: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- alias: "Check if the manual fan switch is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Inverted Mode - By-pass is turned off & check if the trigger sensor and the manual fan switch is off"
conditions:
- condition: template
value_template: "{{ trigger_options == 'inverted_trigger' }}"
- condition: trigger
id:
- 't4_on'
- 't4_off'
- 't4_stop'
- "{{ is_state(entity_trigger, 'off') }}"
- condition: or
conditions:
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch') and (is_state(manual_fan_switch, 'off')) }}"
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off') and (is_state(manual_fan_switch, 'off')) }}"
- "{{ include_manual_fan_switch == 'disable_manual_fan_switch' }}"
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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
state: 'off'
sequence:
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Trigger sensor 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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
match: any
state: 'on'
sequence:
- stop: "Stop the automation"
- alias: "Inverted Mode - By-pass is turned off & check if the trigger sensor or the manual fan switch is on"
conditions:
- condition: template
value_template: "{{ trigger_options == 'inverted_trigger' }}"
- condition: trigger
id:
- 't4_on'
- 't4_off'
- 't4_stop'
- condition: or
conditions:
- "{{ is_state(entity_trigger, 'on') }}"
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, '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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
state: 'off'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
state: 'off'
- condition: or
conditions:
- condition: and
conditions:
- condition: time
after: !input before_time
before: !input after_time
- "{{ include_time == 'time_enabled' }}"
sequence:
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Trigger sensor 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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_on
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_off
match: any
state: 'on'
- condition: state
entity_id: !input bypass_fan_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 bypass_fan_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 bypass_fan_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 bypass_fan_stop
match: any
state: 'on'
sequence:
- stop: "Stop the automation"
- alias: "Check if the manual fan switch option is enabled, manual fan switch is on and the trigger is off"
conditions:
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ not is_state(entity_trigger, 'on') }}"
sequence:
- choose:
- alias: "Check if the manual fan switch auto off is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch_auto_off' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off or the time delay passes"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
timeout:
minutes: !input manual_fan_switch_time_delay
- alias: "Turn off the manual fan switch"
action: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- alias: "Check if the manual fan switch is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- alias: "Check if the trigger sensor is on"
conditions:
- "{{ is_state(entity_trigger, 'on') }}"
sequence:
- choose:
- alias: "Set the transition for the lights"
conditions:
- "{{ (is_state(entity_trigger, 'on')) and (is_state(manual_fan_switch, 'off')) }}"
sequence:
- alias: "Wait until trigger is off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
- alias: "Set the transition for the lights"
conditions:
- "{{ (is_state(entity_trigger, 'on')) and (is_state(manual_fan_switch, 'on')) }}"
sequence:
- delay: 0
- alias: "Safe Guard when HA restarts"
conditions:
- condition: trigger
id: 't6'
sequence:
- choose:
- alias: "Check if enabled manual fan switch is enabled and trigger is off"
conditions:
- "{{ (((include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off')) and (is_state(manual_fan_switch, 'on'))) }}"
- "{{ is_state(entity_trigger, 'off') }}"
sequence:
- choose:
- alias: "Check if the manual fan switch auto off is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch_auto_off' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off or the time delay passes"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
timeout:
minutes: !input manual_fan_switch_time_delay
- alias: "Turn off the manual fan switch"
action: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- alias: "Check if the manual fan switch is enabled"
conditions:
- "{{ include_manual_fan_switch == 'enable_manual_fan_switch' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
trigger: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- choose:
- alias: "Default & prefom trigger options"
conditions:
- condition: trigger
id:
- 't1'
- 't3_on'
- 't4_on'
- 't4_off'
- 't4_stop'
- 't5'
- 't6'
sequence:
- choose:
- alias: "Check if night lights are enabled and within conditions"
conditions:
- condition: and
conditions:
- alias: "Check if night lights is enabled"
condition: or
conditions:
- "{{ include_night_lights == 'night_lights_enabled' }}"
- alias: "Check if night lights entity state is enabled"
condition: or
conditions:
- "{{ ('time_enabled' in night_lights_conditions) and not ('entity_state_enabled' in night_lights_conditions) }}"
- "{{ ('sun_enabled' in night_lights_conditions) and not ('entity_state_enabled' in night_lights_conditions) }}"
- condition: and
conditions:
- "{{ 'entity_state_enabled' in night_lights_conditions }}"
- condition: state
entity_id: !input night_lights_entity_state
state: 'on'
match: any
- alias: "Check if night lights time is enabled"
condition: or
conditions:
- "{{ ('entity_state_enabled' in night_lights_conditions) and not ('time_enabled' in night_lights_conditions) }}"
- "{{ ('sun_enabled' in night_lights_conditions) and not ('time_enabled' in night_lights_conditions) }}"
- condition: and
conditions:
- "{{ 'time_enabled' in night_lights_conditions }}"
- condition: time
after: !input night_lights_after_time
before: !input night_lights_before_time
- alias: "Check if night lights sun is enabled"
condition: or
conditions:
- "{{ ('entity_state_enabled' in night_lights_conditions) and not ('sun_enabled' in night_lights_conditions) }}"
- "{{ ('time_enabled' in night_lights_conditions) and not ('sun_enabled' in night_lights_conditions) }}"
- "{{ ('sun_enabled' in night_lights_conditions) and (((is_state_attr('sun.sun', 'rising', false)) and (state_attr('sun.sun','elevation') <= night_lights_sun_elevation | float(90))) or ((is_state_attr('sun.sun', 'rising', true)) and (state_attr('sun.sun','elevation') <= night_lights_sun_elevation_rising | float(90)))) }}"
- alias: "Check not bypass turning ON or HA restart"
condition: not
conditions:
- condition: trigger
id:
- 't3_on'
- 't6'
sequence:
- alias: "Turn ON lights"
action: light.turn_on
target:
entity_id: "{{ light_entities }}"
data: "{{ night_light_data }}"
- alias: "Check if night lights are enabled and within conditions"
conditions:
- "{{ include_lights == 'lights_enabled'}}"
- alias: "Check not bypass turning ON or HA restart"
condition: not
conditions:
- condition: trigger
id:
- 't3_on'
- 't6'
sequence:
- alias: "Turn ON lights"
action: light.turn_on
target:
entity_id: "{{ light_entities }}"
data: "{{ light_data }}"
- choose:
- alias: "Check the Time Restriction Option"
conditions:
- "{{ include_time == 'time_enabled' }}"
- condition: time
after: !input before_time
before: !input after_time
weekday: !input weekday_options
sequence:
- choose:
- alias: "Check some triggers"
conditions:
- condition: not
conditions:
- condition: trigger
id:
- 't3_on'
- 't4_on'
- 't4_off'
- 't4_stop'
- 't6'
sequence:
- stop: "Stop the automation"
- choose:
- alias: "Check if a trigger wait option is set"
conditions:
- condition: template
value_template: "{{ (trigger_wait_option == 'wait_for_trigger') or (trigger_wait_option == 'turn_on_and_wait_for_trigger') }}"
- condition: not
conditions:
- condition: trigger
id: 't3_on'
sequence:
- choose:
- alias: "Check if the trigger is set to normal mode"
conditions:
- condition: template
value_template: "{{ trigger_options == 'normal_mode_trigger' }}"
sequence:
- choose:
- alias: "Check if the fan is off"
conditions:
- "{{ is_state(fan_switch, 'off') }}"
sequence:
- choose:
- alias: "Check if the trigger wait option is set"
conditions:
- condition: template
value_template: "{{ trigger_wait_option == 'wait_for_trigger' }}"
sequence:
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input trigger_wait_time
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "off"
sequence:
- stop: "Stop the automation"
- alias: "Check if the trigger turn on and wait option is set"
conditions:
- condition: template
value_template: "{{ trigger_wait_option == 'turn_on_and_wait_for_trigger' }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input trigger_wait_time
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "off"
sequence:
- alias: "Wait for the brief use delay"
delay:
minutes: !input brief_use_delay
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- choose:
- alias: "Check if the trigger is set to inverted trigger"
conditions:
- condition: template
value_template: "{{ trigger_options == 'inverted_trigger' }}"
sequence:
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "on"
sequence:
- choose:
- alias: "Check if the trigger wait option is set"
conditions:
- condition: template
value_template: "{{ trigger_wait_option == 'wait_for_trigger' }}"
sequence:
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input trigger_wait_time
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "off"
- "{{ is_state(fan_switch, 'off') }}"
sequence:
- stop: "Stop the automation"
- alias: "Check if the trigger turn on and wait option is set"
conditions:
- condition: template
value_template: "{{ trigger_wait_option == 'turn_on_and_wait_for_trigger' }}"
sequence:
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input trigger_wait_time
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "off"
- "{{ is_state(fan_switch, 'off') }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait for the brief use delay"
delay:
minutes: !input brief_use_delay
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
- stop: "Stop the automation"
- choose:
- alias: "Check the trigger state"
conditions:
- condition: state
entity_id: !input entity_trigger
state: "on"
sequence:
- alias: "Wait for the trigger to turn off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
- choose:
- alias: "Check if the trigger is set to inverted and dont use the trigger wait time"
conditions:
- condition: template
value_template: "{{ trigger_options == 'inverted_trigger' }}"
- "{{ trigger_wait_option == 'fire_on_trigger' }}"
- condition: not
conditions:
- condition: trigger
id: 't3_on'
sequence:
- alias: "Wait for the trigger to turn off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
- choose:
- alias: "Check the trigger state"
conditions:
- "{{ is_state(fan_switch, 'off') }}"
sequence:
- alias: "Turn on the fan"
action: homeassistant.turn_on
entity_id: !input fan_switch
- choose:
- alias: "By-pass is enabled & check by-pass option - turn fan on"
conditions:
- condition: trigger
id: 't3_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
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_on' in include_bypass) and ('bypass_auto_off_enabled_on' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_on
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_turn_off' in include_bypass) and ('bypass_auto_off_enabled_off' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_off
- choose:
- conditions:
- condition: template
value_template: "{{ ('bypass_enabled_stop' in include_bypass) and ('bypass_auto_off_enabled_stop' in include_bypass_auto_off) }}"
sequence:
- alias: "Turn off the by-pass"
action: homeassistant.turn_off
entity_id: !input bypass_fan_stop
- stop: "Stop the automation"
else:
- stop: "Stop the automation"
- choose:
- alias: "Check if the trigger is set to normal mode"
conditions:
- condition: template
value_template: "{{ trigger_options == 'normal_mode_trigger' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ safeguard_option == 'enable_safeguard' }}"
sequence:
- alias: "Wait until trigger is off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input safeguard
- conditions:
- condition: template
value_template: "{{ safeguard_option == 'enable_safeguard_and_trigger' }}"
sequence:
- alias: "Wait until trigger is off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
timeout:
minutes: !input safeguard
- choose:
- conditions:
- condition: template
value_template: "{{ states(entity_trigger) == 'on' }}"
sequence:
- alias: "Turn OFF trigger"
action: homeassistant.turn_off
entity_id: !input entity_trigger
- conditions:
- condition: template
value_template: "{{ safeguard_option == 'disable_safeguard' }}"
sequence:
- alias: "Wait until trigger is off"
wait_for_trigger:
trigger: state
entity_id: !input entity_trigger
from: "on"
to: "off"
- alias: "Wait for the delay time"
delay:
minutes: !input time_delay
- choose:
- alias: "Check if the manual fan switch option is enabled and switch is on"
conditions:
- "{{ (include_manual_fan_switch == 'enable_manual_fan_switch') or (include_manual_fan_switch == 'enable_manual_fan_switch_auto_off') }}"
- "{{ is_state(manual_fan_switch, 'on') }}"
sequence:
- alias: "Turn OFF manual fan switch"
action: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
action: homeassistant.turn_off
entity_id: !input fan_switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment