]> git.basschouten.com Git - openhab-addons.git/blob
4c0a66742e28bb1f50fb24a46b2c217bd2870469
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.internal.handler;
14
15 import java.util.Set;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.openwebnet.internal.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("Generic: there are no channels");
57     }
58
59     @Override
60     protected void refreshDevice(boolean refreshAll) {
61         // do nothing
62         logger.warn("Generic: nothing to refresh");
63     }
64
65     @Override
66     protected void handleChannelCommand(ChannelUID channel, Command command) {
67         // do nothing
68         logger.warn("Generic: there are no channels");
69     }
70
71     @Override
72     protected String ownIdPrefix() {
73         return "G";
74     }
75
76     @Override
77     protected Where buildBusWhere(String wStr) throws IllegalArgumentException {
78         return new WhereLightAutom(wStr);
79     }
80
81     @Override
82     protected void handleMessage(BaseOpenMessage msg) {
83         super.handleMessage(msg);
84         // do nothing
85         logger.warn("Generic: handleMessage() nothing to do!");
86     }
87 }