Hi
I’m fairly new to Node Red, pretty new to Home Assistant and completely new to Javascript, so please forgive and have patience if my code is kinder garden grade!
I’m trying to build a notification node which sends a message with dynamic text based on the payload to a phone along with a prompt for an action.
So far this is what I got:
I’m able to prompt for an action
And I’m able to read and parse the user input back inside Node Red.
I am able to send a message with a single line of dynamic content. Meaning I can make the Notify node insert the payload in the notification title or message under certain conditions.
And here is my problem:
I want to be able to dynamically form the notification content with line breaks etc. so that I can essentially pass a string, which has already been built, to the Notify node as a payload.
Passing anything to the Notify node with carriage returns and line feeds returns an API error:
“Call-service error. extra keys not allowed @ data[‘0’]”
Any suggestions are highly welcome.
Macro level project description:
I am building a system with automated notification if temperature differential between adjacent rooms in the house exceed a defined limit.
I want the notification content to be formatted something like below:
Title:
"
Room gradient temperature warning!
"
Message:
"
F3 <-0.88-> F4
S4 <-3.54-> S5
S5 <-0.93-> S6
"
…Specifically noting the line feeds and carriage returns in the message
As an aside, I have noticed that putting \r\n in the message in Notify works just fine normally, so I don’t understand why it doesn’t parse correctly when I pass what I think is a formatted string to it:
for(let i = 0; i < warnings; i++)
{
if(i % 2 == 0)
{
pushNotification += msg.data[i] + "\n";
}
}
msg.payload = pushNotification;