]> git.basschouten.com Git - openhab-addons.git/blob
08a8bd2b93e15a39923865d2f813d461fcf72a56
[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.io.imperihome.internal;
14
15 import java.util.Map;
16
17 import org.openhab.core.id.InstanceUUID;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Configuration parser and container.
23  *
24  * @author Pepijn de Geus - Initial contribution
25  */
26 public class ImperiHomeConfig {
27
28     private final Logger logger = LoggerFactory.getLogger(ImperiHomeConfig.class);
29
30     private String systemId;
31     private String rootUrl;
32
33     public void update(Map<String, Object> config) {
34         Object cSystemId = config.get("system.id");
35         if (cSystemId == null || cSystemId.toString().isEmpty()) {
36             systemId = InstanceUUID.get();
37         } else {
38             systemId = cSystemId.toString();
39         }
40
41         Object rootUrlObj = config.get("openhab.rootUrl");
42         if (rootUrlObj != null) {
43             rootUrl = String.valueOf(rootUrlObj);
44             if (!rootUrl.endsWith("/")) {
45                 rootUrl += "/";
46             }
47         }
48
49         logger.info("Configuration updated");
50     }
51
52     public String getSystemId() {
53         return systemId;
54     }
55
56     public String getRootUrl() {
57         return rootUrl;
58     }
59 }