]> git.basschouten.com Git - openhab-addons.git/blob
2628834589c9f5e90f665b353b919b3f7704b8ef
[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.rfxcom.internal.messages;
14
15 import org.openhab.binding.rfxcom.internal.config.RFXComDeviceConfiguration;
16 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
17 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
18 import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedValueException;
19 import org.openhab.binding.rfxcom.internal.handler.DeviceState;
20 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
21 import org.openhab.core.types.Command;
22 import org.openhab.core.types.State;
23
24 /**
25  * An interface for message about devices, so interface message do not (have to) implement this
26  *
27  * @author Martin van Wingerden - Initial contribution
28  */
29 public interface RFXComDeviceMessage<T> extends RFXComMessage {
30     /**
31      * Procedure for converting RFXCOM value to openHAB command.
32      *
33      * @param channelId id of the channel
34      * @param deviceState
35      * @return openHAB command.
36      * @throws RFXComUnsupportedChannelException if the channel is not supported
37      */
38     Command convertToCommand(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException;
39
40     /**
41      * Procedure for converting RFXCOM value to openHAB state.
42      *
43      * @param channelId id of the channel
44      * @param deviceState
45      * @return openHAB state.
46      * @throws RFXComUnsupportedChannelException if the channel is not supported
47      */
48     State convertToState(String channelId, DeviceState deviceState) throws RFXComUnsupportedChannelException;
49
50     /**
51      * Procedure to get device id.
52      *
53      * @return device Id.
54      */
55     String getDeviceId();
56
57     /**
58      * Get the packet type for this device message
59      *
60      * @return the message its packet type
61      */
62     RFXComBaseMessage.PacketType getPacketType();
63
64     /**
65      * Given a DiscoveryResultBuilder add any new properties to the builder for the given message
66      *
67      * @param discoveryResultBuilder existing builder containing some early details
68      * @throws RFXComException
69      */
70     void addDevicePropertiesTo(DiscoveryResultBuilder discoveryResultBuilder) throws RFXComException;
71
72     /**
73      * Procedure for converting sub type as string to sub type object.
74      *
75      * @param subType
76      * @return sub type object.
77      * @throws RFXComUnsupportedValueException if the given subType cannot be converted
78      */
79     T convertSubType(String subType) throws RFXComUnsupportedValueException;
80
81     /**
82      * Procedure to set sub type.
83      *
84      * @param subType
85      */
86     void setSubType(T subType);
87
88     /**
89      * Procedure to set device id.
90      *
91      * @param deviceId
92      * @throws RFXComException
93      */
94     void setDeviceId(String deviceId) throws RFXComException;
95
96     /**
97      * Set the config to be applied to this message
98      *
99      * @param config
100      * @throws RFXComException
101      */
102     @Override
103     void setConfig(RFXComDeviceConfiguration config) throws RFXComException;
104 }