]> git.basschouten.com Git - openhab-addons.git/blob
54a168438a2e0af4109de0f42cfb59791ded95f0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.velux.internal.handler;
14
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;
23
24 /**
25  * <B>Channel-specific retrieval and modification.</B>
26  * <P>
27  * This class implements the Channel <B>doDetection</B> of the Thing <B>klf200</B> :
28  * <UL>
29  * <LI><I>Velux</I> <B>bridge</B> &rarr; <B>OpenHAB</B>:
30  * <P>
31  * Information retrieval by method {@link #handleRefresh}.</LI>
32  * </UL>
33  * <UL>
34  * <LI><B>OpenHAB</B> Event Bus &rarr; <I>Velux</I> <B>bridge</B>
35  * <P>
36  * Sending commands and value updates by method {@link #handleCommand}.</LI>
37  * </UL>
38  *
39  * @author Guenther Schreiner - Initial contribution.
40  */
41 @NonNullByDefault
42 final class ChannelBridgeDoDetection extends ChannelHandlerTemplate {
43     private static final Logger LOGGER = LoggerFactory.getLogger(ChannelBridgeDoDetection.class);
44
45     /*
46      * ************************
47      * ***** Constructors *****
48      */
49
50     // Suppress default constructor for non-instantiability
51
52     private ChannelBridgeDoDetection() {
53         throw new AssertionError();
54     }
55
56     /**
57      * Communication method to update the real world according to the passed channel value (or command).
58      *
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 ...
65      */
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);
72         } else {
73             LOGGER.trace("handleCommand(): ignoring OFF command.");
74         }
75         return null;
76     }
77 }