Hi @ all
i had the problem that i´m missing some details in the json call, why?
want to create a module for ip-symcon to generate all variables etc. there.
Shortly take a look at yr code and attached a new handle in webserver.ino
at the top u must add the following:
Code: Select all
WebServer.on("/jsonxl", handle_jsonxl);
and after the handle_json:
Code: Select all
//********************************************************************************
// Web Interface JSONXL page (no password!)
//********************************************************************************
boolean handle_jsonxl()
{
String tasknr = WebServer.arg("tasknr");
String reply = "";
if (tasknr.length() == 0)
{
reply += F("{\"System\":{\n");
reply += F("\"Build\": ");
reply += BUILD;
reply += F(",\n\"Unit\": ");
reply += Settings.Unit;
reply += F(",\n\"Name\": \"");
reply += Settings.Name;
reply += F("\",\n\"Uptime\": ");
reply += wdcounter / 2;
reply += F(",\n\"Flash Size\": ");
reply += ESP.getFlashChipRealSize();
reply += F(",\n\"Protocol\": ");
reply += Settings.Protocol;
reply += F(",\n\"ControllerPort\": ");
reply += Settings.ControllerPort;
reply += F(",\n\"Abfrageintervall\": ");
reply += Settings.Delay;
reply += F(",\n\"Free RAM\": ");
reply += ESP.getFreeHeap();
reply += F("\n},\n");
}
byte taskNr = tasknr.toInt();
byte firstTaskIndex = 0;
byte lastTaskIndex = TASKS_MAX - 1;
if (taskNr != 0 )
{
firstTaskIndex = taskNr - 1;
lastTaskIndex = taskNr - 1;
}
byte lastActiveTaskIndex = 0;
for (byte TaskIndex = firstTaskIndex; TaskIndex <= lastTaskIndex; TaskIndex++)
if (Settings.TaskDeviceNumber[TaskIndex])
lastActiveTaskIndex = TaskIndex;
if (taskNr == 0 )
reply += F("\"Sensors\":[\n");
for (byte TaskIndex = firstTaskIndex; TaskIndex <= lastTaskIndex; TaskIndex++)
{
if (Settings.TaskDeviceNumber[TaskIndex])
{
byte BaseVarIndex = TaskIndex * VARS_PER_TASK;
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]);
LoadTaskSettings(TaskIndex);
reply += F("{\n");
reply += F("\"TaskName\": \"");
reply += ExtraTaskSettings.TaskDeviceName;
reply += F("\",");
reply += F("\n");
reply += F("\"PlugInNumber\": ");
reply += Settings.TaskDeviceNumber[TaskIndex];
reply += F(",");
reply += F("\n");
reply += F("\"TaskIndex\": ");
reply += TaskIndex;
reply += F(",");
reply += F("\n");
reply += F("\"IDX\": ");
reply += Settings.TaskDeviceID[TaskIndex];
reply += F("");
if (Device[DeviceIndex].ValueCount != 0)
reply += F(",");
reply += F("\n");
for (byte x = 0; x < Device[DeviceIndex].ValueCount; x++)
{
reply += F("\"");
reply += ExtraTaskSettings.TaskDeviceValueNames[x];
reply += F("\": ");
reply += UserVar[BaseVarIndex + x];
if (x < (Device[DeviceIndex].ValueCount - 1))
reply += F(",");
reply += F("\n");
}
reply += F("}");
if (TaskIndex != lastActiveTaskIndex)
reply += F(",");
reply += F("\n");
}
}
if (taskNr == 0 )
reply += F("]}\n");
WebServer.send(200, "application/json", reply);
}
BTW: too stupid for a push request, sorry, but it can only bee better