Lua string.gsub() question

I am copying strings from Weather Underground to an arduino device. I need to substitute the right except characters so I am trying to do it with string.sub( ):

assume the conditions are: “Partly Cloudy” the right escape for the receiving device is an "" so I am trying to replace a space with a backslash and a space to create the string: “Partly\ Cloudy”

trying this does not work…

local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Forecast.1.Condition", 59) conditions = string.gsub(conditions, " ", "\ ") os.execute("curl -k https://api.spark.io/v1/devices/5555555555336270287/httpRequest -d access_token=5555555555ceeb14c9d09ef9fee -d params=command#weatherForecast#text="..conditions.."#value0=0#value1=0?" ,1)

You probably need

conditions = conditions : gsub(" ", "\\ ")

[quote=“akbooer, post:2, topic:185715”]You probably need

conditions = conditions : gsub(" ", "\\ ") [/quote]

thanks, that did it!

local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Forecast.1.Condition", 59) conditions = string.gsub(conditions, " ", "\\ ") os.execute("curl -k https://api.spark.io/v1/devices/5555555555336270287/httpRequest -d access_token=5555555555ceeb14c9d09ef9fee -d params=command#weatherForecast#text="..conditions.."#value0=0#value1=0?" ,1)