Passing msg.payload or msg.data to Notification

Hello.

Trying to set up notification after a get entity state, where it dynamically puts the output of $msg.payload, and $msg.data into this format. However the notify doesn’t recognize the information getting passed to it.

I tried using the template node to format it this way, which works in a debug output. However I can’t then get the notify node to accept {{msg.payload}} as the “data” field.

Any suggestions?

{
“message”: {{msg.data}},
“title”: {{msg.payload}}
}

I’m no expert, but try (notice the quotes):

{
“message”: “{{data}}”,
“title”: “{{payload}}”
}

It’s always better to post more of what you have to make sure there is no confusions of how your sequence is set up.

But

{
  "message": msg.data,
  "title": msg.payload
}

Works if everything else is correct.

1 Like

The last suggestion does not work …
… but this works well (it prints the msg.message in the notification) :

{
“title”: “Nachrichtentitel”,
“message”: “{{ message }}”
}

There are 2 different settings for the data field.

There is JSON.

image

When set to JSON variables are encased in mustache {{ }}

Then you have J Expression/JSONata.

image

When using JSONata you would use just the path without msg.

{
  "message": data,
  "title": payload
}

In the above both data and payload are variables and will be replaced with the value contained in the path.