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