Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _C001.ino #8

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions _C001.ino
Original file line number Diff line number Diff line change
Expand Up @@ -144,51 +144,3 @@ boolean CPlugin_001(byte function, struct EventStruct *event)
return success;
}

boolean Domoticz_getData(int idx, float *data)
{
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]);

// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
{
connectionFailures++;
return false;
}
if (connectionFailures)
connectionFailures--;

// We now create a URI for the request
String url = F("/json.htm?type=devices&rid=");
url += idx;

// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"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');
if (line.substring(10, 14) == "Data")
{
String strValue = line.substring(19);
byte pos = strValue.indexOf(' ');
strValue = strValue.substring(0, pos);
strValue.trim();
float value = strValue.toFloat();
*data = value;
success = true;
}
}
return success;
}