[velux] Fixed a couple of bugs if the Bridge contains one or more Scenes (#9794)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2021-01-13 22:01:01 +00:00 committed by GitHub
parent 8616c72ce1
commit b4705eb75c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 7 deletions

View File

@ -100,6 +100,9 @@ public class VeluxBindingConstants {
THING_TYPE_VELUX_ACTUATOR, THING_TYPE_VELUX_ROLLERSHUTTER, THING_TYPE_VELUX_WINDOW, THING_TYPE_VELUX_ACTUATOR, THING_TYPE_VELUX_ROLLERSHUTTER, THING_TYPE_VELUX_WINDOW,
THING_TYPE_VELUX_VSHUTTER, THING_TYPE_BINDING, THING_TYPE_BRIDGE); THING_TYPE_VELUX_VSHUTTER, THING_TYPE_BINDING, THING_TYPE_BRIDGE);
public static final Set<ThingTypeUID> ACTUATOR_THINGS = Set.of(THING_TYPE_VELUX_ACTUATOR,
THING_TYPE_VELUX_ROLLERSHUTTER, THING_TYPE_VELUX_WINDOW);
// *** List of all Channel ids *** // *** List of all Channel ids ***
// List of all binding channel ids // List of all binding channel ids
@ -153,6 +156,4 @@ public class VeluxBindingConstants {
public static final String UNKNOWN_THING_TYPE_ID = "FAILED"; public static final String UNKNOWN_THING_TYPE_ID = "FAILED";
public static final String UNKNOWN_IP_ADDRESS = "xxx.xxx.xxx.xxx"; public static final String UNKNOWN_IP_ADDRESS = "xxx.xxx.xxx.xxx";
public static final String BRIDGE_THING_TYPE_UID = THING_TYPE_BRIDGE.toString();
} }

View File

@ -313,7 +313,8 @@ public class VeluxDiscoveryService extends AbstractDiscoveryService implements R
@Override @Override
protected void startBackgroundDiscovery() { protected void startBackgroundDiscovery() {
logger.trace("startBackgroundDiscovery() called."); logger.trace("startBackgroundDiscovery() called.");
if (backgroundTask == null || backgroundTask.isCancelled()) { ScheduledFuture<?> task = this.backgroundTask;
if (task == null || task.isCancelled()) {
this.backgroundTask = scheduler.scheduleWithFixedDelay(this::startScan, 10, 600, TimeUnit.SECONDS); this.backgroundTask = scheduler.scheduleWithFixedDelay(this::startScan, 10, 600, TimeUnit.SECONDS);
} }
} }

View File

@ -81,7 +81,7 @@ final class ChannelBridgeCheck extends ChannelHandlerTemplate {
LOGGER.trace("handleCommand(): ignoring non SCENE_ACTION."); LOGGER.trace("handleCommand(): ignoring non SCENE_ACTION.");
continue; continue;
} }
if (!ThingConfiguration.exists(thisBridgeHandler, channelUID, if (!ThingConfiguration.exists(thisBridgeHandler, thisChannelUID,
VeluxBindingProperties.PROPERTY_SCENE_NAME)) { VeluxBindingProperties.PROPERTY_SCENE_NAME)) {
LOGGER.trace("handleCommand(): aborting processing as scene name is not set."); LOGGER.trace("handleCommand(): aborting processing as scene name is not set.");
break; break;

View File

@ -200,7 +200,7 @@ public class VeluxBridgeHandler extends ExtendedBaseBridgeHandler implements Vel
* @param channelUID for type {@link ChannelUID}. * @param channelUID for type {@link ChannelUID}.
* @return thingTypeUID of type {@link ThingTypeUID}. * @return thingTypeUID of type {@link ThingTypeUID}.
*/ */
ThingTypeUID thingTypeUIDOf(ChannelUID channelUID) { public ThingTypeUID thingTypeUIDOf(ChannelUID channelUID) {
String[] segments = channelUID.getAsString().split(AbstractUID.SEPARATOR); String[] segments = channelUID.getAsString().split(AbstractUID.SEPARATOR);
if (segments.length > 1) { if (segments.length > 1) {
return new ThingTypeUID(segments[0], segments[1]); return new ThingTypeUID(segments[0], segments[1]);

View File

@ -52,8 +52,9 @@ public class Thing2VeluxActuator {
// Private // Private
private void mapThing2Velux() { private void mapThing2Velux() {
if (channelUID.toString().startsWith(VeluxBindingConstants.BRIDGE_THING_TYPE_UID)) { // only process real actuator things
logger.trace("mapThing2Velux(): channel {} is on a Bridge Thing, exiting.", channelUID); if (!VeluxBindingConstants.ACTUATOR_THINGS.contains(bridgeHandler.thingTypeUIDOf(channelUID))) {
logger.trace("mapThing2Velux(): channel {} is not an Actuator Thing, exiting.", channelUID);
return; return;
} }