Skip to content

Commit

Permalink
[hue] Avoid updating the inbox at each poll (openhab#8066)
Browse files Browse the repository at this point in the history
- Avoid updating the inbox at each poll

Fix openhab#8065

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
  • Loading branch information
lolodomo authored and CSchlipp committed Jul 26, 2020
1 parent 23efb62 commit 8413eab
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,12 @@ protected void doConnectedRun() throws IOException, ApiException {

for (final FullSensor sensor : hueBridge.getSensors()) {
String sensorId = sensor.getId();
lastSensorStateCopy.remove(sensorId);

final SensorStatusListener sensorStatusListener = sensorStatusListeners.get(sensorId);
if (sensorStatusListener == null) {
logger.debug("Hue sensor '{}' added.", sensorId);

if (discovery != null) {
if (discovery != null && !lastSensorStateCopy.containsKey(sensorId)) {
discovery.addSensorDiscovery(sensor);
}

Expand All @@ -192,6 +191,7 @@ protected void doConnectedRun() throws IOException, ApiException {
lastSensorStates.put(sensorId, sensor);
}
}
lastSensorStateCopy.remove(sensorId);
}

// Check for removed sensors
Expand Down Expand Up @@ -227,13 +227,12 @@ protected void doConnectedRun() throws IOException, ApiException {

for (final FullLight fullLight : lights) {
final String lightId = fullLight.getId();
lastLightStateCopy.remove(lightId);

final LightStatusListener lightStatusListener = lightStatusListeners.get(lightId);
if (lightStatusListener == null) {
logger.debug("Hue light '{}' added.", lightId);

if (discovery != null) {
if (discovery != null && !lastLightStateCopy.containsKey(lightId)) {
discovery.addLightDiscovery(fullLight);
}

Expand All @@ -243,6 +242,7 @@ protected void doConnectedRun() throws IOException, ApiException {
lastLightStates.put(lightId, fullLight);
}
}
lastLightStateCopy.remove(lightId);
}

// Check for removed lights
Expand Down Expand Up @@ -310,14 +310,13 @@ protected void doConnectedRun() throws IOException, ApiException {
groupState.getXY());

String groupId = fullGroup.getId();
lastGroupStateCopy.remove(groupId);

final GroupStatusListener groupStatusListener = groupStatusListeners.get(groupId);
if (groupStatusListener == null) {
logger.debug("Hue group '{}' ({}) added (nb lights {}).", groupId, fullGroup.getName(),
fullGroup.getLights().size());

if (discovery != null) {
if (discovery != null && !lastGroupStateCopy.containsKey(groupId)) {
discovery.addGroupDiscovery(fullGroup);
}

Expand All @@ -327,6 +326,7 @@ protected void doConnectedRun() throws IOException, ApiException {
lastGroupStates.put(groupId, fullGroup);
}
}
lastGroupStateCopy.remove(groupId);
}

// Check for removed groups
Expand Down

0 comments on commit 8413eab

Please sign in to comment.