]> git.basschouten.com Git - openhab-addons.git/blob
5279c4db1b1b43a5a4d656e64583b381a84ecc0b
[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.enocean.internal.eep.A5_3F;
14
15 import java.util.function.Function;
16
17 import org.openhab.binding.enocean.internal.config.EnOceanChannelTransformationConfig;
18 import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
19 import org.openhab.binding.enocean.internal.messages.ERP1Message;
20 import org.openhab.core.config.core.Configuration;
21 import org.openhab.core.transform.actions.Transformation;
22 import org.openhab.core.types.Command;
23 import org.openhab.core.types.State;
24 import org.openhab.core.util.HexUtils;
25
26 /**
27  *
28  * @author Daniel Weber - Initial contribution
29  */
30 public class A5_3F_7F_Universal extends _4BSMessage {
31
32     // This class is currently not used => instead use Generic4BS
33
34     public A5_3F_7F_Universal() {
35         super();
36     }
37
38     public A5_3F_7F_Universal(ERP1Message packet) {
39         super(packet);
40     }
41
42     @Override
43     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
44             Function<String, State> getCurrentStateFunc, Configuration config) {
45         if (config != null) {
46             try {
47                 EnOceanChannelTransformationConfig transformationInfo = config
48                         .as(EnOceanChannelTransformationConfig.class);
49                 String c = Transformation.transform(transformationInfo.transformationType,
50                         transformationInfo.transformationFunction, command.toString());
51
52                 if (c != null && !c.equals(command.toString())) {
53                     setData(HexUtils.hexToBytes(c));
54                 }
55
56             } catch (Exception e) {
57                 logger.debug("Command {} could not transformed", command.toString());
58             }
59         }
60     }
61 }