SOLVED: Can I template the entire data field in a service call?

I am trying to template my various notifications. for example
if i put this in the data field it works
If i put it in a template and view the debug output, i see it broken down correctly into titles, objects, arrays. etc.
but using {{payload}} in the data field always gives error. the actions/array parse out but the rest does not. how can I achieve this?
reason being is I want to have 1 notify node for each device, but the notifications vary, some with intents and some without. so i’d like to template all that, and then just pass it to 1 notify node.

{
    "title": "Alert",
    "message": "A new version of HomeAssistant is available. would you like me to upgrade?",
    "data": {
        "actions": [
            {
                "action": "upgrade_ha_yes",
                "title": "Upgrade HA Now?"
            },
            {
                "action": "upgrade_ha_no",
                "title": "I will upgrade manually"
            }
        ]
    }
}

Pass it in the input of the node or make sure the data field type is set to J: expression

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/call-service.html#input

@Kermit - thanks for the response. I checked that my formatting was correct, and when i look at the debug output of the inject node, it looks correct to me. but when it hits the call service node, it’s junk. screen shot attached. any idea what i’m doing wrong?

nevermind I got it sorted. will leave my solution for anyone else searching.
my formatting was indeed not correct.
had to use {{msg.payload}} and this json format, it it worked.

{
    "data": {
        "title": "Alert",
        "message": "A new version of HomeAssistant is available. would you like me to upgrade?",
        "data": {
            "actions": [
                {
                    "action": "upgrade_ha_yes",
                    "title": "Upgrade HA Now?"
                },
                {
                    "action": "upgrade_ha_no",
                    "title": "I will upgrade manually"
                }
            ]
        }
    }
}

Howdy there, would you be able to shed some light on how you configured your nodes to do this?

I’m trying to pass light command data directly into a node using MQTT-In and a data block, but I’m coming up a bit short.

I’ve tried your solution here, but just keep getting "Call-service error. extra keys not allowed @ data['0']".

Presently I have the following:

  • An Inject node connected to an MQTT-Out node. I’ve set the msg.payload to
{
    "data": {
        "brightness_pct": 100,
        "rgbww_color": [
            255,
            0,
            0,
            0,
            0
        ]
    }
}
  • An MQTT-Out node subscribed to the same topic as the “in” node
  • A Call-Service node set to the Light domain and targeting the area Office. Its Data field is set to a JSONata expression "{{ msg.payload }}"

Sadly this doesn’t work, and I’m struggling to find a way to pass the entire data object directly into this node.

Cancel this, I figured it out. In order to use injected data, you leave the Data field in the call service node blank. Thanks!