Wait until does not work properly with templated input
Describe the bug
There is a problem with Wait Until, and this shows a minimal example. The problem was previously raised here, but closed.
If the entity for the Wait Until is templated, such as "{{ payload.entity_id }}" then it seems to cache that value until Node Red is redeployed.
In the screenshot I have two injects, one Wait Until waiting for "off" plus sending the entity to "waitEntity", and two debugs. The first inject sets payload.entity_id to "light.kitchen" and the second sets it to "light.kitchen_cooking". The two debug outputs correspond to clicking the first inject and turning off the kitchen light, waiting for the result, and then clicking the other inject and turning off the cooking light.
The first debug shows payload.entity_id set to "light.kitchen" and the "waitEntity" also set to the same value. However, the second debug shows payload.entity_id set to "light.kitchen_cooking" but the "waitEntity" still set to "light.kitchen". And since the kitchen light didn't change state, it ends up incorrectly taking the timeout path.
If I redeploy and click the "light.kitchen_cooking" inject first, it works, and the "light.kitchen" inject fails. And btw, despite their similar names, one is not a group containing the other.
To Reproduce
Here is the code I'm using:
[{"id":"d10421ba542afd77","type":"inject","z":"f5d4c8a60c553b43","name":"Kitchen","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"entity_id\": \"light.kitchen\" }","payloadType":"json","x":150,"y":80,"wires":[["abf670d850e4c0eb"]]},{"id":"abf670d850e4c0eb","type":"ha-wait-until","z":"f5d4c8a60c553b43","name":"","server":"f92704c94ce39f08","version":3,"outputs":2,"entities":{"entity":["{{ payload.entity_id }}"],"substring":[],"regex":[]},"property":"state","comparator":"is","value":"off","valueType":"str","timeout":"20","timeoutType":"num","timeoutUnits":"seconds","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[{"property":"waitEntity","propertyType":"msg","value":"","valueType":"entity"}],"x":360,"y":100,"wires":[["69a429b5998079ce"],["33ee2f47a319e97a"]]},{"id":"69a429b5998079ce","type":"debug","z":"f5d4c8a60c553b43","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":80,"wires":[]},{"id":"33ee2f47a319e97a","type":"debug","z":"f5d4c8a60c553b43","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":120,"wires":[]},{"id":"334775bbe4017e71","type":"inject","z":"f5d4c8a60c553b43","name":"Cooking","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"entity_id\": \"light.kitchen_cooking\" }","payloadType":"json","x":160,"y":120,"wires":[["abf670d850e4c0eb"]]},{"id":"f92704c94ce39f08","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m","enableGlobalContextStore":false}]
Expected behavior
No response
Screenshots
Example Flow
Environment Information
Version: 0.75.0
Home Assistant version: 2025.2.1 Companion version: 4.1.2
Node-RED version: 4.0.8 Docker: yes Add-on: 19.0.0
Node.js version: v22.11.0 x64 linux OS: Linux 6.6.73-haos x64
Additional context
No response