]> git.basschouten.com Git - openhab-addons.git/blob
78e739a620d0850506b7083643ecb8490415f908
[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.mystrom.internal;
14
15 import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link MyStromConfiguration} class contains fields mapping thing configuration parameters.
21  *
22  * @author Paul Frank - Initial contribution
23  * @author Stefan Navratil - Added configuration for myStrom PIR
24  */
25 @NonNullByDefault
26 public class MyStromConfiguration {
27
28     private final String urlPrefix = "http://";
29
30     private String hostname = "localhost";
31
32     private String apiToken = "";
33
34     private int refresh = DEFAULT_REFRESH_RATE_SECONDS;
35
36     private int backoffTime = DEFAULT_BACKOFF_TIME_SECONDS;
37
38     private boolean ledEnable = true;
39
40     /**
41      * Returns the hostname with http prefix if missing.
42      *
43      * @return hostname
44      */
45     public String getHostname() {
46         String prefix = "";
47         if (!this.hostname.contains(urlPrefix)) {
48             prefix = urlPrefix;
49         }
50         return prefix + this.hostname;
51     }
52
53     /**
54      * returns API Token
55      *
56      * @return apiToken
57      */
58     public String getApiToken() {
59         return apiToken;
60     }
61
62     /**
63      * Returns the refreshrate in SECONDS.
64      *
65      * @return refresh
66      */
67     public int getRefresh() {
68         return refresh;
69     }
70
71     /**
72      * Returns the Backoff time of the MotionSensor in SECONDS.
73      *
74      * @return backoff_time
75      */
76     public int getBackoffTime() {
77         return backoffTime;
78     }
79
80     /**
81      * Returns the Status LED Configuration.
82      *
83      * @return led_enable
84      */
85     public boolean getLedEnable() {
86         return ledEnable;
87     }
88 }