Hello, I am trying to create a blueprint to control the covers at a given time. However I would like to have a condition to choose the weekdays.
When creating automations we can create a condition to chose the weekdays and I would love to do the same in the blueprints but I did not find that in the documentation or in other blueprints as an example.
I have a prototype that works but it’s not that awesome - but it was more of a proof of concept
blueprint:
name: Scheduled Actions
domain: automation
description: This automation will let you setup a weekly / time-based scheduled task.
input:
start_time:
name: Start Time
description: Time action should start
selector:
time:
end_time:
name: End Time
description: Time action should stop
selector:
time:
run_on_sunday:
name: Run on Sunday
description: Should this action run on Sundays
selector:
boolean:
run_on_monday:
name: Run on Monday
description: Should this action run on Mondays
selector:
boolean:
run_on_tuesday:
name: Run on Tuesday
description: Should this action run on Tuesdays
selector:
boolean:
run_on_wednesday:
name: Run on Wednesday
description: Should this action run on Wednesdays
selector:
boolean:
run_on_thursday:
name: Run on Thursday
description: Should this action run on Thursdays
selector:
boolean:
run_on_friday:
name: Run on Friday
description: Should this action run on Fridays
selector:
boolean:
run_on_saturday:
name: Run on Saturday
description: Run on the sabbath?
selector:
boolean:
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications
selector:
device:
integration: mobile_app
variables:
run_on_sunday: !input run_on_sunday
run_on_monday: !input run_on_monday
run_on_tuesday: !input run_on_tuesday
run_on_wednesday: !input run_on_wednesday
run_on_thursday: !input run_on_thursday
run_on_friday: !input run_on_friday
run_on_saturday: !input run_on_saturday
trigger_variables:
run_on_sunday: !input run_on_sunday
run_on_monday: !input run_on_monday
run_on_tuesday: !input run_on_tuesday
run_on_wednesday: !input run_on_wednesday
run_on_thursday: !input run_on_thursday
run_on_friday: !input run_on_friday
run_on_saturday: !input run_on_saturday
trigger:
- platform: time
at: !input start_time
id: "start_trigger"
- platform: time
at: !input end_time
id: "end_trigger"
action:
- choose:
- conditions:
# Turn On Time
- alias: Day of the week match
condition: template
value_template: |-
{{ ((now().strftime('%A') == 'Sunday') and run_on_sunday) or
((now().strftime('%A') == 'Monday') and run_on_monday) or
((now().strftime('%A') == 'Tuesday') and run_on_tuesday) or
((now().strftime('%A') == 'Wednesday') and run_on_wednesday) or
((now().strftime('%A') == 'Thursday') and run_on_thursday) or
((now().strftime('%A') == 'Friday') and run_on_friday) or
((now().strftime('%A') == 'Saturday') and run_on_saturday) }}
- alias: Start Trigger
condition: trigger
id: "start_trigger"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
message: Starting - On/Off [Day Match]
- conditions:
# Turn Off Time
- alias: Day of the week match
condition: template
value_template: |-
{{ ((now().strftime('%A') == 'Sunday') and run_on_sunday) or
((now().strftime('%A') == 'Monday') and run_on_monday) or
((now().strftime('%A') == 'Tuesday') and run_on_tuesday) or
((now().strftime('%A') == 'Wednesday') and run_on_wednesday) or
((now().strftime('%A') == 'Thursday') and run_on_thursday) or
((now().strftime('%A') == 'Friday') and run_on_friday) or
((now().strftime('%A') == 'Saturday') and run_on_saturday) }}
- alias: End Trigger
condition: trigger
id: "end_trigger"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
message: Stopping - On/Off [Day match]
default:
- device_id: !input notify_device
domain: mobile_app
type: notify
message: Default - On/Off Default [Did not match day]
But it does print out a start/end message on my phone at the specified time window… If somebody wants to roll with it this is where I left off.
The logic is sound → and the notifications do come across as specified … I’d love to see something like this get into a base component of HA → but until then … you can copy this code and modify it…
I was thinking of going with an On-Action / Off-Action … just never got around to it and honestly I forgot until you reminded me