]> git.basschouten.com Git - openhab-addons.git/blob
a74dcba4eebf51c83d109e8b1a4b505d6c3d4b0f
[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.D2_05;
14
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_REPEATERMODE;
16
17 import java.util.function.Function;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.enocean.internal.EnOceanBindingConstants;
22 import org.openhab.binding.enocean.internal.messages.ERP1Message;
23 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
24 import org.openhab.core.config.core.Configuration;
25 import org.openhab.core.library.types.StringType;
26 import org.openhab.core.types.Command;
27 import org.openhab.core.types.RefreshType;
28 import org.openhab.core.types.State;
29
30 /**
31  * @author MArcel Eckert - Initial contribution
32  * @author Marcel Eckert - based on D2_01_0F_NodON.java and D2_01_12_NodOn.java
33  * 
34  */
35 @NonNullByDefault
36 public class D2_05_00_NodON extends D2_05_00 {
37
38     public D2_05_00_NodON() {
39         super();
40     }
41
42     public D2_05_00_NodON(ERP1Message packet) {
43         super(packet);
44     }
45
46     @Override
47     protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
48             Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
49         if (channelId.equals(CHANNEL_REPEATERMODE)) {
50             if (command == RefreshType.REFRESH) {
51                 senderId = new byte[0]; // make this message invalid as we do not support refresh of repeter status
52             } else if (command instanceof StringType) {
53                 switch (((StringType) command).toString()) {
54                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
55                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x01, (byte) 0x01);
56                         break;
57                     case EnOceanBindingConstants.REPEATERMODE_LEVEL_2:
58                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x01, (byte) 0x02);
59                         break;
60                     default:
61                         setRORG(RORG.MSC).setData((byte) 0x00, (byte) 0x46, (byte) 0x08, (byte) 0x00, (byte) 0x00);
62                 }
63             }
64         } else {
65             super.convertFromCommandImpl(channelId, channelTypeId, command, getCurrentStateFunc, config);
66         }
67     }
68 }