]> git.basschouten.com Git - openhab-addons.git/blob
f0fba0e4a1e145f34b09091629a36eee332282a7
[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.boschshc.internal.services.communicationquality.dto;
14
15 import org.openhab.core.library.types.DecimalType;
16
17 /**
18  * Possible states for the communication quality between a device and the
19  * bridge.
20  * 
21  * @author David Pace - Initial contribution
22  *
23  */
24 public enum CommunicationQualityState {
25     BAD,
26     MEDIUM,
27     NORMAL,
28     GOOD,
29     UNKNOWN,
30     FETCHING;
31
32     /**
33      * Converts this Bosch-specific communication quality state into a numeric state
34      * for the system channel of type <code>signal-strength</code>.
35      * 
36      * @return
37      */
38     public DecimalType toSystemSignalStrength() {
39         switch (this) {
40             case BAD:
41                 return new DecimalType(1);
42             case MEDIUM:
43                 return new DecimalType(2);
44             case NORMAL:
45                 return new DecimalType(3);
46             case GOOD:
47                 return new DecimalType(4);
48             default:
49                 // includes UNKNOWN and FETCHING
50                 return new DecimalType(0);
51         }
52     }
53 }