Morning automation based on calendar

?

The code you posted moments ago did not have an id and now suddenly it does?

I grabbed it from trace instead of just from edit in YAML mode.

ok, looking back on it, i feel incredibly stupid. im so sorry. I never changed calendar.school from my original post to calendar.ACTUALNAME. i feel like such a turd. Let me try again tonight. im so sorry to waste all your time.

The trace indicates it triggered at 8:00 (and there’s likely to be a previous trace showing it triggered at 7:00). However, it didn’t execute the action because the Template Condition failed. It probably failed for the reason you already guessed and that’s because the specified calendar entity didn’t exist and so the template failed with an error.

i switched to the correct calendar and clicked “Run automation”. Lights turned on and turned on green. Hopefully my stupidity being fixed solved it. Sorry and thanks!!

If you mean you clicked this:
Screenshot from 2021-08-31 12-19-18
then you didn’t actually test the automation’s condition, only its action.

Had you actually tested the condition it would not have executed the action because the current time is neither 07:00 or 08:00.

Dang it. Ok, well I can try again tomorrow.

There is a way you can test the condition today (and not have to wait until the scheduled time).

  1. Go to Developer Tools > Services and select Automation: Trigger.
  2. Select the name of your automation.
  3. Tick the checkbox for Skip Conditions and then (important!) turn off its toggle button.
  4. Click the Call Service button.

Finally, inspect the automation’s trace. It should indicate something like result: false for the Template Condition as opposed to the error message you originally had.

If the trace reports yet another error message then there’s till something wrong with the Template Condition’s contents.

Step details:

Executed: August 31, 2021, 12:33:26 PM
Result:

result: false
entities: []

Under Trace Timeline:
“Stopped because a condition failed at August 31, 2021, 12:33:26 PM (runtime: 0.00 seconds)”

I think that’s fine. That’s exactly what it says for a simple automation I just tested a few minutes ago using the same technique I described:

alias: Test 555
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.test
    to: 'on'
condition:
  - condition: template
    value_template: '{{ now().hour < 12 }}'
action:
  - service: notify.persistent_notification
    data:
      message: Hello world!
      title: Test 555
mode: single

Screenshot from 2021-08-31 12-39-29


The current time here is 12:42 so the Template Condition will return false.

1 Like

If it is a regular schedule you could use

Which lets your specify the days and just returns true/false

1 Like

My sons school doesn’t follow the normal school week/holiday schedule. They have inservice days and district days off throughout the year, so a calendar solves that. But thanks!

I see i could add all those days in as well. True, but with Thanksgiving, winter, spring, and summer vacations, its a lot of dates to add

Well… You could also just change the trigger and condition time in the automation to make it trigger at any time.

I agree 100% but, given the length of this thread, at this point in its evolution I didn’t want to suggest altering the automation’s trigger and Template Condition for a one-off test. The OP will know soon enough (tomorrow morning) if all is well.

I’m not going to argue with you because I agree with the logic, but the duplicate automation button is one great button in these kind of situations.
Just make a duplicate and make the changes you want to test then you can just delete it.

True but we are over 30 posts deep into fixing this one automation and, based on that progress, that’s why I chose not to start a parallel effort to create a test version that’s only needed once.

However, if you want to do that, please go ahead and coach them through the process of creating the duplicate, testing it, and deleting/disabling it afterwards. Either way, the OP will be using the one already posted above for the foreseeable future and it’ll get tested tomorrow morning.

Thanks for the help. It worked perfectly this morning.

As for creating a duplicate, thats a great idea and I should have done that at the very start.

1 Like