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.Base;
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
17 import java.util.function.Function;
19 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
20 import org.openhab.binding.enocean.internal.messages.ERP1Message;
21 import org.openhab.core.config.core.Configuration;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.library.types.OpenClosedType;
24 import org.openhab.core.library.types.PercentType;
25 import org.openhab.core.types.Command;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
31 * @author Daniel Weber - Initial contribution
33 public class PTM200Message extends _RPSMessage {
35 static final byte On = 0x70;
36 static final byte Off = 0x50;
37 static final byte Up = 0x70;
38 static final byte Down = 0x50;
39 static final byte Open = (byte) 0xE0;
40 static final byte Closed = (byte) 0xF0;
42 public PTM200Message() {
46 public PTM200Message(ERP1Message packet) {
51 protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
52 Function<String, State> getCurrentStateFunc, Configuration config) {
56 protected State convertToStateImpl(String channelId, String channelTypeId,
57 Function<String, State> getCurrentStateFunc, Configuration config) {
60 case CHANNEL_GENERAL_SWITCHING:
61 return bytes[0] == On ? OnOffType.ON : OnOffType.OFF;
62 case CHANNEL_ROLLERSHUTTER:
63 return bytes[0] == Up ? PercentType.ZERO : (bytes[0] == Down ? PercentType.HUNDRED : UnDefType.UNDEF);
65 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
67 return bytes[0] == Open ? OpenClosedType.CLOSED
68 : (bytes[0] == Closed ? OpenClosedType.OPEN : UnDefType.UNDEF);
70 return bytes[0] == Open ? OpenClosedType.OPEN
71 : (bytes[0] == Closed ? OpenClosedType.CLOSED : UnDefType.UNDEF);
75 return UnDefType.UNDEF;
79 public boolean isValidForTeachIn() {