Timestamp calculation for automation

FYI, the version I created triggered at noon today. I have reset it to trigger again tomorrow. I’m confident it will work again tomorrow for me and for you on October 11th.

Sounds good, for me i have a next pickup date in 5 days, will let know the result,
If all okay, i will mark it as the solution.

It works, i can the notification trought the telegram service,
Marked the post as the solution, .astimezone() did the trick,
many thanks.

1 Like

I’m still to stupid.

In Nodered and Json, I succeeded already to concatenate some values from different “payload messages”
Like:
let num7 = msg.payload7;

Now I want to add the timestamp of the message in a readable format

I tried already several examples but I’ve always an error:

Like: let time = msg.payload7.timestamp;

Gves a “tim undefined” answer in debug screen

How can I extract thedate and the time from a message?

Timestamp of what? and what you need to do with it? What you tried? Give more info

For simple way you can use


var textdate=new Date(msg.payload).toISOString().replace(/\..+/,'');

or for custom display based on Date - JavaScript | MDN

Thank you.

I still have to learn a lot.

I have already the date & time in my string, concatenated with other values.

In my function object, I’m returning the string :
msg.payload = ans;
return msg;

And the string shows up correctly in the debug screen.

But how can I send this string in a notify object

image

My notify/email functions correctly, but when sending a text message.
Now I want to send the string I made in the function.

This does not work :
image

How can I send the output of my function?

In json type something as

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

If it’s not exact I can check later in nodered, I am not at computer currently.

Thanks for your answer

But it gives a syntax error

image

Replace msg.payload with “{{ payload}}”

  1. Replace msg.payload with “{{ payload}}”
    {
    “title”: “Temp”,
    “data”: {“{{payload}}”}
    }
    → Syntax checking gives Bad string

{
“title”: “Temp”,
“data”: {{payload}}
}
→ Gives also bad string

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

Is accepted but gives error on execution.
image

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

Is accepted but gives error on execution.
image

Based on this

If this can help.

This syntax works and sends a notify/email with a snapshot image of a camera. (thanks to a forum member)

But how to send a string message coming from a preceeding function object?

{
“title”: “Beweging voordeur”,
“message”: “Beweging voordeur”,
“data”: {
“images”: [
“/config/tmp/snapshot_camera_voordeur.jpg”
]
}
}

I am still on mobile but as I said just replace msg.payload with {{payload}}
{
“title”:“Temp”,
“data”:{ “message”: msg.payload}
}

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