Update state error messages Homes, update gateway login

This commit is contained in:
BWS Systems
2019-05-30 15:45:35 -05:00
parent 5f6bfae41a
commit 2d3fac691b
19 changed files with 101 additions and 55 deletions

View File

@@ -1246,7 +1246,7 @@ public class HueMulator {
if (isOnRequest) {
if (bridgeSettings.isTracestate())
log.info("Tracestate: Calling on-off as requested.");
log.info("Tracestate: Calling on-off as requested: " + theStateChanges.isOn());
log.debug("Calling on-off as requested.");
if (theStateChanges.isOn()) {
@@ -1265,6 +1265,9 @@ public class HueMulator {
if (url != null && !url.equals("")) {
responseString = callUrl(url, device, userId, lightId, body, ipAddress, ignoreRequester, targetBri,
targetBriInc, colorData);
if (responseString != null && responseString.contains("[{\"error\":")) {
log.warn("On/Off Request failed with: " + responseString);
}
} else {
log.info("On/off url not available for state change, lightId: " + lightId + ", userId: " + userId
+ ", from IP: " + ipAddress + ", body: " + body);
@@ -1273,7 +1276,7 @@ public class HueMulator {
if (isDimRequest) {
if (bridgeSettings.isTracestate())
log.info("Tracestate: Calling dim as requested.");
log.info("Tracestate: Calling dim as requested: " + targetBri + ", inc: " + targetBriInc);
log.debug("Calling dim as requested.");
url = device.getDimUrl();
@@ -1295,6 +1298,9 @@ public class HueMulator {
}
responseString = callUrl(url, device, userId, lightId, body, ipAddress, ignoreRequester, targetBri,
targetBriInc, colorData);
if (responseString != null && responseString.contains("[{\"error\":")) {
log.warn("Dim Request failed with: " + responseString);
}
} else {
log.info("Dim url not available for state change, lightId: " + lightId + ", userId: " + userId
+ ", from IP: " + ipAddress + ", body: " + body);
@@ -1324,6 +1330,9 @@ public class HueMulator {
}
responseString = callUrl(url, device, userId, lightId, body, ipAddress, ignoreRequester, targetBri,
targetBriInc, colorData);
if (responseString != null && responseString.contains("[{\"error\":")) {
log.warn("Color Request failed with: " + responseString);
}
} else {
log.info("Color url not available for state change, lightId: " + lightId + ", userId: " + userId
+ ", from IP: " + ipAddress + ", body: " + body);
@@ -1346,7 +1355,8 @@ public class HueMulator {
}
private ColorData parseColorInfo(String body, StateChangeBody theStateChanges, DeviceState state, Integer targetBri, Integer targetBriInc) {
private ColorData parseColorInfo(String body, StateChangeBody theStateChanges, DeviceState state, Integer targetBri,
Integer targetBriInc) {
ColorData colorData = null;
List<Double> xy = null;
List<Double> xyInc = null;
@@ -1402,9 +1412,9 @@ public class HueMulator {
} else if (hue != null || sat != null) {
anHSL = new HueSatBri();
int bri = 0;
if(targetBriInc != null) {
if (targetBriInc != null) {
bri = state.getBri() - targetBriInc;
if(bri < 0)
if (bri < 0)
bri = 0;
} else if (targetBri != null) {
bri = targetBri;
@@ -1412,12 +1422,12 @@ public class HueMulator {
bri = state.getBri();
}
anHSL.setBri(bri);
if(hue != null)
if (hue != null)
anHSL.setHue(hue);
else
anHSL.setHue(state.getHue());
if(sat != null)
if (sat != null)
anHSL.setSat(sat);
else
anHSL.setSat(state.getSat());
@@ -1426,9 +1436,9 @@ public class HueMulator {
} else if (hueInc != null || satInc != null) {
anHSL = new HueSatBri();
int bri = 0;
if(targetBriInc != null) {
if (targetBriInc != null) {
bri = state.getBri() - targetBriInc;
if(bri < 0)
if (bri < 0)
bri = 0;
} else if (targetBri != null) {
bri = targetBri;
@@ -1436,12 +1446,12 @@ public class HueMulator {
bri = state.getBri();
}
anHSL.setBri(bri);
if(hueInc != null)
if (hueInc != null)
anHSL.setHue(state.getHue() - hueInc);
else
anHSL.setHue(state.getHue());
if(satInc != null)
if (satInc != null)
anHSL.setSat(state.getSat() - satInc);
else
anHSL.setSat(state.getSat());
@@ -1591,6 +1601,8 @@ public class HueMulator {
} else if (!url.startsWith("[{\"item\""))
url = "[{\"item\":" + url + "}]";
if (bridgeSettings.isTracestate())
log.info("Tracestate: Decode Json for url items: " + url);
log.debug("Decode Json for url items: " + url);
CallItem[] callItems = null;
try {
@@ -1639,7 +1651,8 @@ public class HueMulator {
aMultiUtil.setTheDelay(callItems[i].getDelay());
else
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
if (bridgeSettings.isTracestate())
log.info("Tracestate: Calling Home device handler for type : " + callItems[i].getType().trim());
log.debug("Calling Home device handler for type : " + callItems[i].getType().trim());
responseString = homeManager.findHome(callItems[i].getType().trim()).deviceHandler(callItems[i],
aMultiUtil, lightId, device.getDeviceState().getBri(), targetBri, targetBriInc, colorData,

View File

@@ -119,7 +119,7 @@ public class NestHome implements com.bwssystems.HABridge.Home {
log.warn("Should not get here, no Nest available");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no Nest available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else if (anItem.getType() != null && anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.NEST_HOMEAWAY[DeviceMapTypes.typeIndex])) {
NestInstruction homeAway = null;
if(anItem.getItem().isJsonObject())
@@ -167,7 +167,7 @@ public class NestHome implements com.bwssystems.HABridge.Home {
log.warn("no valid Nest control info: " + thermoSetting.getControl());
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"no valid Nest control info\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
}
return responseString;

View File

@@ -106,11 +106,14 @@ public class BroadlinkHome implements Home {
log.warn("Should not get here, no Broadlinks configured");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no LifxDevices configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
BroadlinkEntry broadlinkCommand = null;
broadlinkCommand = new Gson().fromJson(anItem.getItem().getAsString(), BroadlinkEntry.class);
if(anItem.getItem().isJsonObject())
broadlinkCommand = new Gson().fromJson(anItem.getItem(), BroadlinkEntry.class);
else
broadlinkCommand = new Gson().fromJson(anItem.getItem().getAsString(), BroadlinkEntry.class);
BLDevice theDevice = null;
if(broadlinkMap != null && !broadlinkMap.isEmpty())
theDevice = broadlinkMap.get(broadlinkCommand.getId());
@@ -126,17 +129,17 @@ public class BroadlinkHome implements Home {
log.warn("Could not initialize BroadlinkDevice device due to Mac (" + broadlinkCommand.getId() + ") format exception: " + e.getMessage());
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Could not initialize BroadlinkDevice device due to Mac format exception\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} catch (IOException e) {
log.warn("Could not initialize BroadlinkDevice device due to IP Address (" + broadlinkCommand.getId() + ") exception: " + e.getMessage());
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Could not initialize BroadlinkDevice device due to IP Address exception\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} catch (Exception e) {
log.warn("Could not initialize BroadlinkDevice device due to (" + broadlinkCommand.getId() + ") exception: " + e.getMessage());
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Could not initialize BroadlinkDevice device due to exception\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
if(broadlinkMap == null)
@@ -154,7 +157,7 @@ public class BroadlinkHome implements Home {
log.warn("Should not get here, no BroadlinkDevice not available");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no Broadlinks available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
log.debug("calling BroadlinkDevice: " + broadlinkCommand.getName());
try {
@@ -163,7 +166,7 @@ public class BroadlinkHome implements Home {
log.error("Call to " + broadlinkCommand.getId() + " device authorization failed.");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"" + broadlinkCommand.getId() + " device auth error.\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
}
switch (theDevice.getDeviceType()) {
@@ -235,7 +238,7 @@ public class BroadlinkHome implements Home {
log.error("Call to " + broadlinkCommand.getId() + " with no data, noop");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"" + broadlinkCommand.getId() + " could not call device without data.\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
break;
@@ -244,7 +247,7 @@ public class BroadlinkHome implements Home {
log.error("Call to " + broadlinkCommand.getId() + " device failed with exception: " + e.getMessage(), e);
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"" + broadlinkCommand.getId() + " device call error.\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
}

View File

@@ -128,25 +128,25 @@ public class DomoticzHome implements Home {
log.warn("Call failed for Domoticz " + theHandler.getDomoticzAddress().getName() + " with status " + theDomoticzApiResponse.getStatus() + " for item " + theDomoticzApiResponse.getTitle());
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
} catch (Exception e) {
log.warn("Cannot interrpret result from call for Domoticz " + theHandler.getDomoticzAddress().getName() + " as response is not parsable.");
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
} else {
log.warn("Domoticz Call could not complete, no address found: " + theUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
} else {
log.warn("Domoticz Call to be presented as http(s)://<ip_address>(:<port>)/payload, format of request unknown: " + theUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
return responseString;
}

View File

@@ -67,13 +67,13 @@ public class CommandHome implements Home {
log.warn("Could not execute request: " + anItem + " with message: " + e.getMessage());
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId
+ "state\"}}]";
+ "/state\"}}]";
}
} else {
log.warn("Could not execute request. Request is empty.");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId
+ "state\"}}]";
+ "/state\"}}]";
}
return responseString;

View File

@@ -55,12 +55,15 @@ public class FHEMHome implements Home {
if(theUrl != null && !theUrl.isEmpty()) {
FHEMCommand theCommand = null;
try {
theCommand = new Gson().fromJson(theUrl, FHEMCommand.class);
if(anItem.getItem().isJsonObject())
theCommand = new Gson().fromJson(anItem.getItem(), FHEMCommand.class);
else
theCommand = new Gson().fromJson(anItem.getItem().getAsString(), FHEMCommand.class);
} catch(Exception e) {
log.warn("Cannot parse command to FHEM <<<" + theUrl + ">>>", e);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
return responseString;
}
String intermediate = theCommand.getUrl().substring(theCommand.getUrl().indexOf("://") + 3);

View File

@@ -165,7 +165,7 @@ public class HalHome implements Home {
log.warn("Error on calling hal to change device state: " + anUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
}
}
@@ -175,7 +175,7 @@ public class HalHome implements Home {
log.warn("No HAL found to call: " + theUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"No HAL found.", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
return responseString;
}

View File

@@ -187,7 +187,7 @@ public class HarmonyHome implements Home {
log.warn("Should not get here, no harmony configured");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no harmony configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
if (anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex])) {
RunActivity anActivity = null;
@@ -202,7 +202,7 @@ public class HarmonyHome implements Home {
log.warn("Should not get here, no harmony hub available");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no harmony hub available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
if (!myHarmony.startActivity(anActivity)) {
if (resetHub(myHarmony)) {
@@ -212,7 +212,7 @@ public class HarmonyHome implements Home {
+ ", please restart...");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Could not communicate with harmony\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
}
}
@@ -265,7 +265,7 @@ public class HarmonyHome implements Home {
+ ", please restart...");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Could not communicate with harmony\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
}
}

View File

@@ -131,7 +131,7 @@ public class HassHome implements Home {
log.warn("Should not get here, no HomeAssistant clients configured");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no HomeAssistants configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
HassCommand hassCommand = null;
@@ -146,7 +146,7 @@ public class HassHome implements Home {
log.warn("Should not get here, no HomeAssistants available");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no HiomeAssistant clients available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
log.debug("calling HomeAssistant: " + hassCommand.getHassName() + " - "
+ hassCommand.getEntityId() + " - " + hassCommand.getState() + " - " + hassCommand.getBri());

View File

@@ -49,7 +49,7 @@ public class HomeWizardHome implements Home {
log.warn("Should not get here, no HomeWizard smart plug available");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no HomeWizard smart plug available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
if (anItem.getType() != null && anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HOMEWIZARD_DEVICE[DeviceMapTypes.typeIndex])) {
@@ -62,7 +62,7 @@ public class HomeWizardHome implements Home {
log.warn("Should not get here, no HomeWizard smart plug configured");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no HomeWizard smart plug configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
try {
homeWizzardHandler.execApply(jsonToPost);
@@ -70,7 +70,7 @@ public class HomeWizardHome implements Home {
log.warn("Error posting request to HomeWizard smart plug");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error posting request to HomeWizard smart plug\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
+ "\",\"description\": \"Error posting request to HomeWizard smart plug\", \"parameter\": \"/lights/" + lightId + "/state\"}}]";
}
}
}

View File

@@ -86,7 +86,7 @@ public class HTTPHome implements Home {
log.warn("Error on calling url to change device state: " + anUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
if(isDevMode)
@@ -95,7 +95,7 @@ public class HTTPHome implements Home {
log.warn("HTTP Call to be presented as http(s)://<ip_address>(:<port>)/payload, format of request unknown: " + theUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
}
return responseString;

View File

@@ -159,7 +159,7 @@ public class HueInfo {
log.warn("Error on calling Hue passthru to change device state: " + deviceId.getHueName());
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error on calling HUE to change device state\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else if (responseString.contains("[{\"error\":")) {
// if(responseString.contains("unauthorized user")) {
// }

View File

@@ -144,7 +144,7 @@ public class LifxHome implements Home {
log.warn("Should not get here, no LifxDevice clients configured");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no LifxDevices configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
LifxEntry lifxCommand = null;
@@ -157,7 +157,7 @@ public class LifxHome implements Home {
log.warn("Should not get here, no LifxDevices available");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no Lifx clients available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
log.debug("calling LifxDevice: " + lifxCommand.getName());
if(theDevice.getType().equals(LifxDevice.LIGHT_TYPE)) {

View File

@@ -50,12 +50,13 @@ public class MozIotHome implements Home {
if(theUrl != null && !theUrl.isEmpty()) {
MozIotCommand theCommand = null;
try {
theUrl = theUrl.replaceAll("^\"|\"$", "");
theCommand = new Gson().fromJson(theUrl, MozIotCommand.class);
} catch(Exception e) {
log.warn("Cannot parse command to Mozilla IOT <<<" + theUrl + ">>>", e);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
return responseString;
}
String intermediate = theCommand.getUrl().substring(theCommand.getUrl().indexOf("://") + 3);

View File

@@ -94,10 +94,17 @@ public class MozIotInstance {
else
aUrl = "http://";
headers = new NameValue[2];
headers[0] = new NameValue();
headers[0].setName("Content-Type");
headers[0].setValue("application/json");
headers[1] = new NameValue();
headers[1].setName("Accept");
headers[1].setValue("application/json");
aUrl = aUrl + mozIotIP.getIp() + ":" + mozIotIP.getPort() + "/login";
String commandData = "{\"email\": \"" + mozIotIP.getUsername() + "\", \"password\":\"" + mozIotIP.getPassword()
+ "\"}";
String theData = httpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "application/json", commandData, null);
String theData = httpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "application/json", commandData, headers);
if (theData != null) {
log.info("GET Mozilla login - data: " + theData);
try {
@@ -108,6 +115,8 @@ public class MozIotInstance {
} else {
log.warn("Could not login " + mozIotIP.getName() + " error: <<<" + theData + ">>>");
}
headers = null;
}
public NamedIP getMozIotIP() {

View File

@@ -128,7 +128,7 @@ public class MQTTHome implements Home {
log.warn("Should not get here, no mqtt brokers configured");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no mqtt brokers configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
}
return responseString;

View File

@@ -51,12 +51,15 @@ public class OpenHABHome implements Home {
if(theUrl != null && !theUrl.isEmpty()) {
OpenHABCommand theCommand = null;
try {
theCommand = new Gson().fromJson(theUrl, OpenHABCommand.class);
if(anItem.getItem().isJsonObject())
theCommand = new Gson().fromJson(anItem.getItem(), OpenHABCommand.class);
else
theCommand = new Gson().fromJson(anItem.getItem().getAsString(), OpenHABCommand.class);
} catch(Exception e) {
log.warn("Cannot parse command to OpenHAB <<<" + theUrl + ">>>", e);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
"Error on calling url to change device state", "/lights/"
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
+ lightId + "/state", null, null).getTheErrors(), HueError[].class);
return responseString;
}
String intermediate = theCommand.getUrl().substring(theCommand.getUrl().indexOf("://") + 3);

View File

@@ -72,7 +72,7 @@ public class SomfyHome implements Home {
log.warn("Should not get here, no somfy hub available");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no somfy hub available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
if (anItem.getType() != null && anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex])) {
@@ -84,14 +84,14 @@ public class SomfyHome implements Home {
log.warn("Should not get here, no Somfy configured");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no somfy configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
+ lightId + "/state\"}}]";
} else {
try {
somfyHandler.execApply(jsonToPost);
} catch (Exception e) {
log.warn("Error posting request to Somfy");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Error posting request to SomfyTahoma\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
+ "\",\"description\": \"Error posting request to SomfyTahoma\", \"parameter\": \"/lights/" + lightId + "/state\"}}]";
}
}

View File

@@ -249,6 +249,20 @@ public class UpnpListener {
+ " with discovery responseTemplateOriginal is <<<" + discoveryResponse + ">>>");
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
} else {
discoveryResponse = String.format(responseTemplateOriginal, Configuration.UPNP_MULTICAST_ADDRESS,
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
if (traceupnp) {
log.info("Traceupnp: send upnp discovery template Original with response address: " + httpLocationAddress + ":"
+ httpServerPort + " to address: " + requester + ":" + sourcePort);
} else
log.debug("sendUpnpResponse to address: " + requester + ":" + sourcePort
+ " with discovery responseTemplateOriginal is <<<" + discoveryResponse + ">>>");
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
try {
Thread.sleep(theUpnpSendDelay);
} catch (InterruptedException e) {
// noop
}
discoveryResponse = String.format(responseTemplate1, Configuration.UPNP_MULTICAST_ADDRESS,
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
if (traceupnp) {