Including timestamp in a call service to Notify

First post here - I hope I get this right!

I'm running Node Red v2.2.0 on Home Assistant and when certain events happen in NR I want to use the call service function to send a notification to my mobile. This bit I have working.

BUT :slight_smile:

I want to timestamp the message being sent out by the notify call. From my googling I have found that it may be possible by calling a node red function (see here) but I don't yet understand how I can include the output of this function into the call service option.

Here (See attachment) is the detail of my call service section. Can I somehow include the date and time in the output to my mobile?

You can do that directly in the call service node with the JSONata expression

{"message": "GR lamp ON " & $moment().tz("Europe/London").format("DD-MM-yyyy HH:mm:ss")}

[edit] you can also add msg vaiables the same way
eg.

{"message": "GR lamp ON " & $$.payload}

should add the contents of msg.payload.

Wow ! Thank you! I'm off to play....sorry mean test!

Ta

Thank you - it worked first time :slight_smile:

I can already send a normal text string by email.
I have concatenated a string message in a function. And the debug screen shows a correct string
Now I want to send the payload of the function by email

I don't find the correct syntax to send this message. This does not works
{
"title": "Temperaturen Herman",
"message": "{{msg.payload}}"
}

Nor this
{
"title": "Temperaturen Herman",
"message": "Temperaturen zijn:", $$.payload
}

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