Template Issues with attributes

I’m pulling my hair out why this isn’t working: I have a flow that triggers and I want to send an attribute using the notify service. The following works fine in HA Automations but not in node-red:

{
    "message": "{{ state_attr('image_processing.tensorflow_drive_camera', 'summary') }}"
}

It fails with:

t"Call-service API error. Error Message: required key not provided @ data['message']"

What am I missing?

The call service node doesn’t not render jinja templates. You have to fetch the state before the call service set in a flow context or use the incoming message with moustache template, look at the call service info tab. If you have latest version (not sure yet I have to check) you can use jsonata to get the state without consulting in a previous node.

This also could be done using the Mustache templates as they do have access to the cached states.

{
    "message": "{{entity.image_processing.tensorflow_drive_camera.attributes.summary}}"
}
1 Like