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.neohub.internal;
15 import static org.openhab.binding.neohub.internal.NeoHubBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.neohub.internal.NeoHubAbstractDeviceData.AbstractRecord;
19 import org.openhab.core.library.types.OnOffType;
20 import org.openhab.core.library.types.OpenClosedType;
21 import org.openhab.core.thing.Thing;
24 * The {@link NeoContactHandler} is the OpenHAB Handler for NeoContact devices
26 * Note: inherits almost all the functionality of a {@link NeoBaseHandler}
28 * @author Andrew Fiddian-Green - Initial contribution
32 public class NeoContactHandler extends NeoBaseHandler {
34 public NeoContactHandler(Thing thing) {
38 // =========== methods of NeoBaseHandler that are overridden ================
41 protected void toOpenHabSendChannelValues(AbstractRecord deviceRecord) {
42 boolean offline = deviceRecord.offline();
44 toOpenHabSendValueDebounced(CHAN_CONTACT_STATE,
45 deviceRecord.isWindowOpen() ? OpenClosedType.OPEN : OpenClosedType.CLOSED, offline);
47 toOpenHabSendValueDebounced(CHAN_BATTERY_LOW_ALARM, OnOffType.from(deviceRecord.isBatteryLow()), offline);