Setting numeric value with Http call

Hi

I have a dummy device created with TemperatureSensor1 D and I xml files so its temperature stored in CurrentTemperature which is numeric, if I use

http://ip of openluup RPI/data_request?id=variableset&DeviceNum=54&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value=38

i correctly sets the variable to 38 as a numeric

but if i use

[code]local socket = require"socket"
local http=require’socket.http’

local devusagetemplate = “http://ip of openluup RPI/data_request?id=variableset&DeviceNum=54&serviceId=urn:micasaverde-com:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value=%s”
newt=90
url=string.format(devusagetemplate,newt)
retcode = http.request(url)[/code]

it creates another variable in device 54 called CurrentValue with the value 90 which I assume is a string.

(if I delete the original CurrentValue variable the device icon show NaN - which i assume is ‘not a number’)

so How do I force the http call to send a number not a string

regards

nik

Since you used 2 different Service ID’s, you’ll get 2 different variables (upnp-org and micasaverde-com). Change the Service ID’s to match and it will likely do what you want.

As far as I know the variables are always stored as strings. You have to do conversions when you get them back to coerce them into what you want to use. But that’s not the problem you are facing here.

Yes, NaN is not a number.

Karma to @jswim788 for beating me to it…

Indeed.

As far as I know the variables are always stored as strings. You have to do conversions when you get them back to coerce them into what you want to use. But that's not the problem you are facing here.

Also true. There is no such thing as a numeric device variable - they are all strings. Some may parse as numbers.

Yes, NaN is not a number.

True again, but I’m not clear on where you are seeing this? “device icon show NaN” ?? Where, exactly is this appearing?

Thanks for that the service Id was that problem - I had the two different http calls saved from when I originally did this about 2 years ago and didnt notice the discrepancy - changing the service id worked

Akbooer it was Showing NaN on the little device rectangle just to the right of the thermometer icon

Ah, OK, that makes sense now. Thanks.