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.openhab.binding.enocean.internal.EnOceanBindingConstants;
20 import org.openhab.binding.enocean.internal.messages.ERP1Message;
21 import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
22 import org.openhab.core.config.core.Configuration;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.library.types.StringType;
25 import org.openhab.core.types.Command;
26 import org.openhab.core.types.RefreshType;
27 import org.openhab.core.types.State;
31 * @author Daniel Weber - Initial contribution
33 public class D2_01_09_Permundo extends D2_01 {
35 public D2_01_09_Permundo() {
39 public D2_01_09_Permundo(ERP1Message packet) {
44 protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
45 Function<String, State> getCurrentStateFunc, Configuration config) {
46 if (channelId.equals(CHANNEL_REPEATERMODE)) {
47 setRepeaterMode(command);
48 } else if (channelId.equals(CHANNEL_ECOMODE)) {
51 super.convertFromCommandImpl(channelId, channelTypeId, command, getCurrentStateFunc, config);
55 private void setRepeaterMode(Command command) {
56 if (command == RefreshType.REFRESH) {
57 senderId = null; // make this message invalid as we do not support refresh of repeater status
58 } else if (command instanceof StringType) {
59 switch (((StringType) command).toString()) {
60 case EnOceanBindingConstants.REPEATERMODE_LEVEL_1:
61 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x01);
63 case EnOceanBindingConstants.REPEATERMODE_LEVEL_2:
64 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x02);
67 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x35, (byte) 0x00);
72 private void setEcoMode(Command command) {
73 if (command == RefreshType.REFRESH) {
74 senderId = null; // make this message invalid as we do not support refresh of ecomode status
75 } else if (command instanceof OnOffType) {
76 if (((OnOffType) command) == OnOffType.ON) {
77 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x01);
79 setRORG(RORG.MSC).setData((byte) 0x03, (byte) 0x36, (byte) 0x00);