[WIP] - Day / Time selector

This is a work in progress but some folks have asked if there is a way to schedule an action on a combo of day/time

I’ve prototyped out a blueprint automation that lets you select Days and a start/time + end time. Currently it just sends a notification to a device but for folks interested you can probably mod what I have to something more useful. Ultimately I hope to release a generic blueprint that will let you choose what/when to do at a given time.

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
      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
    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
          - 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) }}
          - 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
          - 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) }}
          - 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]

2 Likes

Hello
I would need a template like this to turn the entity on and off.
This is a sonoff entity.
Thank you in advance
I agree for translation, translated by google
I am from Czech

Did you get this working?

Podařilo se vám to?

I realize this was a few months ago, but in case you still care, or in case it will help someone else, there’s another way to do conditions for certain weekdays in a blueprint pulled from the selectors…

It may not have been available 6 months ago, but it is available now.

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:
    weekday:
      name: Day of the week to use the Automation
      default: [mon, tue, wed, thu, fri, sat, sun]
      selector:
        select:
          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
          custom_value: false
          multiple: true
    notify_device:
      name: Device to notify
      description: Device needs to run the official Home Assistant app to receive notifications
      selector:
        device:
          integration: mobile_app
trigger:
  - platform: time
    at: !input start_time
    id: "start_trigger"
  - platform: time
    at: !input end_time
    id: "end_trigger"

action:
- choose:
  - conditions:
    - condition: time
      weekday: !input 'weekday'
    sequence:
      - device_id: !input notify_device
        domain: mobile_app
        type: notify
        message: On/Off [Day Match]
  default:
    - device_id: !input notify_device
      domain: mobile_app
      type: notify
      message: Default - On/Off Default [Did not match day]

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like

Pretty sure it came out in the last 2-3 months if I recall correctly

Bonsoir,
Comment fait-on pour avoir ce programme ? car je suis débutant,merci

Ce programme n’est pas pour les débutants. Désolé

1 Like

ça me fait pensée au patron qui recrute , pas d’expériences passez votre chemin, humour .

J’utilise google translate donc mon français est très merdique

What program are you referring to?
That previous post is just a Home Assistant Blueprint.

I added an import link to the post if it will help you out.

1 Like

Bonjour,
Je viens seulement de voir le message,merci de la réponse, je n’arrivais pas à importer les URL de votre instance https://192…il était mal configuré,je viens juste de savoir le faire.

Hello,
Thank you for sharing, the result is very good.
I would like to use it to program my automatic watering.
I have “Wooz R7054”: Woox R7060 control via MQTT | Zigbee2MQTT

How do I assign a device in this blueprint?
It is for ON/OFF action
I would also like to be able to enable or disable notifications on mobile.

Thanks in advance
Good day

I do not know how to activate a device with this automation. I am not that good with automations. In this case it is just a switch that I need to turn on and off
switch.sprinkler

Im pretty sure this stuff got built into core in the last 2 years so you can just use a schedule inside HA