]> git.basschouten.com Git - openhab-addons.git/blob
4530d628f19bdd3c80c007cc1ce6620cccd34ee7
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.loxone.internal.types;
14
15 import org.openhab.binding.loxone.internal.controls.LxControl;
16
17 /**
18  * Category of Loxone Miniserver's {@link LxControl} object.
19  *
20  * @author Pawel Pieczul - initial contribution
21  *
22  */
23 public class LxCategory extends LxContainer {
24
25     /**
26      * Various categories that Loxone Miniserver's control can belong to.
27      *
28      * @author Pawel Pieczul - initial contribution
29      */
30     public enum CategoryType {
31         /**
32          * Category for lights
33          */
34         LIGHTS,
35         /**
36          * Category for shading / rollershutter / blinds
37          */
38         SHADING,
39         /**
40          * Category for temperatures
41          */
42         TEMPERATURE,
43         /**
44          * Unknown category
45          */
46         UNDEFINED
47     }
48
49     private String type; // deserialized from JSON
50     private CategoryType catType;
51
52     /**
53      * Obtain the type of this category
54      *
55      * @return type of category
56      */
57     public CategoryType getType() {
58         if (catType == null && type != null) {
59             String tl = type.toLowerCase();
60             if ("lights".equals(tl)) {
61                 catType = CategoryType.LIGHTS;
62             } else if ("shading".equals(tl)) {
63                 catType = CategoryType.SHADING;
64             } else if ("indoortemperature".equals(tl)) {
65                 catType = CategoryType.TEMPERATURE;
66             } else {
67                 catType = CategoryType.UNDEFINED;
68             }
69         }
70         return catType;
71     }
72 }