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.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.enocean.internal.config.EnOceanChannelContactConfig;
22 import org.openhab.binding.enocean.internal.messages.ERP1Message;
23 import org.openhab.core.config.core.Configuration;
24 import org.openhab.core.library.types.OnOffType;
25 import org.openhab.core.library.types.OpenClosedType;
26 import org.openhab.core.library.types.PercentType;
27 import org.openhab.core.types.Command;
28 import org.openhab.core.types.State;
29 import org.openhab.core.types.UnDefType;
33 * @author Daniel Weber - Initial contribution
36 public class PTM200Message extends _RPSMessage {
38 static final byte SWITCH_ON = 0x70;
39 static final byte SWITCH_OFF = 0x50;
40 static final byte UP = 0x70;
41 static final byte DOWN = 0x50;
42 static final byte OPEN = (byte) 0xE0;
43 static final byte CLOSED = (byte) 0xF0;
45 public PTM200Message() {
49 public PTM200Message(ERP1Message packet) {
54 protected void convertFromCommandImpl(String channelId, String channelTypeId, Command command,
55 Function<String, State> getCurrentStateFunc, @Nullable Configuration config) {
59 protected State convertToStateImpl(String channelId, String channelTypeId,
60 Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
62 case CHANNEL_GENERAL_SWITCHING:
63 return bytes[0] == SWITCH_ON ? OnOffType.ON : OnOffType.OFF;
64 case CHANNEL_ROLLERSHUTTER:
65 return bytes[0] == UP ? PercentType.ZERO : (bytes[0] == DOWN ? PercentType.HUNDRED : UnDefType.UNDEF);
67 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
69 return bytes[0] == OPEN ? OpenClosedType.CLOSED
70 : (bytes[0] == CLOSED ? OpenClosedType.OPEN : UnDefType.UNDEF);
72 return bytes[0] == OPEN ? OpenClosedType.OPEN
73 : (bytes[0] == CLOSED ? OpenClosedType.CLOSED : UnDefType.UNDEF);
77 return UnDefType.UNDEF;
81 public boolean isValidForTeachIn() {