2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.rfxcom.internal.messages;
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;
26 * An interface for message about devices, so interface message do not (have to) implement this
28 * @author Martin van Wingerden - Initial contribution
30 public interface RFXComDeviceMessage<T> extends RFXComMessage {
32 * Procedure for converting RFXCOM value to openHAB command.
34 * @param channelId id of the channel
35 * @param config Configuration of the thing being handled
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
41 Command convertToCommand(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
42 throws RFXComUnsupportedChannelException, RFXComInvalidStateException;
45 * Procedure for converting RFXCOM value to openHAB state.
47 * @param channelId id of the channel
48 * @param config configuration of the thing being handled
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
54 State convertToState(String channelId, RFXComDeviceConfiguration config, DeviceState deviceState)
55 throws RFXComUnsupportedChannelException, RFXComInvalidStateException;
58 * Procedure to get device id.
65 * Get the packet type for this device message
67 * @return the message its packet type
69 RFXComBaseMessage.PacketType getPacketType();
72 * Given a DiscoveryResultBuilder add any new properties to the builder for the given message
74 * @param discoveryResultBuilder existing builder containing some early details
75 * @throws RFXComException
77 void addDevicePropertiesTo(DiscoveryResultBuilder discoveryResultBuilder) throws RFXComException;
80 * Procedure for converting sub type as string to sub type object.
83 * @return sub type object.
84 * @throws RFXComUnsupportedValueException if the given subType cannot be converted
86 T convertSubType(String subType) throws RFXComUnsupportedValueException;
89 * Procedure to set sub type.
93 void setSubType(T subType);
96 * Procedure to set device id.
99 * @throws RFXComException
101 void setDeviceId(String deviceId) throws RFXComException;
104 * Set the config to be applied to this message
107 * @throws RFXComException
110 void setConfig(RFXComDeviceConfiguration config) throws RFXComException;