[Hueemulation] Fix xy change response (#10692)

Signed-off-by: Flole <flole@flole.de>
This commit is contained in:
Flole998 2021-12-11 11:35:33 +01:00 committed by GitHub
parent c1b10c8363
commit ebf2a76311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -13,7 +13,9 @@
package org.openhab.io.hueemulation.internal.dto.response;
import java.lang.reflect.Type;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
@ -65,6 +67,9 @@ public class HueSuccessResponseStateChanged extends HueSuccessResponse {
if (product.value instanceof String) {
jObj.addProperty(product.relURI, (String) product.value);
}
if (product.value instanceof List) {
jObj.add(product.relURI, new Gson().toJsonTree(product.value));
}
return jObj;
}
}

View File

@ -306,6 +306,7 @@ public class LightsAndGroupsTests {
.put(Entity.json(body));
assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success"));
assertThat(response.readEntity(String.class), containsString("xy"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(200));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).xy[0], is(0.5119));