So I set some global variables that define various entity_ids.
If I use the call service node (api-call-service) and use mustache templates for the entity_id like this
{{global.kitchen_light}}
Everything works just as if I had put the entity id in directly.
But in the events: state node (server-state-changed) if I use the exact same mustache template for the entity_id field nothing works. No state change is ever registered.
Can I not use mustache templates in that node? Is there a workaround?
Mustache templates don’t work in event nodes entity id fields. There’s no workaround for it that I can think of and probably won’t be because at the time of deployment it needs to know what to listen for. There is no way to track when a global variable gets updated to then update the event node.
Interesting, and I guess that kind of makes sense the way you describe it. Because yeah, the global could change, but then the event node wouldn’t know that it changed, since it is initiated at deployment. The other nodes, like call service, get updated when something triggers them.
So maybe related then…is there a way to have a variable assigned to the entity id that would get updated just at deploy?
My main goal here is to have like something akin to an ‘environment’ table where I have variables with say ‘kitchen light’ and ‘bedroom light’. And then assign individual light bulbs to those variables. I would then build my flows using the variables ‘kitchen light’ or ‘bedroom light’, and then let that variable assign the corresponding entity_ids to those nodes. I can then have many flows that reference the ‘kitchen light’. But then, if I need to change bulbs around or buy a new one, I can just update the ONE kitchen light variable with the new entity_id of the new light bulb. Then re-deploy. And have everything upated in all the flows that reference that variable.
Right now I would have to hunt through and find all events for kitchen light. And then all events with bedroom light, and on and on for everything in multiple different flow if I ever change bulb location/identity id’s around.
In regular programing you would have some sort a variable declaration file and then everything would reference those variables. Right now I have to retype everything in multiple places to update changes to entity_ids.
Is there a better way to do this? Maybe something other than mustache templates, something I don’t know about.