Updated FHEM for command

Started Broadlink implementation
This commit is contained in:
bsamuels
2018-01-18 16:54:21 -06:00
parent 4b048c2a7f
commit 5a052d9374
15 changed files with 725 additions and 305 deletions

View File

@@ -1,20 +1,50 @@
package com.bwssystems.HABridge.plugins.http;
import java.util.ArrayList;
import java.util.List;
import com.bwssystems.HABridge.api.NameValue;
import com.bwssystems.HABridge.plugins.http.HTTPHandler;
public class HttpTestHandler extends HTTPHandler {
private String theData;
private List<NameValue> theData;
public String getTheData() {
return theData;
public void setTheData(String compareValue, String testData) {
if( this.theData == null )
this.theData = new ArrayList<NameValue>();
NameValue aValueSet = new NameValue();
aValueSet.setName(compareValue);
aValueSet.setValue(testData);
this.theData.add(aValueSet);
}
public void setTheData(String theData) {
this.theData = theData;
public void updateTheData(String compareValue, String testData) {
if( this.theData == null ) {
this.theData = new ArrayList<NameValue>();
NameValue aValueSet = new NameValue();
aValueSet.setName(compareValue);
aValueSet.setValue(testData);
this.theData.add(aValueSet);
}
else {
for(NameValue aTest:this.theData) {
if(aTest.getName().equals(compareValue));
aTest.setValue(testData);
}
}
}
public String doHttpRequest(String url, String httpVerb, String contentType, String body, NameValue[] headers) {
return theData;
String responseData = null;
for(NameValue aTest:theData) {
if(url.contains(aTest.getName()))
responseData = aTest.getValue();
else if(aTest.getName() == null || aTest.getName().isEmpty())
responseData = aTest.getValue();
if(responseData != null)
break;
}
return responseData;
}
}