]> git.basschouten.com Git - openhab-addons.git/blob
e93ada2a2c34c34a8912f2110a90d9daeb58bb4b
[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.core.library.types.OnOffType;
19 import org.openhab.core.library.types.QuantityType;
20 import org.openhab.core.thing.Thing;
21
22 /**
23  * The {@link NeoTemperatureSensorHandler} is the OpenHAB Handler for NeoTemperatureSensor devices
24  * 
25  * Note: inherits almost all the functionality of a {@link NeoBaseHandler}
26  * 
27  * @author Andrew Fiddian-Green - Initial contribution
28  * 
29  */
30 @NonNullByDefault
31 public class NeoTemperatureSensorHandler extends NeoBaseHandler {
32
33     public NeoTemperatureSensorHandler(Thing thing) {
34         super(thing);
35     }
36
37     // =========== methods of NeoBaseHandler that are overridden ================
38
39     @Override
40     protected void toOpenHabSendChannelValues(NeoHubAbstractDeviceData.AbstractRecord deviceRecord) {
41         boolean offline = deviceRecord.offline();
42
43         toOpenHabSendValueDebounced(CHAN_TEMPERATURE_SENSOR,
44                 new QuantityType<>(deviceRecord.getActualTemperature(), getTemperatureUnit()), offline);
45
46         toOpenHabSendValueDebounced(CHAN_BATTERY_LOW_ALARM, OnOffType.from(deviceRecord.isBatteryLow()), offline);
47     }
48 }