mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[digitalstrom] Fix initialization of temperature control devices (#16352)
* Fix UnsupportedOperation thrown when adding an element to a fixed-size list. Fixes #10649 * removed static modifier on SUPPORTED_EVENTS and made the field a normal member Signed-off-by: Rouven Schürch <r.schuerch@gmx.ch>
This commit is contained in:
parent
7671f4b9b1
commit
ef7e03c1c6
@ -12,12 +12,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.digitalstrom.internal.lib.manager.impl;
|
package org.openhab.binding.digitalstrom.internal.lib.manager.impl;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.openhab.binding.digitalstrom.internal.lib.climate.TemperatureControlSensorTransmitter;
|
import org.openhab.binding.digitalstrom.internal.lib.climate.TemperatureControlSensorTransmitter;
|
||||||
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
|
import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl.TemperatureControlStatus;
|
||||||
@ -60,7 +61,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class TemperatureControlManager implements EventHandler, TemperatureControlSensorTransmitter {
|
public class TemperatureControlManager implements EventHandler, TemperatureControlSensorTransmitter {
|
||||||
|
|
||||||
private static final List<String> SUPPORTED_EVENTS = Arrays.asList(EventNames.HEATING_CONTROL_OPERATION_MODE);
|
private final Set<String> supportedEvents;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(TemperatureControlManager.class);
|
private final Logger logger = LoggerFactory.getLogger(TemperatureControlManager.class);
|
||||||
|
|
||||||
@ -149,12 +150,14 @@ public class TemperatureControlManager implements EventHandler, TemperatureContr
|
|||||||
this.systemStateChangeListener = systemStateChangeListener;
|
this.systemStateChangeListener = systemStateChangeListener;
|
||||||
this.discovery = discovery;
|
this.discovery = discovery;
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
|
this.supportedEvents = new HashSet<>();
|
||||||
|
this.supportedEvents.add(EventNames.HEATING_CONTROL_OPERATION_MODE);
|
||||||
checkZones();
|
checkZones();
|
||||||
if (eventListener != null) {
|
if (eventListener != null) {
|
||||||
if (isConfigured) {
|
if (isConfigured) {
|
||||||
SUPPORTED_EVENTS.add(EventNames.ZONE_SENSOR_VALUE);
|
supportedEvents.add(EventNames.ZONE_SENSOR_VALUE);
|
||||||
if (systemStateChangeListener != null) {
|
if (systemStateChangeListener != null) {
|
||||||
SUPPORTED_EVENTS.add(EventNames.STATE_CHANGED);
|
supportedEvents.add(EventNames.STATE_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eventListener.addEventHandler(this);
|
eventListener.addEventHandler(this);
|
||||||
@ -367,12 +370,12 @@ public class TemperatureControlManager implements EventHandler, TemperatureContr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSupportedEvents() {
|
public List<String> getSupportedEvents() {
|
||||||
return SUPPORTED_EVENTS;
|
return List.copyOf(supportedEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsEvent(String eventName) {
|
public boolean supportsEvent(String eventName) {
|
||||||
return SUPPORTED_EVENTS.contains(eventName);
|
return supportedEvents.contains(eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -442,7 +445,7 @@ public class TemperatureControlManager implements EventHandler, TemperatureContr
|
|||||||
*/
|
*/
|
||||||
public void registerSystemStateChangeListener(SystemStateChangeListener systemStateChangeListener) {
|
public void registerSystemStateChangeListener(SystemStateChangeListener systemStateChangeListener) {
|
||||||
if (eventListener != null) {
|
if (eventListener != null) {
|
||||||
SUPPORTED_EVENTS.add(EventNames.STATE_CHANGED);
|
supportedEvents.add(EventNames.STATE_CHANGED);
|
||||||
eventListener.addSubscribe(EventNames.STATE_CHANGED);
|
eventListener.addSubscribe(EventNames.STATE_CHANGED);
|
||||||
}
|
}
|
||||||
this.systemStateChangeListener = systemStateChangeListener;
|
this.systemStateChangeListener = systemStateChangeListener;
|
||||||
|
Loading…
Reference in New Issue
Block a user