mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 08:13:23 +00:00
addded logging for url item json decoding, fixed harmony activity json
decoding
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>4beta3.3</version>
|
<version>4beta3.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.bwssystems.HABridge.plugins.hue.HueHome;
|
|||||||
import com.bwssystems.HABridge.util.JsonTransformer;
|
import com.bwssystems.HABridge.util.JsonTransformer;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import static spark.Spark.get;
|
import static spark.Spark.get;
|
||||||
import static spark.Spark.options;
|
import static spark.Spark.options;
|
||||||
@@ -746,8 +747,16 @@ public class HueMulator {
|
|||||||
} else if(!url.startsWith("[{\"item\""))
|
} else if(!url.startsWith("[{\"item\""))
|
||||||
url = "[{\"item\":" + url + "}]";
|
url = "[{\"item\":" + url + "}]";
|
||||||
|
|
||||||
|
log.debug("Decode Json for url items: " + url);
|
||||||
CallItem[] callItems = null;
|
CallItem[] callItems = null;
|
||||||
callItems = aGsonHandler.fromJson(url, CallItem[].class);
|
try {
|
||||||
|
callItems = aGsonHandler.fromJson(url, CallItem[].class);
|
||||||
|
} catch(JsonSyntaxException e) {
|
||||||
|
log.warn("Could not decode Json for url items: " + lightId + " for hue state change request: " + userId + " from "
|
||||||
|
+ ipAddress + " body: " + body + " url items: " + url);
|
||||||
|
return aGsonHandler.toJson(HueErrorResponse.createResponse("3", "/lights/" + lightId,
|
||||||
|
"Could decode json in request", "/lights/" + lightId, null, null).getTheErrors(), HueError[].class);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; callItems != null && i < callItems.length; i++) {
|
for (int i = 0; callItems != null && i < callItems.length; i++) {
|
||||||
if(!filterByRequester(callItems[i].getFilterIPs(), ipAddress)) {
|
if(!filterByRequester(callItems[i].getFilterIPs(), ipAddress)) {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class HarmonyHome implements Home {
|
|||||||
} else {
|
} else {
|
||||||
if(anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex]))
|
if(anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex]))
|
||||||
{
|
{
|
||||||
RunActivity anActivity = aGsonHandler.fromJson(anItem.getItem().getAsString(), RunActivity.class);
|
RunActivity anActivity = aGsonHandler.fromJson(anItem.getItem(), RunActivity.class);
|
||||||
if(anActivity.getHub() == null || anActivity.getHub().isEmpty())
|
if(anActivity.getHub() == null || anActivity.getHub().isEmpty())
|
||||||
anActivity.setHub(device.getTargetDevice());
|
anActivity.setHub(device.getTargetDevice());
|
||||||
HarmonyHandler myHarmony = getHarmonyHandler(anActivity.getHub());
|
HarmonyHandler myHarmony = getHarmonyHandler(anActivity.getHub());
|
||||||
|
|||||||
Reference in New Issue
Block a user