]> git.basschouten.com Git - openhab-addons.git/blob
0298cd1a77ce8513b6fbb2c447ae651fb2a3561f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.neohub.internal;
14
15 import static org.openhab.binding.neohub.internal.NeoHubBindingConstants.*;
16
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;
22
23 /**
24  * The {@link NeoContactHandler} is the OpenHAB Handler for NeoContact devices
25  * 
26  * Note: inherits almost all the functionality of a {@link NeoBaseHandler}
27  * 
28  * @author Andrew Fiddian-Green - Initial contribution
29  * 
30  */
31 @NonNullByDefault
32 public class NeoContactHandler extends NeoBaseHandler {
33
34     public NeoContactHandler(Thing thing) {
35         super(thing);
36     }
37
38     // =========== methods of NeoBaseHandler that are overridden ================
39
40     @Override
41     protected void toOpenHabSendChannelValues(AbstractRecord deviceRecord) {
42         boolean offline = deviceRecord.offline();
43
44         toOpenHabSendValueDebounced(CHAN_CONTACT_STATE,
45                 deviceRecord.isWindowOpen() ? OpenClosedType.OPEN : OpenClosedType.CLOSED, offline);
46
47         toOpenHabSendValueDebounced(CHAN_BATTERY_LOW_ALARM, OnOffType.from(deviceRecord.isBatteryLow()), offline);
48     }
49 }