Skip to content

Instantly share code, notes, and snippets.

@Lennix
Created October 26, 2025 10:29
Show Gist options
  • Save Lennix/3334f992ea14b1a196abea1bcbace391 to your computer and use it in GitHub Desktop.
Save Lennix/3334f992ea14b1a196abea1bcbace391 to your computer and use it in GitHub Desktop.
Simple home assistant scheduled on/off blueprint
blueprint:
name: Scheduled Off Window for a Switch (overnight-friendly)
description: >
Keep a switch OFF between two times (e.g., night) and ON outside that window.
Works across midnight; respects selected weekdays; restores correct state on HA restart/automation reload.
domain: automation
source_url: https://example.local/blueprints/scheduled_off_window_switch
input:
target_switch:
name: Target switch
description: The switch entity to control (e.g., your circulation pump)
selector:
entity:
domain: switch
off_start:
name: Off start time
description: Time of day when the switch should turn OFF
selector:
time:
off_end:
name: Off end time
description: Time of day when the switch should turn ON
selector:
time:
weekdays:
name: Weekdays
description: Days when this schedule applies
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: single
max_exceeded: silent
trigger:
- platform: time
at: !input off_start
id: off_start
- platform: time
at: !input off_end
id: off_end
- platform: homeassistant
event: start
id: ha_start
- platform: event
event_type: automation_reloaded
id: auto_reload
condition: []
action:
- choose:
# Turn OFF exactly at off_start on selected weekdays
- conditions:
- condition: trigger
id: off_start
- condition: time
weekday: !input weekdays
sequence:
- service: switch.turn_off
target:
entity_id: !input target_switch
# Turn ON exactly at off_end on selected weekdays
- conditions:
- condition: trigger
id: off_end
- condition: time
weekday: !input weekdays
sequence:
- service: switch.turn_on
target:
entity_id: !input target_switch
# On HA start / automation reload, enforce the correct state
- conditions:
- condition: or
conditions:
- condition: trigger
id: ha_start
- condition: trigger
id: auto_reload
sequence:
- choose:
# If we're currently in the OFF window on a selected weekday, ensure OFF
- conditions:
- condition: time
after: !input off_start
before: !input off_end
- condition: time
weekday: !input weekdays
sequence:
- service: switch.turn_off
target:
entity_id: !input target_switch
default:
# Otherwise ensure ON (outside off window or not a selected weekday)
- service: switch.turn_on
target:
entity_id: !input target_switch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment