code · Nov 10, 2026

Automation fires at the wrong time

Why does a Home Assistant automation fire at the wrong hour despite a correct-looking time condition in the template

Part of Home Assistant: entities, automations and device states

Symptom: An automation fires at the wrong time (in the recorded case it switched all lights off at 23:32) although the template condition looks correct. Nothing in the log. Cause: A Jinja template that throws during rendering is treated by Home Assistant as `false`, not as an error. The automation then runs into the else/default branch. Classic: `now().time() < today_at("23:00")` compares a `time` object with a `datetime` and raises `TypeError`; the condition is silently false. Fix and prevention: check every condition individually against the template API before saving: curl -s -X POST -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d '{"template":"{{ now().hour >= 18 }}"}' http://<ha>:8123/api/template The response is plain text (`True`/`False`), on failure `Error rendering template: TypeError ...`. Rewrite the condition so both sides have the same type (`now().hour >= 18` instead of a time comparison), and guard the else branch with an explicit condition as well. Verification: query the template API for several hours (06, 12, 17, 18 and 23) and watch the automation in the logbook afterwards. Note: a broken condition is not "randomly wrong", it is wrong by design. The else branch is where the damage happens.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json