Problem with Node-RED, Service Calls, and iOS Notifications [SOLVED]

I’ve hit a wall trying to figure this one out and was hoping for assistance. I’m using Node-RED to create a flow that gets alerted by Blue Iris, passes the image to TensorFlow, and sends an iOS notification if a person is detected. I have this working without any issues using Pushover. However, I’m stuck when it comes to sending the alert to iOS.

The second template node seems to be what I can’t get working correctly:

Here’s the JSON from that:

{
	"message": "Person Detected",
	"title": "{{data.attributes.friendly_name}}",
	"data": {
		"attachment": {
			"content-type": "jpeg"
		},
		"push": {
			"category": "camera"
		},
		"entity_id": "{{topic}}"
	}
}

If I swap out the values, I can plug this into a service call in the Home Assistant UI without any issues. It sends the notification exactly like I’d expect.

The output from a debug on that node output replaces the values exactly as I’d like:
2019-03-22%2012_05_27-Home%20Assistant

However, I seem to be doing something wrong since I constantly get this error when trying to pass it to a service call with a few pre-populated fields:

This is the error:

"Call-service API error. Error Message: extra keys not allowed @ data['attachment']"

Any ideas here? I’ve built a bunch of flows before, but seem to be stuck on this one.

EDIT: Got it working. I had the template incorrect and had to change a few items. This is the template format that I should have used for the service call.

{
   "data": {
      "message": "{{data.attributes.friendly_name}}",
      "title": "Person Detected",
      "data": {
         "attachment": {
            "content-type": "jpeg"
         },
         "push": {
            "category": "camera"
         },
         "entity_id": "{{data.entity_id}}"
      }
   }
}
2 Likes