2 * Copyright (c) 2010-2022 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.A5_14;
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_CONTACT;
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.OpenClosedType;
23 import org.openhab.core.types.State;
26 * Single Input Contact (Window/Door), Supply voltage monitor
28 * @author Dominik Krickl-Vorreiter - Initial contribution
30 public class A5_14_01 extends A5_14 {
32 public A5_14_01(ERP1Message packet) {
36 private State getContact(boolean inverted) {
37 boolean ct = getBit(getDB_0(), 0);
40 return ct ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
42 return ct ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
47 protected State convertToStateImpl(String channelId, String channelTypeId,
48 Function<String, State> getCurrentStateFunc, Configuration config) {
51 EnOceanChannelContactConfig c = config.as(EnOceanChannelContactConfig.class);
52 return getContact(c.inverted);
55 return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);