Timestamp in Node Red Notify iOS message

Im trying to send a message to my phone when someone arrives home. I would like to include a timestamp in the message but im having issues. The timestamp does not show up in the message. I would like the format to be:
hh:mm:ss - Person is Home

I have tried this:
{“message” : “{{ as_timestamp(now())}} - Brodie is Home”}

As far as i know there is only one component in ha that can render jinja templates in the call service parameters (can’t remember the name), in nodered you will have to generate the timestamp in a function node using the javascript Date methods or use the moment node to construct later the date using mustache template in the call service node

If you have seen examples of using double curly braces in examples or ss here for nodered is called mustache syntax. They can expand msg properties, global and flow context, and now ha entity states.

Here is a basic example.

[{"id":"ddd79a0f.cffcc8","type":"inject","z":"9ac58995.e96338","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"0.3","x":320,"y":2020,"wires":[["760088ed.b1e2b8"]]},{"id":"760088ed.b1e2b8","type":"moment","z":"9ac58995.e96338","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Brisbane","adjAmount":0,"adjType":"days","adjDir":"add","format":"object","locale":"en_AU","output":"d","outputType":"msg","outTz":"Australia/Brisbane","x":520,"y":2020,"wires":[["298cf35d.22c66c"]]},{"id":"298cf35d.22c66c","type":"api-call-service","z":"9ac58995.e96338","name":"","server":"d5ce5cec.92bc8","service_domain":"notify","service":"ha_telegram","data":"{\"message\":\"Arrived at {{d.hours}}:{{d.hours}}:{{d.minutes}}\"}","mergecontext":"","output_location":"","output_location_type":"none","x":750,"y":2020,"wires":[[]]},{"id":"d5ce5cec.92bc8","type":"server","z":"","name":"Home Assistant","legacy":false}]

Managed to get what I wanted using the moment Node

Thanks for the help

Can you show us your solution, please?

If you’re using v0.12+ you can again use jinja2 templates in the call-service by checking Use alternative Mustache tags for the Data field. This will change the opening/closing tags for mustache templates to <% %> and this will allow jinja2 templates to be passed to Home Assistant.

1 Like