I have a time-based automation that triggers every morning at 9:00. The purpose of this automation is to run a script. The script should check the current time, and if it’s past 9:00, the service call should execute. This check is necessary for my use case.
I followed various troubleshooting steps, such as running the automation separately and comparing entity entries before and after execution. The script always triggers on time, but the boolean does not change as expected. Additionally, I added a delay between the automation and the trigger to see if I had a timing issue, but this had no effect one way or the other. However, I can run either the automation or the script manually without any problems.
Here is the YAML for the automation:
alias: Craig Pill late automation
description: ""
trigger:
- platform: time
at: "09:00:00"
condition: []
action:
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: script.turn_on
target:
entity_id: script.craig_pill_late_script
data: {}
mode: single
And here is the YAML for the script:
alias: Craig Pill Late Script
description: Script to turn on the Craig Pill Late boolean if the time is after 9:00 AM
sequence:
- condition: template
value_template: "{{ now().hour > 9 or (now().hour == 9 and now().minute > 0) }}"
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.craig_pill_late
mode: single
How can I effectively implement this time check in my script to ensure the boolean changes correctly and ensure the service call to Google Sheets executes properly?