Assume my template sensor depends on some command_line sensor - will the template sensor be updated after updating of command_line sensor?
Assume my command_line sensor depends on some template sensor (i.e. the “command” contains a template with some template sensor) - will the template sensor be initialized first and then the command_line sensor is updated?
Is there any need to specify a trigger “HA: startup” for template sensors since they are updated on startup anyway?
I know there’s some control over the start order for integrations. I’m trying to remember where I saw it, but I remember a release that specifically improved this. It was during that series of start time improvements. Also, integrations initialise async, so I don’t think every step in the start order will wait (but some may), plus integrations can timeout and retry, in which case all the timings will be off. This is as much as I know. Someone that understands and have read the code would know better.
Pieter, thank a lot for a feedback.
My observations are:
If an automation with a “HA startup” trigger using an entity provided by some integration (like Traccar etc) - this entity may not be ready yet (could be “unavailable”).
If a command_line sensor has a templated command & depends on some template sensor - by the moment when this command is executed this template sensor is not ready yet (which is strange).
Yes, from what I understand, should an integration time out or be too slow during startup, HA will continue, and what you describe will happen.
This might be a chicken and egg scenario (Catch-22): sensors that have templates, that uses other sensors. It’s not obvious to me what an ideal initiation sequence would be.
Since these command_line sensors depend on template sensors, I usually use this:
command:
echo ;
{{... processing a template sensor ... }}
value_template: >-
... analysing a result ...
If a template sensor cannot be properly processed → only “echo” is executed.
In “value_template” then a result is processed.
So the 1st update on HA startup does not lead to an error.