Mustache Templates in NodeRED Service Call

I’m stuck on a problem.

I use NodeRED to listen to empty scripts using the Events All node, and I filter those events out so I don’t spam NodeRED by the event bus.

An example of a script would be:

button_one:
  name: Button One

That’s it. So I set the Events All to filter out everything that starts with ^button_* and only those get through.

Now, when I activate that script, the flow begins.

From there, it hits a Service Call which is where I’m getting stuck. In the service call, I want to define the entity based upon the payload received from the Events All node. According to the Service Call node documentation, Mustache Templates can be used to define the entity. If that’s the case, then I would simply specify input_boolean.{{payload.event.service}} in the Entity field, but that doesn’t seem to work because the field is blanked out if I try that.

{
  "event_type":"call_service",
  "event":{
    "domain":"script",
    "service":"button_one",
    "service_data":{
      
    }
  }

My next best option is to create a switch node to route the flows but that ends up being huge because of how many buttons I’m working with.

Side note, the vision of this project is to create buttons that are on timers which only appear on the screen when the timers have expired. So, I take the garbage out, tap the garbage can button and it goes away until the timer runs out at which point it appears again (conditional card.)

Is it or is it not possible to use the payload information to populate fields in subsequent nodes to reduce the number of flows by reusing the same flows for multiple entities?

What’s a possible alternative?

Heck yeah! I got it.

Bypass the Entity field completely and use the JSONata field to define the entity_id.

Here’s what I added to that field to get what I wanted:

{
   "entity_id": $join(['input_boolean.',payload.event.service])
}

This particular function will always apply to input_boolean entities, and the corresponding scripts that are fired will always be named to match the input_boolean, which makes it really easy to have a single node perform the same function on multiple input_boolean switches without needing gobs and gobs of additional flows.