Creating a list via Text String. Need Carriage Return/Line Feed/Enter


1) Give a description of the problem
Hello, Creating a piston that will output all my motion sensors and when they last changed. Got it working, but want to separate each item in the list with a carriage return. How do I build a string list with carriage returns/line feeds? is there a special character?

2) What is the expected behavior?
Tried a few things, like ‘/[\n]+/’ but don’t know what the special character for new line/carriage return is. Searched documentation and site for info, but can’t find it.

3) What is happening/not happening?

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)


I know if you use the set piston state, you can use \n to display the items on a separate line


When I try and put \n in, I get Variable n not found.

If I include it within ’ then I it puts it literally into the string.




I don’t think you can have a carriage return in a variable. I don’t think it works that way. Why do you need a carriage return in a variable? webCoRE doesn’t care if it bleeds into another line on the screen. What else are you doing with that variable that you need it on the next line?


I use it in a variable but I use it for setting a piston state.

example when using \n

example when \n is removed


I have never tried to force a new line inside a variable, but I build expressions with new lines all the time.

Here is one example using \n in quotes:

Which outputs 4 lines.


That would all be very helpful if the OP has asked about setting a Piston State using carriage return. However, they didn’t. But that’s for the demo on what a carriage return was. :stuck_out_tongue_winking_eye:

So, @PhantomSpice, why do you want to use a carriage return in a variable? What are you planning on doing with that variable later that it has to contain a carriage return?

Also, you didn’t try wrapping the \n in double quotes…which it has to be. So, it might work…I’ve never tried it.

EDIT: Just tried it…it actually stores the \n as readable text. So, if you set your piston state to that variable later it should make a new line. Which makes sense when you think about it. The variable is just storing a text string. The piston state is using HTML to display the text.



True, but since he had difficulty using parenthesis, it couldn’t hurt to see a real life example in action.
(since most popup windows have ‘Expression’ boxes)


LOL…honestly, i was just giving both of you sh*t cause it looked like both of you were just showing off your fancy shamsy HTML coding. I thought :stuck_out_tongue_winking_eye: was the universal emoji for “i’m being a goofball right now” Sorry, it’s been a VERY long day.


It’s all good. :sunglasses:
Would you believe I actually tried to find a SIMPLE example from my collection of pistons!

*offers you a Rum & Coke to unwind*


Hi everyone,

Carriage Return/New Line/Line Feed, I just need an enter. I honestly don’t know what the difference between any of them are, I just did a search for all those terms on the forum and couldn’t find any, and figured next person who was looking for it, if they didn’t know the right term either, at least hopefully this thread will come up with their answer as well.

So @Ryan780, you are right, I probably don’t NEED a carriage return, and the reason I want this in a variable is that I use helper applications to do different things like text me. But the variable is what one piston passes to the helper app piston via $args. So what I am trying to do is have this piston build a report report, set it to a variable, then send it to another piston which is responsible to texting me by using the variable that has all the right information appropriately formatted. This is better for me sending me 40 text, each of one line, of every sensor in my house.

Hope that makes sense.


Could you tweak the final piston a bit to send the text this way:

This does add new lines between each variable when sending an SMS
(notice the carriage returns are inside quotes)

Here is my resulting text:

Side Note:
I understand why we sometimes use an extra piston to organize and que text-to-speech, so multiple commands don’t step on each other’s toes… but SMS messages happen (fairly) instantly. If it were me, I would have the original piston simply send out the SMS properly formatted. (all in the one piston)

Here is a quick example of that in action, with a complex example right below it:

Personally, I think you are making it more complex than it needs to be by using a piston to talk to a “helper app” to talk to a piston to send a SMS.


I agree. However, I do have one piston that I direct all my sms messages through. The reason for this is, my wife hates getting too many messages that I like getting. So, I have 2 simulated switches set up, one for me and one for my wife. When she turns on the switch she gets all the messages that may happen. If she turns that switch off she will only get the high priority messages. The same applies to myself. Think of it like ‘please silence your phone button’; and it saves in some coding in each piston. All you have to do is pass arguments from each piston to the main sms piston and it takes it from there.


Great example @Gopack2!

I do something similar with Tasker monitoring my notifications coming in, (and deciding how to treat them) but your method really gets my creative juices flowing… LOL

Have you shared that last piston in another thread? I would love to look under the hood…


I don’t think so… lemme dig it up. Gotta sift through some stuff. Dust off some cobwebs and I’ll get back to you. Lol


Thanks, I appreciate that!

Honestly though, I don’t mind seeing it “sloppy” if it has been working for you.
(just make sure your personal info is not shared with the world, LOL)


HHere you go, everything gets fed through the sender piston. Also included a couple basic pistons

Switch 36 and 37 are the virtual switches to turn sms messages on or off by individual


The problem you are going to have with using that command in a text is that your texts are not HTML formatted and \n is an HTML formatting code. So, sending that to your text will not create a new line.
You could try sending it to an email. I don’t know if webcore emails are HTML formatted or not.


@WCmore, Just a note of thanks for the formatting tip- I was writing a piston to send caller ID info into a ST push notification (so it would show on my new Samsung TV that integrates with SmartThings) Your note was exactly what I needed. Works great!