diff --git a/pom.xml b/pom.xml
index 96d3a15..9575212 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 1.1.0a
+ 1.1.0b
jar
HA Bridge
@@ -33,7 +33,7 @@
com.sparkjava
spark-core
- 2.2
+ 2.3
org.apache.httpcomponents
diff --git a/src/main/java/com/bwssystems/HABridge/HABridge.java b/src/main/java/com/bwssystems/HABridge/HABridge.java
index 080b34d..b803583 100644
--- a/src/main/java/com/bwssystems/HABridge/HABridge.java
+++ b/src/main/java/com/bwssystems/HABridge/HABridge.java
@@ -85,7 +85,7 @@ public class HABridge {
// setup the class to handle the resource setup rest api
theResources = new DeviceResource(bridgeSettings, theVersion, myHarmonyServer.getMyHarmony());
// setup the class to handle the hue emulator rest api
- theHueMulator = new HueMulator(theResources.getDeviceRepository(), myHarmonyServer.getMyHarmony());
+ theHueMulator = new HueMulator(bridgeSettings, theResources.getDeviceRepository(), myHarmonyServer.getMyHarmony());
theHueMulator.setupServer();
// setup the class to handle the upnp response rest api
theSettingResponder = new UpnpSettingsResource(bridgeSettings);
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index b094194..74be736 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -1,5 +1,6 @@
package com.bwssystems.HABridge.hue;
+import com.bwssystems.HABridge.BridgeSettings;
import com.bwssystems.HABridge.JsonTransformer;
import com.bwssystems.HABridge.api.UserCreateRequest;
import com.bwssystems.HABridge.api.hue.DeviceResponse;
@@ -58,14 +59,18 @@ public class HueMulator {
private HarmonyHandler myHarmony;
private HttpClient httpClient;
private ObjectMapper mapper;
+ private Integer lastCount;
+ private BridgeSettings bridgeSettings;
- public HueMulator(DeviceRepository aDeviceRepository, HarmonyHandler theHandler){
+ public HueMulator(BridgeSettings theBridgeSettings, DeviceRepository aDeviceRepository, HarmonyHandler theHandler){
httpClient = HttpClients.createDefault();
mapper = new ObjectMapper(); //armzilla: work around Echo incorrect content type and breaking mapping. Map manually
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
repository = aDeviceRepository;
myHarmony = theHandler;
+ bridgeSettings = theBridgeSettings;
+ lastCount = 0;
}
// This function sets up the sparkjava rest calls for the hue api
@@ -77,9 +82,13 @@ public class HueMulator {
log.debug("hue lights list requested: " + userId + " from " + request.ip());
List deviceList = repository.findAll();
Map deviceResponseMap = new HashMap<>();
- for (DeviceDescriptor device : deviceList) {
+ for (int i = 0; i < bridgeSettings.getUpnpResponseDevices(); i++) {
+ if(lastCount == deviceList.size())
+ lastCount = 0;
+ DeviceDescriptor device = deviceList.get(lastCount);
DeviceResponse deviceResponse = DeviceResponse.createResponse(device.getName(), device.getId());
deviceResponseMap.put(device.getId(), deviceResponse);
+ lastCount++;
}
response.type("application/json; charset=utf-8");
response.status(HttpStatus.SC_OK);