2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.velux.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.velux.internal.bridge.VeluxBridgeDetectProducts;
18 import org.openhab.core.library.types.OnOffType;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.types.Command;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * <B>Channel-specific retrieval and modification.</B>
27 * This class implements the Channel <B>doDetection</B> of the Thing <B>klf200</B> :
29 * <LI><I>Velux</I> <B>bridge</B> → <B>OpenHAB</B>:
31 * Information retrieval by method {@link #handleRefresh}.</LI>
34 * <LI><B>OpenHAB</B> Event Bus → <I>Velux</I> <B>bridge</B>
36 * Sending commands and value updates by method {@link #handleCommand}.</LI>
39 * @author Guenther Schreiner - Initial contribution.
42 final class ChannelBridgeDoDetection extends ChannelHandlerTemplate {
43 private static final Logger LOGGER = LoggerFactory.getLogger(ChannelBridgeDoDetection.class);
46 * ************************
47 * ***** Constructors *****
50 // Suppress default constructor for non-instantiability
52 private ChannelBridgeDoDetection() {
53 throw new AssertionError();
57 * Communication method to update the real world according to the passed channel value (or command).
59 * @param channelUID The item passed as type {@link ChannelUID} for which to following command is addressed to.
60 * @param channelId The same item passed as type {@link String} for which a refresh is intended.
61 * @param command The command passed as type {@link Command} for the mentioned item.
62 * @param thisBridgeHandler The Velux bridge handler with a specific communication protocol which provides
63 * information for this channel.
64 * @return newValue ...
66 static @Nullable Command handleCommand(ChannelUID channelUID, String channelId, Command command,
67 VeluxBridgeHandler thisBridgeHandler) {
68 LOGGER.debug("handleCommand({},{},{},{}) called.", channelUID, channelId, command, thisBridgeHandler);
69 if (command == OnOffType.ON) {
70 LOGGER.trace("handleCommand(): about to activate veluxBridge detection mode.");
71 new VeluxBridgeDetectProducts().detectProducts(thisBridgeHandler.thisBridge);
73 LOGGER.trace("handleCommand(): ignoring OFF command.");