mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Corrected group action success response
This commit is contained in:
@@ -1258,13 +1258,20 @@ public class HueMulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, DeviceResponse> light : lights.entrySet()) {
|
for (Map.Entry<String, DeviceResponse> light : lights.entrySet()) {
|
||||||
|
// ignore on/off for devices that are already on/off
|
||||||
if (turnOff && !light.getValue().getState().isOn())
|
if (turnOff && !light.getValue().getState().isOn())
|
||||||
continue;
|
continue;
|
||||||
if (turnOn && light.getValue().getState().isOn())
|
if (turnOn && light.getValue().getState().isOn())
|
||||||
continue;
|
continue;
|
||||||
changeState(userId, light.getKey(), body, ipAddress);
|
changeState(userId, light.getKey(), body, ipAddress);
|
||||||
}
|
}
|
||||||
return "[]";
|
// construct success response: one success message per changed property, but not per light
|
||||||
|
String successString = "[";
|
||||||
|
for (String pairStr : body.replaceAll("[{|}]", "").split(",")) {
|
||||||
|
String[] pair = pairStr.split(":");
|
||||||
|
successString += "{\"success\":{ \"address\": \"/groups/" + groupId + "/action/" + pair[0].replaceAll("\"", "").trim() + "\", \"value\": " + pair[1].trim() + "}},";
|
||||||
|
}
|
||||||
|
return (successString.length() == 1) ? "[]" : successString.substring(0, successString.length()-1) + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user