Custom Notification with Node Red

Hi, I’m new to HA, I would like to answer a question that I didn’t find and it can be simple.
Using tips here on the forum, I made the sensors with football games that warns of the next games and data.

I would like to send a custom notification with the next game and also with x minutes left to start the game, it is possible to do this via node red

Yes of course this is possible. You can use the same service calls as you would be using in HomeAssistant.
Which Notification Platform would you like to use?
Basically you just need to format your message and send it via the correct service call.

I will use the telegram.
I don’t know how to format the message to send the notification missing x hours for a game, for example.

So in Telegram case its pretty easy. I would recommend doing it with a function node, that just feeds the message to the Telegram.

Assuming your X hours is in the msg.payload you can try the following:

newmsg.payload = { data: { "message":"Game starts in "+msg.payload+" Minutes"} }

image

[{"id":"3b4124e7c01b4f01","type":"function","z":"5ff14be1.9cddc4","name":"Message","func":"newmsg = {}\n\nnewmsg.payload = { data: { \"message\":\"Game starts in \"+msg.payload+\" Minutes\"} }\n\nreturn newmsg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":2060,"wires":[["894c2d1ba5bb89cb"]]},{"id":"894c2d1ba5bb89cb","type":"api-call-service","z":"5ff14be1.9cddc4","name":"Notify Telegram","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"telegram_marcus","entityId":"","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":2060,"wires":[[]]},{"id":"bb63f0a152148a63","type":"inject","z":"5ff14be1.9cddc4","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":290,"y":2060,"wires":[["3b4124e7c01b4f01"]]}]

Thanks for the help, but it still doesn’t work :confused:

I have the game date information in this format via msg.payload: “2021-11-21T03:00:00.000Z”
print

Therefore, I don’t have the information that the game is 3 days away, I have the information that the game is the 21st

In that case you want to compare two dates to get the remaining days. Its a calculation. Im not sure if there exists already a node that easily does this, but please follow the links here to get you going:

You can use a function node to experiment with it a bit more.

1 Like