metbosch / homebridge-http-temperature

HomeBridge HomeKit Plugin for HTTP temperature endpoints
https://www.npmjs.com/package/homebridge-http-temperature
Apache License 2.0
33 stars 18 forks source link

Right answer for the json-parser #2

Closed DaPeace80 closed 7 years ago

DaPeace80 commented 7 years ago

Hello, i try to get temperature working with my arduino + homebridge. Ive tried several possibilitys but cant figure out what sentence i have to send back to your temp-script. Every time it trys to parse the temp its killing homebridge.

I tried:

String s = "HTTP/1.1 200 OK\r\n{\r\n \"temperature\": "; s += temp; s += "\r\n}"; client.print(s); client.flush();

as well as:

String s = "{\"temperature\": "; s += temp; s += "}";

i first tried with a fixed variable -> long temp = 20.0; Could you help? When i reroute to an php-script with content:

{ "temperature": 20.0 }

the script works... :-(

Regards, Jan

metbosch commented 7 years ago

Try (note the the slashes before the internal double-quotes):

String s = "{\"temperature\": "; s += temp; s += "}"; client.print(s); client.flush();