API Error when sending notifcation to phone- call service

Hi!

I have a notification system that notifies me via google assistant speakers when particulate matter (PM) is above a certain threshold. Works well sending the notification to my speakers BUT I als would like for it to be sent as a message on my cell phone (with the companion app), but keep getting an API error when a notification is sent. Please see flow below, along with call service node setup.

Please let me know if you require more informatoin here.

I do not use HA, you might get a better answer on the HA forum.

But you would need to send the service some data, at least a title and message.
Try pasting this in where it says data

{
"title": "A Title",
"message": "A Message"
}

If that works, then you can feed a payload into the node and set data to msg.payload, or what ever properties you want to use.

@E1cid thanks very much! By placing the json text in the data box, and injecting time stamp, it works i get the message I set to my phone app.

How do I now feed the existing payload into the node and set data to msg.payload?

Here is the function node before the call node

I can not work with text in an image,
but your function node would be something like this

msg.payload = {
"title": msg.topic,
"message": msg.some_property_name + " " + msg.some_other_property
};
return msg;

Then in data you would select msg and type in payload.

thanks very much! The function node is as you wrote it, and then I changed the call service node this below

I was not able to find "msg" so i just wrote what what shown in the photo.

You have not selected msg.
where it says {} click the chevron to the left, select msg. Then type payload.

You will need to add your own properties to the function, the one's i put there are dummy ones to show you how to construct your own. As i said images do not help me help you you need to pastes code.

I don't have msg when select the chevron to the left. please see here:

here is my function node in code

msg.payload = msg.topic + " Particulate Matter levels are at " + msg.PM25EOut_reading + " ug/m3";
return msg;

Then pick j expression and type payload.

You have to then set the function as i showed

msg.payload = {
"title": "some_title",
"message": msg.topic + " Particulate Matter levels are at " + msg.PM25EOut_reading + " ug/m3";
return msg;
};
return msg;

[edit]

Or you can select J expression (JSONata) and enter

{
"title": "A Title",
"message": $$.topic & " Particulate Matter levels are at " & $$.PM25EOut_reading & " ug/m3"
}

And not use the function node at all.

1 Like

@E1cid thanks for your help !!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.