]> git.basschouten.com Git - openhab-addons.git/blob
1beb0c7fd7126512fffbddaacb429b5b299fbb0c
[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.homematic.internal.model;
14
15 /**
16  * Object that holds the rssi infos for a RF device.
17  *
18  * @author Gerhard Riegler - Initial contribution
19  */
20
21 public class HmRssiInfo {
22     private String address;
23     private Integer device;
24     private Integer peer;
25
26     public HmRssiInfo(String address, Integer device, Integer peer) {
27         this.address = address;
28         this.device = convert(device);
29         this.peer = convert(peer);
30     }
31
32     /**
33      * Converts the rssi value to null if necessary.
34      */
35     private Integer convert(Integer intValue) {
36         if (intValue == null || intValue == 65536) {
37             return 0;
38         }
39         return intValue;
40     }
41
42     /**
43      * Returns the address of the device.
44      */
45     public String getAddress() {
46         return address;
47     }
48
49     /**
50      * Returns the device rssi.
51      */
52     public Integer getDevice() {
53         return device;
54     }
55
56     /**
57      * Returns the peer rssi.
58      */
59     public Integer getPeer() {
60         return peer;
61     }
62
63     @Override
64     public String toString() {
65         return String.format("%s[address=%s,device=%d,peer=%i]", getClass().getSimpleName(), address, device, peer);
66     }
67 }