Espace and quoted mark in a OpenHab String

  • Platform information:
    Mac High Sierra on a mac Mini with Openhab 2.1

Hi I’m trying to send a command to my Mac in a rules. Everything is working fine but now I’m trying to send a parameter in my commande so I need to add a space before my value and put my value between quoted mark

this is my command :

      executeCommandLine("/usr/local/bin/node /Users/admin/OpenHab/conf/HScript/JS/Salon.js"  ghSalontts.state)

so I want to put my string item ghSalontts as a parameter for my script

Thanks

executeCommandLine("/usr/local/bin/node /Users/admin/OpenHab/conf/HScript/JS/Salon.js "+ghSalontts.state)

Thank you for your anser but it’s not what i need …

let say my value for ghSalontts is Hello World

but when i send my command i need the value to be : SPACE “Hello World”

There is a space after “js”.
Have you checked it?
You can alse use

executeCommandLine("/usr/local/bin/node /Users/admin/OpenHab/conf/HScript/JS/Salon.js"+" "+ghSalontts.state)

OP also want’s the Hello World to be in quotes.

    executeCommandLine("/usr/local/bin/node /Users/admin/OpenHab/conf/HScript/JS/Salon.js \""+ghSalontts.state+"\"")

Thank you !! It seam to work but I still have an issue that I can’t figure out

Just to be sure if my value is ok is it possible to add the space and quoted mark directly to the value so I could check via the rest API if everything is ok

You know something like :

postUpdate( ghSalontts,SPACE+QUOTEDMARK+ghSalontts.state+QUOTEDMARK)

Is there some reason you wouldn’t want to use the same method?

postUpdate( ghSalontts, " \""+ghSalontts.state+"\"")

because it does not work … this is the result in my rest API :slight_smile:

{
“link”: “XXXXXXX:7070/rest/items/ghSalontts”,
“state”: " “Hello World”",
“type”: “String”,
“name”: “ghSalontts”,
“label”: " TTS Salon",
“tags”: [],
“groupNames”: []
}