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.F6_10;
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.eep.Base._RPSMessage;
21 import org.openhab.binding.enocean.internal.messages.ERP1Message;
22 import org.openhab.core.config.core.Configuration;
23 import org.openhab.core.library.types.OpenClosedType;
24 import org.openhab.core.library.types.StringType;
25 import org.openhab.core.types.State;
26 import org.openhab.core.types.UnDefType;
30 * @author Daniel Weber - Initial contribution
32 public class F6_10_00 extends _RPSMessage {
34 public final byte Closed = (byte) 0xF0; // 1111xxxx
35 public final byte Open1 = (byte) 0xE0; // 1110xxxx
36 public final byte Open2 = (byte) 0xC0; // 1100xxxx
37 public final byte Tilted = (byte) 0xD0; // 1101xxxx
43 public F6_10_00(ERP1Message packet) {
48 protected State convertToStateImpl(String channelId, String channelTypeId,
49 Function<String, State> getCurrentStateFunc, Configuration config) {
51 byte data = (byte) (bytes[0] & 0xF0);
55 case CHANNEL_WINDOWHANDLESTATE:
57 return new StringType("CLOSED");
58 } else if (data == Tilted) {
59 return new StringType("TILTED");
60 } else if (data == Open1 || data == Open2) {
61 return new StringType("OPEN");
65 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
67 return c.inverted ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
68 } else if (data == Tilted) {
69 return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
70 } else if (data == Open1 || data == Open2) {
71 return c.inverted ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
75 return UnDefType.UNDEF;
79 protected boolean validateData(byte[] bytes) {
80 return super.validateData(bytes) && getBit(bytes[0], 7) && getBit(bytes[0], 6);
84 public boolean isValidForTeachIn() {
85 return t21 && !nu && getBit(bytes[0], 7) && getBit(bytes[0], 6);