This page last changed on Nov 30, 2014 by agarcia.

I am having an issue with the HTTP Command GET using a JSON data string. I get the entire string in the label. Any help would be greatly appreciated. It is very simple, I have a command, a sensor and a label. The JSON is very simple "LED"= 0 or "LED"= 1. Once I have this working I will continue adding more stuff.



Name: GET_LED_State
Protocol: HTTP

HTTP attributes
HTTP Method: GET
XPath Expression:
Polling interval: 3s
JSONPath Expression: $.LED


Name: LED_Sensor
Command: GET_LED_Sate

Type: Custom
Not sure which values I need to put/select in Name and Value fields

Then I add a label and select the sensor and all a get is the entire string "LED"= 1 or "LED"= 0

Thanks in advance

Posted by pz1 at Nov 30, 2014 21:32

Hi PZ1,

Thank you very much for your reply. Yes, I haven seen this link already but it is not very clear to me to be honest. It didnt help me so that is why I asked in this forum for more help.

What shall I put in Name: and Value: if I need to use my settings of "LED"=1?

Many thanks,

Posted by agarcia at Dec 01, 2014 11:40

As in the last image of the link I gave you.

on   "LED"= 1
off  "LED"= 0
Posted by pz1 at Dec 01, 2014 11:58

It still displays the JSON string in the label app instead of the value: "LED": 1

The arduino code which generate the HTTP response code is:

// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: application/json");

// output the value of each analog input pin as a json-p object
client.print("\": ");
int sw1 = digitalRead(2);
if (sw1 == HIGH)

Unknown macro: { client.print("1"); }

if (sw1 == LOW)
Unknown macro: { client.print("0"); }


Below, are also the three elements that I am working with. Also, when adding the label in the UI Designer, there is the Sensor State which displays Off: On: . See last picture. I guess this is the actual label you want to display in the app, is that correct?




Thank you so much

Posted by agarcia at Dec 01, 2014 18:46

1) Show the json as you receive it from the Arduino
2) Include your code and logs {code}...{code} tags for better readability

Posted by pz1 at Dec 01, 2014 18:56

Text displays in the label is:

Posted by agarcia at Dec 01, 2014 19:36

OK, then in the custom sensor definition use 1 and 0 instead of the full strings including LED that you use now.
I only tested with a online JSONPath expression tester ( on your data.

Posted by pz1 at Dec 02, 2014 08:17
Document generated by Confluence on Jun 05, 2016 09:35