]> git.basschouten.com Git - openhab-addons.git/blob
d0ced83efea8b381a5a38ec1296cecce538069fa
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.openwebnet.handler;
14
15 import java.util.Set;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.openwebnet.OpenWebNetBindingConstants;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.thing.Thing;
21 import org.openhab.core.thing.ThingTypeUID;
22 import org.openhab.core.types.Command;
23 import org.openwebnet4j.message.BaseOpenMessage;
24 import org.openwebnet4j.message.Where;
25 import org.openwebnet4j.message.WhereLightAutom;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 /**
30  * The {@link OpenWebNetGenericHandler} is responsible for handling Generic OpenWebNet
31  * devices. It does not too much, but it is needed to avoid handler errors and to tell the user
32  * that some device has been found by the gateway but it was not recognised.
33  * It extends the abstract {@link OpenWebNetThingHandler}.
34  *
35  * @author Massimo Valla - Initial contribution
36  */
37 @NonNullByDefault
38 public class OpenWebNetGenericHandler extends OpenWebNetThingHandler {
39
40     private final Logger logger = LoggerFactory.getLogger(OpenWebNetGenericHandler.class);
41
42     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = OpenWebNetBindingConstants.GENERIC_SUPPORTED_THING_TYPES;
43
44     public OpenWebNetGenericHandler(Thing thing) {
45         super(thing);
46     }
47
48     @Override
49     public void initialize() {
50         super.initialize();
51     }
52
53     @Override
54     protected void requestChannelState(ChannelUID channel) {
55         // do nothing
56         logger.warn("There are no channels");
57     }
58
59     @Override
60     protected void handleChannelCommand(ChannelUID channel, Command command) {
61         // do nothing
62         logger.warn("There are no channels");
63     }
64
65     @Override
66     protected String ownIdPrefix() {
67         return "G";
68     }
69
70     @Override
71     protected Where buildBusWhere(String wStr) throws IllegalArgumentException {
72         return new WhereLightAutom(wStr);
73     }
74
75     @Override
76     protected void handleMessage(BaseOpenMessage msg) {
77         super.handleMessage(msg);
78         // do nothing
79         logger.warn("handleMessage(): Nothing to do!");
80     }
81 }