You are absolutely right: That whole part is missing.
Please find below the diff -u _C009.ino _C022.ino
command. Only the differences are displayed. The lines starting with a “-” are the _C009 lines. The lines starting with a “+” are the _CO22 lines. Wutu did the renaming from _C009 to _C022. I added the comments and did the removal of the “>210” statement.
--- _C009.ino 2016-10-18 11:51:10.498638800 +0200
+++ _C022.ino 2016-10-18 11:30:01.409699700 +0200
@@ -1,12 +1,23 @@
//#######################################################################################################
-//########################### Controller Plugin 009: Pimatic RestApi ####################################
+//########################### Controller Plugin 022: Pimatic RestApi ####################################
//#######################################################################################################
-#define CPLUGIN_009
-#define CPLUGIN_ID_009 9
-#define CPLUGIN_NAME_009 "Pimatic RestApi"
+/*******************************************************************************
+ * Release notes:
+ * V 1.0
+ - First version by deejaybeam, 7 July 2016
+ * V 1.01
+ - Update and rename _C009.ino to _C022.ino by Wutu due to new standard protocols, 21 September 2016
+ * V1.02
+ - Remove ">210" core statement to comply (and function) with new standard 230 core as of R114, 24 September 2016
+ *
+ /******************************************************************************/
+
+#define CPLUGIN_022
+#define CPLUGIN_ID_022 22
+#define CPLUGIN_NAME_022 "Pimatic RestApi"
-boolean CPlugin_009(byte function, struct EventStruct *event, String& string)
+boolean CPlugin_022(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
@@ -14,7 +25,7 @@
{
case CPLUGIN_PROTOCOL_ADD:
{
- Protocol[++protocolCount].Number = CPLUGIN_ID_009;
+ Protocol[++protocolCount].Number = CPLUGIN_ID_022;
Protocol[protocolCount].usesMQTT = false;
Protocol[protocolCount].usesAccount = true;
Protocol[protocolCount].usesPassword = true;
@@ -24,7 +35,7 @@
case CPLUGIN_GET_DEVICENAME:
{
- string = F(CPLUGIN_NAME_009);
+ string = F(CPLUGIN_NAME_022);
break;
}
@@ -33,6 +44,7 @@
switch (event->sensorType)
{
case SENSOR_TYPE_SINGLE: // single value sensor, used for Dallas, BH1750, etc
+ case SENSOR_TYPE_SWITCH:
case SENSOR_TYPE_DIMMER:
pimaticUpdateVariable(event, 0, UserVar[event->BaseVarIndex], 0);
break;
@@ -62,11 +74,6 @@
pimaticUpdateVariable(event, 2, UserVar[event->BaseVarIndex + 2], 0);
break;
}
- case SENSOR_TYPE_SWITCH:
- {
- pimaticSetSwitchState(event, 0, UserVar[event->BaseVarIndex]);
- break;
- }
}
break;
}
@@ -83,7 +90,7 @@
{
String authHeader = "";
- #if ESP_CORE >= 210
+
if ((SecuritySettings.ControllerUser[0] != 0) && (SecuritySettings.ControllerPassword[0] != 0))
{
base64 encoder;
@@ -92,7 +99,7 @@
auth += SecuritySettings.ControllerPassword;
authHeader = "Authorization: Basic " + encoder.encode(auth) + " \r\n";
}
- #endif
+
char log[80];
boolean success = false;
@@ -167,91 +174,5 @@
client.stop();
}
-//********************************************************************************
-// Pimatic setSwitchState
-//********************************************************************************
-boolean pimaticSetSwitchState(struct EventStruct *event, byte varIndex, float value)
-{
-
- String authHeader = "";
-#if ESP_CORE >= 210
- if ((SecuritySettings.ControllerUser[0] != 0) && (SecuritySettings.ControllerPassword[0] != 0))
- {
- base64 encoder;
- String auth = SecuritySettings.ControllerUser;
- auth += ":";
- auth += SecuritySettings.ControllerPassword;
- authHeader = "Authorization: Basic " + encoder.encode(auth) + " \r\n";
- }
-#endif
-
- char log[80];
- boolean success = false;
- char host[20];
- sprintf_P(host, PSTR("%u.%u.%u.%u"), Settings.Controller_IP[0], Settings.Controller_IP[1], Settings.Controller_IP[2], Settings.Controller_IP[3]);
-
- sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host, Settings.ControllerPort);
- addLog(LOG_LEVEL_DEBUG, log);
-
- // Use WiFiClient class to create TCP connections
- WiFiClient client;
- if (!client.connect(host, Settings.ControllerPort))
- {
- connectionFailures++;
- strcpy_P(log, PSTR("HTTP : connection failed"));
- addLog(LOG_LEVEL_ERROR, log);
- return false;
- }
- statusLED(true);
- if (connectionFailures)
- connectionFailures--;
-
- if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
- PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
-
- String url = "/api/device/";
- url += URLEncode(ExtraTaskSettings.TaskDeviceValueNames[varIndex]);
-
- if (value == 0)
- url += "/turnOff";
- else
- url += "/turnOn";
-
- url.toCharArray(log, 80);
- addLog(LOG_LEVEL_DEBUG_MORE, log);
-
- String hostName = host;
- if (Settings.UseDNS)
- hostName = Settings.ControllerHostName;
-
- // This will send the request to the server
- client.print(String("GET ") + url + " HTTP/1.1\r\n" +
- "Host: " + hostName + "\r\n" + authHeader +
- "Connection: close\r\n\r\n");
-
- unsigned long timer = millis() + 200;
- while (!client.available() && millis() < timer)
- delay(1);
-
- // Read all the lines of the reply from server and print them to Serial
- while (client.available()) {
- String line = client.readStringUntil('\n');
- line.toCharArray(log, 80);
- addLog(LOG_LEVEL_DEBUG_MORE, log);
- if (line.substring(0, 15) == "HTTP/1.1 200 OK")
- {
- strcpy_P(log, PSTR("HTTP : Succes!"));
- addLog(LOG_LEVEL_DEBUG, log);
- success = true;
- }
- delay(1);
- }
- strcpy_P(log, PSTR("HTTP : closing connection"));
- addLog(LOG_LEVEL_DEBUG, log);
-
- client.flush();
- client.stop();
-}
-
@deejaybeam : Can you please explain to us whether you deliberately removed this entire function or that it is a mistake?