Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active October 27, 2024 20:00
Show Gist options
  • Save Blackshome/ec0afd31dce7fc6b106e378d06b01940 to your computer and use it in GitHub Desktop.
Save Blackshome/ec0afd31dce7fc6b106e378d06b01940 to your computer and use it in GitHub Desktop.
timer.yaml
blueprint:
name: Timer
description: >
# ⏲️ Timer
**Version: 1.2**
Effortless Control: Schedule 📅, Trigger ⚡, and Automate Your Home 🏠 with Precision 🎯!
**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>
- **Automation:**
- Turn ON and OFF any entity you like on a set time.
- You must use a timer helper for this automation to work.
- **Multiple Timers:**
- You can set up to 4 different time triggers, each with its own time period.
- **Weekdays Condition Option:**
- Specify the weekdays to define when the automation can run.
</details>
Need help?
- FAQ: [Click Here](https://community.home-assistant.io/t/time-clock/651151/2)
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/time-clock/651151)
Required = *
domain: automation
input:
settings:
name: "Settings *"
icon: mdi:cog-outline
collapsed: true
input:
timer_helper:
name: Timer - Timer Helper *
description: Select the timer helper to be used for all timers.
Using a timer helper provides flexibility to start, pause, and cancel timers, persistence across reboots, and real-time monitoring, making your automations more robust and adaptable.
For more information on how to create a timer helper [Click Here](https://community.home-assistant.io/t/651151/4?u=blacky)
default: []
selector:
entity:
filter:
domain:
- timer
entity_input:
name: Entities To Turn ON *
description: Specify the entities that will be turned ON by a start time and OFF after the set duration.
default: []
selector:
target:
triggers:
name: "Triggers"
icon: mdi:clock-outline
collapsed: true
input:
trigger_one_time:
name: Timer One - Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
trigger_one_duration:
name: Timer One - Duration
description: Set the duration for Timer One.
default: 00:00:00
selector:
duration:
include_extra_triggers:
name: Use The Extra Timers (Optional)
description: Select any additional timers you want to include.
default: []
selector:
select:
multiple: true
options:
- label: Use timer two
value: "use_trigger_two"
- label: Use timer three
value: "use_trigger_three"
- label: Use timer four
value: "use_trigger_four"
trigger_two_time:
name: Timer Two - Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
trigger_two_duration:
name: Timer Two - Duration
description: Set the duration for Timer Two.
default: 00:00:00
selector:
duration:
trigger_three_time:
name: Timer Three - Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
trigger_three_duration:
name: Timer Three - Duration
description: Set the duration for Timer Three.
default: 00:00:00
selector:
duration:
trigger_four_time:
name: Timer Four - Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
trigger_four_duration:
name: Timer Four - Duration
description: Set the duration for Timer Four.
default: 00:00:00
selector:
duration:
weekdays:
name: "Weekdays"
icon: mdi:calendar-week
collapsed: true
input:
include_weekdays:
name: Use The Weekdays Option (Optional)
description: This option adds a condition to operate only on specified weekdays. It applies globally to all start times.
default: weekday_disabled
selector:
select:
options:
- label: Enable the weekday option
value: "weekday_enabled"
- label: Disable the weekday option
value: "weekday_disabled"
weekday_options:
name: Weekdays
description: Select the days of the week on which you want the automation to run.
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"
mode: restart
max_exceeded: silent
variables:
trigger_one_duration: !input trigger_one_duration
entity_input: !input entity_input
timer_helper: !input timer_helper
trigger_one_time: !input trigger_one_time
include_extra_triggers: !input include_extra_triggers
trigger_two_time: !input trigger_two_time
trigger_two_duration: !input trigger_two_duration
trigger_three_time: !input trigger_three_time
trigger_three_duration: !input trigger_three_duration
trigger_four_time: !input trigger_four_time
trigger_four_duration: !input trigger_four_duration
include_weekdays: !input include_weekdays
weekday_options: !input weekday_options
trigger:
- platform: time
at: !input trigger_one_time
id: 't1'
- platform: time
at: !input trigger_two_time
id: 't2'
- platform: time
at: !input trigger_three_time
id: 't3'
- platform: time
at: !input trigger_four_time
id: 't4'
- platform: state
entity_id: !input timer_helper
to: "idle"
id: 't5'
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger for ON and OFF state
conditions:
- condition: trigger
id:
- 't1'
- condition: and
conditions:
- condition: trigger
id: 't2'
- "{{ 'use_trigger_two' in include_extra_triggers }}"
- condition: and
conditions:
- condition: trigger
id: 't3'
- "{{ 'use_trigger_three' in include_extra_triggers }}"
- condition: and
conditions:
- condition: trigger
id: 't4'
- "{{ 'use_trigger_four' in include_extra_triggers }}"
- condition: and # trigger for end timer helper
conditions:
- condition: trigger
id: 't5'
# Check The Weekday Option
- condition: or
conditions:
- "{{ include_weekdays == 'weekday_disabled' }}"
- condition: and
conditions:
- condition: time
weekday: !input weekday_options
- "{{ include_weekdays == 'weekday_enabled' }}"
- condition: trigger
id:
- 't5'
action:
- choose:
- alias: "Check if the time helper is enabled"
conditions:
- condition: trigger
id:
- 't1'
- 't2'
- 't3'
- 't4'
sequence:
- alias: "Turn ON the entities"
service: homeassistant.turn_on
target: !input entity_input
- choose:
- alias: "By-pass is turned on & check by-pass option - turn lights off"
conditions:
- condition: trigger
id:
- 't1'
sequence:
- alias: "Turn ON the timer helper"
service: timer.start
entity_id: !input timer_helper
data:
duration: !input trigger_one_duration
- alias: "By-pass is turned on & check by-pass option - turn lights off"
conditions:
- condition: trigger
id:
- 't2'
sequence:
- alias: "Turn ON the timer helper"
service: timer.start
entity_id: !input timer_helper
data:
duration: !input trigger_two_duration
- alias: "By-pass is turned on & check by-pass option - turn lights off"
conditions:
- condition: trigger
id:
- 't3'
sequence:
- alias: "Turn ON the timer helper"
service: timer.start
entity_id: !input timer_helper
data:
duration: !input trigger_three_duration
- alias: "By-pass is turned on & check by-pass option - turn lights off"
conditions:
- condition: trigger
id:
- 't4'
sequence:
- alias: "Turn ON the timer helper"
service: timer.start
entity_id: !input timer_helper
data:
duration: !input trigger_four_duration
- alias: "Turn OFF entities after the timer helper is finished"
conditions:
- condition: trigger
id:
- 't5'
sequence:
- alias: "Turn OFF the entities"
service: homeassistant.turn_off
target: !input entity_input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment