I have a collection of automations which use the numeric_state of a particular sensor as a trigger. (These are actually external air quality sensors that I pull from an API. There are two near me, and neither is super reliable. One or the other will go “down” for days at a time sometimes.)
It would be really handy if there was a way to parameterize the entity_id so I could swap in either one sensor or the other when one of them goes down. I don’t really want to rewrite all of the automations using template as the trigger type. I’d really rather just have some mechanism for indirection/parameterization on the entity_id while using numeric_state as the trigger type, and then set it to one or the other in some central place.
I take it this is not really possible? Or am I missing something?
No, you can not use templates, and therefore anything parameter-like, for trigger entity IDs. Could you just list both entities on the trigger? Or create a template sensor that takes the higher/lower of them?
I think in this case a template sensor that takes the max is probably the best solution, since a sensor that’s “down” reports 0’s.
I was curious if this sort of parameterization was possible in general, though. Does the HACS “variables” package do something like this? It’s certainly not the first time I’ve wanted to tie something to an abstract idea of a particular kind of entity, and have the flexibility to change what specific entity_id it actually maps to as my system evolves. I guess for sensors the template sensor would allow this.
Yea, template sensors and template triggers are pretty much the built-in way to do that. You’ll just have to keep that in mind for your automations from here on
I haven’t used that package, but I imagine it wouldn’t be able to help in this situation if you need to reference the variables through a template.