Trouble sending value with http.put

I am trying to make my imp in the garage send the temperature to the openhab site, which will then relay it to my local server.

With curl I can get it to work, but I am having some trouble replicating the function in the agent.

curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "9.8" ""

The 9.8 is the value it should send, and using curl it does it correct, but I cant get the agent to do the same, any suggestions?

local headers = {"Content-Type": "text/plain"}; local csv = xivelyData.temperature/xivelyData.samples; local request = http.put("", headers, csv); local response = request.sendsync();

As far as I can see, curl only sends the value, nothing else. Failing to get the agent to do that too without giving me an error.

csv = “” + value; worked, just seems to be a bit crude, is there a more elegant way?

So you’re saying that the Imp has a temp sensor and it will send that to myopenhab at certain intervals? What is actually supposed to happen?

It updates the value on my local openhab server. And it works if I put “” + in front of the value, but it looks strange having that in front, but it actually works.

This is, I suspect, because “csv” isn’t text, it’s the actual numeric value.

The http.put is expecting a string. When you do “”+ this coerces the number into string form, and everything works.

Adding “.tostring()” after xivelyData.samples would likely also work.

aaah yes, that was it

That’s sort-of a bug, then. Really it should either be coercing the integer, or throwing an error. Might be a bit awkward to change it now, though, without changing the meaning of existing code.