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.D5_00;
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_CONTACT;
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.eep.Base._1BSMessage;
23 import org.openhab.binding.enocean.internal.messages.ERP1Message;
24 import org.openhab.core.config.core.Configuration;
25 import org.openhab.core.library.types.OpenClosedType;
26 import org.openhab.core.types.State;
27 import org.openhab.core.types.UnDefType;
31 * @author Daniel Weber - Initial contribution
34 public class D5_00_01 extends _1BSMessage {
36 protected static final byte OPEN = 0 | TEACHIN_BIT;
37 protected static final byte CLOSED = 1 | TEACHIN_BIT;
43 public D5_00_01(ERP1Message packet) {
48 protected State convertToStateImpl(String channelId, String channelTypeId,
49 Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
50 if (channelId.equals(CHANNEL_CONTACT)) {
51 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
53 return bytes[0] == CLOSED ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
55 return bytes[0] == CLOSED ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
59 return UnDefType.UNDEF;