Newline in string

I can't believe nobody's asked this, but I searched the documentation and the community and couldn't find anything.

How can I build a string variable with newlines in it to eventually send in a notification? I'm using pushover, so potentially it's specific to them, but \n works fine when I send it directly in a http request to pushover.

IE:

(Door A is open
Window B is open
Temperature is < 50 degrees)

Try putting a \n where you want a new line.

I tried \n and \\n and got literal \n and \\n respectively.

IE:

(Door A is open\nWindow B is open\nTemp is < 50)

Sorry, just noticed that in your original post... I'm not sure...

How are you building the variable? For string variables in general, you can just literally insert a new line (e.g., press Enter). This may depend on the app and the inputs it provides but works in many places.

A separate issue but relevant for your use case: I don't know what the Pushover driver does with these. It may not escape them in a format the service needs to actually get them in your notification. If the built-in driver doesn't do this for you, there is at least one community driver that might (or could be modified, at least).

1 Like

I suspect based on what OP said, the system driver IS escaping the \ to make it a literal \ (possibly forcing it to \\n) , so then pushover does not interpret it as a new line.

If you can somehow get an ASCII character 10 (newline) into your string, maybe that would work better and the driver would convert that to a proper \n for pushover.

It does appear that hitting the enter key works. As a professional software developer that codes for a living, I never would have tried that in a million years.

The app in question is Rules Machine

1 Like

I guess thats how you get the char(10) in there :wink:

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