Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active April 19, 2024 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blackshome/70349658a0c7543dbaa5f2e69e10cce0 to your computer and use it in GitHub Desktop.
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.5**
🚽 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> - Click here to expand</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.
- **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 Option:**
- This setting is ideal for instances when the fan isn't necessary during a brief use (e.g., for a short visit), but for longer use (e.g., for an extended visit) that typically requires the fan, the light being ON for a set amount of time will prompt the fan to turn ON.
- **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/bathroom-humidity-exhaust-fan/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? See our FAQ: [Click Here](https://community.home-assistant.io/t/toilet-exhaust-fan-time-delay/478954/7?u=blacky)
Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/toilet-exhaust-fan-with-time-delay/478954)
Required = *
domain: automation
input:
entity_trigger:
name: Trigger Sensor *
description: The trigger is typically either a light switch or a motion sensor. However, any entity capable of toggling between an ON and OFF state can serve as the trigger.
selector:
entity:
fan_switch:
name: Fan *
description: The fan that gets turned on by the trigger sensor.
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"
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
trigger_wait_option:
name: Trigger Wait Option (Optional)
description: The trigger (Light) needs to remain ON for a designated period before activating the fan.
This setting is ideal for instances when the fan isn't necessary during a brief use (e.g., for a short visit).
However, for longer use (e.g., for an extended visit), typically associated with the need for the fan, the light being ON for X amount of time will prompt the fan to turn ON.
If selecting this setting, please specify the trigger wait time below.
default: fire_on_trigger
selector:
select:
options:
- label: Use the wait time
value: "wait_for_trigger"
- label: Dont use the wait time
value: "fire_on_trigger"
trigger_wait_time:
name: Trigger Wait Time
description: The time the trigger (Light) needs to remain ON before turning the fan ON.
default: 3
selector:
number:
min: 0
max: 10
step: 0.2
unit_of_measurement: minutes
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
include_time:
name: Use The Time Options (Optional)
description: Use the "Start Time", "End Time" and the "Weekdays" values to only run the automation between the time periods.
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.
default: time_disabled
selector:
select:
options:
- label: Enable the time options
value: "time_enabled"
- label: Disable the time options
value: "time_disabled"
after_time:
name: Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
before_time:
name: End Time
description: Set the end time.
default: 00:00:00
selector:
time:
weekday_options:
name: Weekdays
description: Select the days of the week you would like the automation to run.
You must select "Enable the time options" above for the weekdays selections to work.
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
multiple: true
mode: list
options:
- label: Monday
value: "mon"
- label: Tuesday
value: "tue"
- label: Wednesday
value: "wed"
- label: Thursday
value: "thu"
- label: Friday
value: "fri"
- label: Saturday
value: "sat"
- label: Sunday
value: "sun"
include_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:
name: Global Conditions
description: Enter any global conditions you would like to apply to the automation.
default: []
selector:
condition:
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
fan_switch: !input fan_switch
trigger_options: !input trigger_options
time_delay: !input time_delay
trigger_wait_option: !input trigger_wait_option
trigger_wait_time: !input trigger_wait_time
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
trigger:
- platform: state
id: "t1"
entity_id: !input entity_trigger
from: "off"
to: "on"
- platform: state
id: "t3_on"
entity_id: !input bypass_fan_on
from: "off"
to: "on"
- platform: state
id: "t3_off"
entity_id: !input bypass_fan_off
from: "off"
to: "on"
- platform: state
id: "t3_stop"
entity_id: !input bypass_fan_stop
from: "off"
to: "on"
- platform: state
id: "t4_on"
entity_id: !input bypass_fan_on
from: "on"
to: "off"
- platform: state
id: "t4_off"
entity_id: !input bypass_fan_off
from: "on"
to: "off"
- platform: state
id: "t4_stop"
entity_id: !input bypass_fan_stop
from: "on"
to: "off"
- platform: state
id: "t5"
entity_id: !input manual_fan_switch
from: "off"
to: "on"
- platform: homeassistant
id: "t6"
event: start
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger normal mode
conditions:
- "{{ (trigger_wait_option == 'fire_on_trigger') or (trigger_wait_option == 'wait_for_trigger') }}"
- 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: state
entity_id: !input manual_fan_switch
match: any
state: 'on'
- condition: trigger
id: 't5'
- "{{ ( 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:
- "{{ (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' }}"
- condition: trigger
id: 't6'
# Check The Time Options
- condition: or
conditions:
- "{{ include_time == 'time_disabled' }}"
- condition: and
conditions:
- condition: time
after: !input after_time
before: !input before_time
weekday: !input weekday_options
- "{{ include_time == 'time_enabled' }}"
- condition: trigger
id:
- '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"
service: 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:
platform: 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"
service: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
service: 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"
service: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
platform: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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"
service: 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:
platform: 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"
service: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
service: 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"
service: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
platform: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
service: 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"
service: 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"
service: 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"
service: 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:
platform: 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"
service: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
service: 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"
service: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
platform: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
service: 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:
platform: 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:
- 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"
service: 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:
platform: 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"
service: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
service: 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"
service: homeassistant.turn_on
entity_id: !input fan_switch
- alias: "Wait until the manual fan switch is turned off"
wait_for_trigger:
platform: state
entity_id: !input manual_fan_switch
from: "on"
to: "off"
- alias: "Turn off the fan"
service: 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 the trigger wait option is set"
conditions:
- condition: template
value_template: "{{ trigger_wait_option == '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 trigger wait option is set"
conditions:
- "{{ is_state(fan_switch, 'off') }}"
sequence:
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
platform: 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"
- 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:
- alias: "Wait for the trigger to be on for the trigger wait time"
wait_for_trigger:
platform: 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"
- 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:
platform: 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:
platform: state
entity_id: !input entity_trigger
from: "on"
to: "off"
- alias: "Turn on the fan"
service: 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"
service: 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"
service: 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"
service: 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:
- alias: "Wait until trigger is off"
wait_for_trigger:
platform: 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"
service: homeassistant.turn_off
entity_id: !input manual_fan_switch
- alias: "Turn off the fan"
service: 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