]> git.basschouten.com Git - openhab-addons.git/blob
b205ca35165cd5b486bb5d13fd31564d71e617c6
[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.jeelink.internal.lacrosse;
14
15 import org.openhab.binding.jeelink.internal.Reading;
16
17 /**
18  * Reading of sensors directly connected to a LGW.
19  *
20  * @author Volker Bier - Initial contribution
21  */
22 public class LgwReading implements Reading {
23     private String sensorId;
24     private Float temp;
25     private Integer humidity;
26     private Integer pressure;
27
28     public LgwReading(int sensorId, Float temp, Integer humidity, Integer pressure) {
29         this.sensorId = String.valueOf(sensorId);
30         this.temp = temp;
31         this.humidity = humidity;
32         this.pressure = pressure;
33     }
34
35     @Override
36     public String getSensorId() {
37         return sensorId;
38     }
39
40     public Float getTemperature() {
41         return temp;
42     }
43
44     public Integer getHumidity() {
45         return humidity;
46     }
47
48     public Integer getPressure() {
49         return pressure;
50     }
51
52     public boolean hasPressure() {
53         return pressure != null;
54     }
55
56     public boolean hasHumidity() {
57         return humidity != null;
58     }
59
60     public boolean hasTemperature() {
61         return temp != null;
62     }
63
64     @Override
65     public String toString() {
66         return "sensorId=" + sensorId + ": temp=" + temp + (hasHumidity() ? ", hum=" + humidity : "")
67                 + (hasPressure() ? ", pressure=" + pressure : "");
68     }
69 }