]> git.basschouten.com Git - openhab-addons.git/blob
533e71c8c0ecbe7bbff7011653fba70540abc9fb
[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.smartthings.internal.converter;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.smartthings.internal.dto.SmartthingsStateData;
18 import org.openhab.core.thing.ChannelUID;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.types.Command;
21 import org.openhab.core.types.State;
22
23 /**
24  * This "Converter" is assigned to a channel when a special converter is not needed.
25  * A channel specific converter is specified in the thing-type channel property smartthings-converter then that channel
26  * is used.
27  * If a channel specific converter is not found a convert based on the channel ID is used.
28  * If there is no convert found then this Default converter is used.
29  * Yes, it would be possible to change the SamrtthingsConverter class to not being abstract and implement these methods
30  * there. But, this makes it explicit that the default converter is being used.
31  * See SmartthingsThingHandler.initialize() for details
32  *
33  * @author Bob Raker - Initial contribution
34  */
35 @NonNullByDefault
36 public class SmartthingsDefaultConverter extends SmartthingsConverter {
37
38     public SmartthingsDefaultConverter(Thing thing) {
39         super(thing);
40     }
41
42     @Override
43     public String convertToSmartthings(ChannelUID channelUid, Command command) {
44         return defaultConvertToSmartthings(channelUid, command);
45     }
46
47     @Override
48     public State convertToOpenHab(@Nullable String acceptedChannelType, SmartthingsStateData dataFromSmartthings) {
49         return defaultConvertToOpenHab(acceptedChannelType, dataFromSmartthings);
50     }
51 }