@@ -59,16 +59,13 @@ boolean CPlugin_009(byte function, struct EventStruct *event, String& string)
59
59
{
60
60
byte valueCount = getValueCountFromSensorType (event->sensorType );
61
61
C009_queue_element element (event);
62
- if (ExtraTaskSettings.TaskIndex != event->TaskIndex )
63
- PluginCall (PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
64
62
65
63
MakeControllerSettings (ControllerSettings);
66
64
LoadControllerSettings (event->ControllerIndex , ControllerSettings);
67
65
68
66
for (byte x = 0 ; x < valueCount; x++)
69
67
{
70
68
element.txt [x] = formatUserVarNoCheck (event, x);
71
- element.valueNames [x] = ExtraTaskSettings.TaskDeviceValueNames [x];
72
69
}
73
70
success = C009_DelayHandler.addToQueue (element);
74
71
scheduleNextDelayQueue (TIMER_C009_DELAY_QUEUE, C009_DelayHandler.getNextScheduleTime ());
@@ -86,55 +83,56 @@ bool do_process_c009_delay_queue(int controller_number, const C009_queue_element
86
83
if (!try_connect_host (controller_number, client, ControllerSettings))
87
84
return false ;
88
85
89
- // Create json root object
90
- DynamicJsonBuffer jsonBuffer;
91
- JsonObject& root = jsonBuffer.createObject ();
92
- root[F (" module" )] = String (F (" ESPEasy" ));
93
- root[F (" version" )] = String (F (" 1.04" ));
94
-
95
- // Create nested objects
96
- JsonObject& data = root.createNestedObject (String (F (" data" )));
97
- JsonObject& ESP = data.createNestedObject (String (F (" ESP" )));
98
- ESP[F (" name" )] = Settings.Name ;
99
- ESP[F (" unit" )] = Settings.Unit ;
100
- ESP[F (" version" )] = Settings.Version ;
101
- ESP[F (" build" )] = Settings.Build ;
102
- ESP[F (" build_notes" )] = String (F (BUILD_NOTES));
103
- ESP[F (" build_git" )] = String (F (BUILD_GIT));
104
- ESP[F (" node_type_id" )] = NODE_TYPE_ID;
105
- ESP[F (" sleep" )] = Settings.deepSleep ;
106
-
107
- // embed IP, important if there is NAT/PAT
108
- // char ipStr[20];
109
- // IPAddress ip = WiFi.localIP();
110
- // sprintf_P(ipStr, PSTR("%u.%u.%u.%u"), ip[0], ip[1], ip[2], ip[3]);
111
- ESP[F (" ip" )] = WiFi.localIP ().toString ();
112
-
113
- // Create nested SENSOR json object
114
- JsonObject& SENSOR = data.createNestedObject (String (F (" SENSOR" )));
115
- byte valueCount = getValueCountFromSensorType (element.sensorType );
116
- // char itemNames[valueCount][2];
117
- for (byte x = 0 ; x < valueCount; x++)
86
+ LoadTaskSettings (element.TaskIndex );
87
+ String jsonString;
118
88
{
119
- // Each sensor value get an own object (0..n)
120
- // sprintf(itemNames[x],"%d",x);
121
- JsonObject& val = SENSOR.createNestedObject (String (x));
122
- val[F (" deviceName" )] = getTaskDeviceName (element.TaskIndex );
123
- val[F (" valueName" )] = element.valueNames [x];
124
- val[F (" type" )] = element.sensorType ;
125
- val[F (" value" )] = element.txt [x];
89
+ // Create json root object
90
+ DynamicJsonBuffer jsonBuffer;
91
+ JsonObject& root = jsonBuffer.createObject ();
92
+ root[F (" module" )] = String (F (" ESPEasy" ));
93
+ root[F (" version" )] = String (F (" 1.04" ));
94
+
95
+ // Create nested objects
96
+ JsonObject& data = root.createNestedObject (String (F (" data" )));
97
+ JsonObject& ESP = data.createNestedObject (String (F (" ESP" )));
98
+ ESP[F (" name" )] = Settings.Name ;
99
+ ESP[F (" unit" )] = Settings.Unit ;
100
+ ESP[F (" version" )] = Settings.Version ;
101
+ ESP[F (" build" )] = Settings.Build ;
102
+ ESP[F (" build_notes" )] = String (F (BUILD_NOTES));
103
+ ESP[F (" build_git" )] = String (F (BUILD_GIT));
104
+ ESP[F (" node_type_id" )] = NODE_TYPE_ID;
105
+ ESP[F (" sleep" )] = Settings.deepSleep ;
106
+
107
+ // embed IP, important if there is NAT/PAT
108
+ // char ipStr[20];
109
+ // IPAddress ip = WiFi.localIP();
110
+ // sprintf_P(ipStr, PSTR("%u.%u.%u.%u"), ip[0], ip[1], ip[2], ip[3]);
111
+ ESP[F (" ip" )] = WiFi.localIP ().toString ();
112
+
113
+ // Create nested SENSOR json object
114
+ JsonObject& SENSOR = data.createNestedObject (String (F (" SENSOR" )));
115
+ byte valueCount = getValueCountFromSensorType (element.sensorType );
116
+ // char itemNames[valueCount][2];
117
+ for (byte x = 0 ; x < valueCount; x++)
118
+ {
119
+ // Each sensor value get an own object (0..n)
120
+ // sprintf(itemNames[x],"%d",x);
121
+ JsonObject& val = SENSOR.createNestedObject (String (x));
122
+ val[F (" deviceName" )] = getTaskDeviceName (element.TaskIndex );
123
+ val[F (" valueName" )] = ExtraTaskSettings.TaskDeviceValueNames [x];
124
+ val[F (" type" )] = element.sensorType ;
125
+ val[F (" value" )] = element.txt [x];
126
+ }
127
+
128
+ // Create json buffer
129
+ root.printTo (jsonString);
126
130
}
127
131
128
- // Create json buffer
129
- String jsonString;
130
- root.printTo (jsonString);
131
-
132
132
// We now create a URI for the request
133
- String url = F (" /ESPEasy" );
134
-
135
133
String request = create_http_request_auth (
136
134
controller_number, element.controller_idx , ControllerSettings,
137
- F (" POST" ), url , jsonString.length ());
135
+ F (" POST" ), F ( " /ESPEasy " ) , jsonString.length ());
138
136
request += jsonString;
139
137
140
138
return send_via_http (controller_number, client, request, ControllerSettings.MustCheckReply );
0 commit comments