Replacing Google Daylong Routines with HomeAssistant

Hey there,

I’m looking for a way to replace my daylong routines in Google with something in HomeAssistant. I tried creating an automation using if-else statements, and wait for time options and it is not working to run the automations at the times set.

Here is a copy of the YAML that I’m trying to use

alias: Workday Automation Test
description: ""
trigger:
  - platform: time
    at: "08:55:00"
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: "on"
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
action:
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: script.start_workday
        data: {}
  - wait_for_trigger:
      - platform: time
        at: "09:00:00"
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: script.checkin
        data: {}
  - wait_for_trigger:
      - platform: time
        at: "10:00:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: tts.google_translate_say
        data:
          cache: false
          entity_id: media_player.speaker_group
          message: "Message "
  - wait_for_trigger:
      - platform: time
        at: "13:30:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: tts.google_translate_say
        data:
          cache: false
          entity_id: media_player.speaker_group
          message: >-
            "Message"
  - wait_for_trigger:
      - platform: time
        at: "16:00:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
    continue_on_timeout: false
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: tts.google_translate_say
        data:
          cache: false
          entity_id: media_player.speaker_group
          message: "Message "
  - wait_for_trigger:
      - platform: time
        at: "16:55:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
    continue_on_timeout: false
  - if:
      - condition: state
        entity_id: input_boolean.holiday
        state: "off"
    then:
      - service: script.announce_the_time
        data: {}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.speaker_group
            to: idle
      - service: tts.google_translate_say
        data:
          cache: false
          entity_id: media_player.speaker_group
          message: >-
            "Message"
mode: single

I have redacted some of the finer details

Right now I have the 8:55AM session go off normally, then the 9:00AM one the rest all go off simultaneously

Can anyone make suggestions how to fix this or if there is a better way for me to do this?

First off, this topic is about help with Blueprints. Since there are no BP’s involved in the code you provide, I would suggest going in the top of the message and changing the topic to one that fits better. You are likely to get a better answer there.

Second,you have set as conditions of any trigger that input_boolean.holiday be off, then a bunch of the if statements are literally the same condition. You don’t need both.

Next, there are 2 ways to call a service, the service: script… call will wait until it is complete before it allows further action. The script_turn_on executes and releases to run the script in the background. That seems to be affecting some of your script timing.

Finally from a cursory glance at your code, you may want to look at the calendar integration, as it may simplify things greatly and make more sense overall. Link to Calendar – My Home Assistant

Thank you for your response, Sorry for putting it in the wrong topic, What is a better topic for this question?