A simple sensor:
template:
- trigger:
- platform: event
event_type: event_template_reloaded
sensor:
- name: xxxx
state: >-
{{ ... }}
When templates are reloaded → the event_template_reloaded is generated.
Will the event be generated AFTER all templates are reloaded?
If no → then probably this particular sensor may not catch this event since it is STILL being reloaded.
My guess seems to be correct - found related threads here.
A template sensor MAY BE still being reloaded - and cannot catch this event.
I have an automation that listens for event_template_reloaded
and all it does is fires another event mb_event_template_reloaded
. Then other code listens for that event instead. It seems to work more reliably but ymmv.
Listening the “event_template_reloaded” in an automation is a different thing since automations are not reloaded when this event is generated.
Sorry, misread your post.
Hmmm, this is an interesting way.
Also, if you add a small delay in the automation BEFORE firing the custom event - it will work more reliable.
Btw, I may be was too quick with marking the thread “solved”.
Found this post where it was said that the “event is posted after Template entities are reloaded”.
But I am still observing this erratic issue.