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.enocean.internal.eep.D2_01;
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
17 import java.util.function.Function;
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.OnOffType;
26 import org.openhab.core.library.types.StringType;
27 import org.openhab.core.types.Command;
28 import org.openhab.core.types.RefreshType;
29 import org.openhab.core.types.State;
33 * @author Daniel Weber - Initial contribution
36 public class D2_01_09_Permundo extends D2_01 {
38 public D2_01_09_Permundo() {
42 public D2_01_09_Permundo(ERP1Message packet) {
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 setRepeaterMode(command);
51 } else if (channelId.equals(CHANNEL_ECOMODE)) {
54 super.convertFromCommandImpl(channelId, channelTypeId, command, getCurrentStateFunc, config);
58 private void setRepeaterMode(Command command) {
59 if (command == RefreshType.REFRESH) {
60 senderId = new byte[0]; // make this message invalid as we do not support refresh of repeater status
61 } else if (command instanceof StringType stringCommand) {
62 switch (stringCommand.toString()) {
63 case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
64 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x01);
66 case EnOceanBindingConstants.REPEATERMODE_LEVEL_2:
67 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x02);
70 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x00);
75 private void setEcoMode(Command command) {
76 if (command == RefreshType.REFRESH) {
77 senderId = new byte[0]; // make this message invalid as we do not support refresh of ecomode status
78 } else if (command instanceof OnOffType onOffCommand) {
79 if (onOffCommand == OnOffType.ON) {
80 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x01);
82 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x00);