Exactly. The example in the Feature Request uses a variable to report which input_booleans are on. Regardless of how many input_booleans are turned on/off/on, the Template Trigger fails to detect the state-changes.
I’m not so certain about that. The variable’s template would be the same one you would normally use in the Template Trigger. Here’s your example without a variable:
Same template but not in the variable; overhead is the same.
As for the concern about the overhead of multiple variables, only the variable(s) used in the Template Trigger needs to be monitored for state-changes.
Anyway, short story is variables aren’t assigned listeners when used in a Template Trigger … so if you want it, please cast your vote for the Feature Request (i.e. throw a virtual coin in the fountain and hope the wish comes true).
At first I thought this behavior might be due to the fact that templates now support native types. Maybe the template’s result is (somehow) converted into a binary true/false value … but that now seems like a stretch.
Anyway, this doesn’t behave consistently nor does it comply with the documentation. You should definitely report it as an Issue in the Core repo.
yeah, nice test set up, and clear for the issue in core.
maybe we should add this Use new template 'expand' functionality in automation trigger? to it, now we’re talking triggering templates, and the dust on the expand() functionality has settled down, maybe try to expand using expand in a trigger template once more…
Your example creates a list of entities in a Template Trigger. You’re expecting the Template Trigger to behave like a State Trigger. However it has never worked that way. A simple state-change is what a State Trigger considers sufficient to trigger but that’s just enough for a Template Trigger to evaluate its template (and trigger only if the computer template’s result changes).
Perhaps what you are looking for is the ability to template a State Trigger’s entity_id. The expand function would be a good fit for that.
I saw that after I commented on the git. So this behaviour was known, and known to be counter intuitive. They agree it’s a “bug” hence the “bugfix”, but at the same time is “working as intended” and “not a bug”. Cool beans. Anyway, sounds they know about and are working on it.
The behavior we’re talking about doesn’t affect me, none of my templates are structure like that. However the PR you mentioned just might!
I have an issue where for some reason or another, if any of my zwave motion sensors are dead the motion boolean is in the on state. This means on a restart, my house alarm triggers if any of those zwave nodes are dead. Problem was discovered at 4:00am burning the midnight oil playing with my config. Wife wasn’t very impressed. Problem reoccurred again a week later when the power flickered at - you guessed it - 4:00 am! Wife was even less impressed.
My “bugfix” for this was if the alarm triggers after a restart, it disarms and then rearms itself, thus saving me from my wife’s wrath. I also finally bought a UPS for the RPi.
Curious if that PR will prevent me from getting tied up by my 'nads again?
I read the responses to your Issue and adminiuga’s reply is notable:
A non zero values are evaluated as True.
This leads me to believe that the unexpected behavior (i.e. it differs from the documentation’s description) is a side-effect of supporting native types. As long as the template generates a result that is a non-zero value, it is interpreted as True (and will trigger). That’s definitely not how it used to work as is described in the documentation which predates the introduction of native types.
It also explains why I observed that it would trigger only when a light changes state to on but not when it changed to off. The on state is equivalent to boolean True or a value of 1 whereas off is boolean False or 0.
When Frenck replied it is “the correct behavior and thus not a bug” that’s 'technically the truth` now. However, it’s not how it used to work (ostensibly prior to support for native types) because you, I, Marius and others have never known it to work like this and our Template Triggers were never written to work that way. This is new behavior.
Thank you. The false if 0 else true isn’t what threw me off here. That’s a pretty common convention and honestly what I would have expected. It was the triggering on state changes to and from non-zero values.
I had basically wrapped my head around the essence of the issue after reading PR#46423 a couple times. Your reply helps solidify it for me. At least I know I’m not crazy now. The initial “that’s the way it’s supposed to be” response without further explanation really threw me off because it clearly was not the documented behaviour to my understanding.
I have received a few of those and it can leave one a bit frustrated. In one case, the individual confirmed they didn’t even try to replicate the bug. Anyway, that’s not the norm and most replies are helpful.
Where and how do you add this?
Recent migrator to HASS, I assume I copy the package_unavailable_entities.yaml to the config folder and then reference it in configuration.yaml somehow?
I’s like to implement it as I have random disconnects on some Tasmota devices which I think is related to my WiFi but need to track them.