mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-10-26 22:10:45 +00:00
[WebUI] Remove duplicate data from JSON when updating taskvalues
This commit is contained in:
1 parent
d10c055ce3
commit
620ec51738
5 files changed
+16
-32
No files matched your search
@@ -383,7 +383,7 @@ boolean Plugin_126(uint8_t function, struct EventStruct *event, String& string)
|
||||
true);
|
||||
|
||||
string += value;
|
||||
pluginWebformShowValue(event->TaskIndex, VARS_PER_TASK + varNr, label, value, true);
|
||||
pluginWebformShowValue(event->TaskIndex, varNr, label, value, true);
|
||||
}
|
||||
}
|
||||
success = true; // Don't show the default value data
|
||||
|
||||
@@ -476,7 +476,7 @@ boolean Plugin_129(uint8_t function, struct EventStruct *event, String& string)
|
||||
true);
|
||||
|
||||
string += value;
|
||||
pluginWebformShowValue(event->TaskIndex, VARS_PER_TASK + varNr, label, value, true);
|
||||
pluginWebformShowValue(event->TaskIndex, varNr, label, value, true);
|
||||
}
|
||||
}
|
||||
success = true; // Don't show the default value data
|
||||
|
||||
@@ -18,6 +18,8 @@ enum PluginFunctions_e {
|
||||
PLUGIN_WEBFORM_SAVE, // Call from web interface to save settings
|
||||
PLUGIN_WEBFORM_LOAD, // Call from web interface for presenting settings and status of plugin
|
||||
PLUGIN_WEBFORM_SHOW_VALUES, // Call from devices overview page to format values in HTML
|
||||
// Return value (success = true/false) indicates whether this call covered all task values.
|
||||
// When regular task values should still be shown (thus success = false), make sure their varNr does not conflict with the existing taskvalue varNrs.
|
||||
PLUGIN_GET_DEVICENAME, // Call to get the plugin description (e.g. "Switch input - Switch")
|
||||
PLUGIN_GET_DEVICEVALUENAMES, // Call to let the plugin generate some default value names when not defined.
|
||||
PLUGIN_GET_DEVICEVALUECOUNT, // Optional function call to allow tasks to specify the number of output values (e.g.
|
||||
|
||||
@@ -845,6 +845,9 @@ void handle_devicess_ShowAllTasksTable(uint8_t page)
|
||||
|
||||
html_TD();
|
||||
|
||||
|
||||
// TODO TD-er: Code duplication with DevicesPage & JSON Create separate function to generate taskvalue data
|
||||
|
||||
if (validDeviceIndex(DeviceIndex)) {
|
||||
# if FEATURE_STRING_VARIABLES
|
||||
const DeviceStruct& device = Device[DeviceIndex];
|
||||
|
||||
@@ -450,6 +450,7 @@ void handle_json()
|
||||
sensorsWriter->setWriteWhenEmpty();
|
||||
for (taskIndex_t TaskIndex = firstTaskIndex; TaskIndex <= lastActiveTaskIndex && validTaskIndex(TaskIndex); TaskIndex++)
|
||||
{
|
||||
// TODO TD-er: Code duplication with DevicesPage & JSON Create separate function to generate taskvalue data
|
||||
const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(TaskIndex);
|
||||
|
||||
if (validDeviceIndex(DeviceIndex))
|
||||
@@ -483,7 +484,7 @@ void handle_json()
|
||||
|
||||
if (taskValueWriter) {
|
||||
struct EventStruct TempEvent(TaskIndex);
|
||||
|
||||
// FIXME tonhuisman: HasFormatUserVar is not really compatible with Derived Values...
|
||||
for (uint8_t x = 0; x < valueCount; x++)
|
||||
{
|
||||
uint8_t nrDecimals = Cache.getTaskDeviceValueDecimals(TaskIndex, x);
|
||||
@@ -508,40 +509,18 @@ void handle_json()
|
||||
const String uom;
|
||||
#endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
handle_json_stream_task_value_data(taskValueWriter.get(),
|
||||
x + 1,
|
||||
Cache.getTaskDeviceValueName(TaskIndex, x),
|
||||
nrDecimals,
|
||||
value,
|
||||
x + 1,
|
||||
Cache.getTaskDeviceValueName(TaskIndex, x),
|
||||
nrDecimals,
|
||||
value,
|
||||
#if FEATURE_STRING_VARIABLES
|
||||
presentation,
|
||||
presentation,
|
||||
#else // if FEATURE_STRING_VARIABLES
|
||||
EMPTY_STRING,
|
||||
EMPTY_STRING,
|
||||
#endif // if FEATURE_STRING_VARIABLES
|
||||
uom);
|
||||
uom);
|
||||
}
|
||||
|
||||
if (Device[DeviceIndex].HasFormatUserVar) {
|
||||
struct EventStruct TempEvent(TaskIndex);
|
||||
|
||||
for (uint8_t x = 0; x < valueCount; x++)
|
||||
{
|
||||
String value;
|
||||
TempEvent.idx = x;
|
||||
TempEvent.ParN[x] = 1; // Get formatted version of the value
|
||||
PluginCall(PLUGIN_FORMAT_USERVAR, &TempEvent, value);
|
||||
|
||||
if (!value.isEmpty()) {
|
||||
handle_json_stream_task_value_data(taskValueWriter.get(),
|
||||
VARS_PER_TASK + x + 1,
|
||||
Cache.getTaskDeviceValueName(TaskIndex, x),
|
||||
255,
|
||||
value,
|
||||
EMPTY_STRING,
|
||||
EMPTY_STRING);
|
||||
}
|
||||
}
|
||||
// FIXME tonhuisman: HasFormatUserVar is not really compatible with Derived Values...
|
||||
}
|
||||
#if FEATURE_STRING_VARIABLES
|
||||
|
||||
if (Settings.ShowDerivedTaskValues(TaskIndex)) {
|
||||
|
||||
Reference in new issue
Block a user