]> git.basschouten.com Git - openhab-addons.git/blob
d7c839e2a452cc9215298c9e7034599834ff0887
[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.daikin.internal.api;
14
15 import java.util.HashMap;
16 import java.util.Map;
17 import java.util.Optional;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Holds information from the basic_info call.
25  *
26  * @author Jimmy Tanagra - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class BasicInfo {
31     private static final Logger LOGGER = LoggerFactory.getLogger(BasicInfo.class);
32
33     public String mac = "";
34     public String ret = "";
35     public String ssid = "";
36
37     private BasicInfo() {
38     }
39
40     public static BasicInfo parse(String response) {
41         LOGGER.trace("Parsing string: \"{}\"", response);
42
43         Map<String, String> responseMap = InfoParser.parse(response);
44
45         BasicInfo info = new BasicInfo();
46         info.mac = Optional.ofNullable(responseMap.get("mac")).orElse("");
47         info.ret = Optional.ofNullable(responseMap.get("ret")).orElse("");
48         info.ssid = Optional.ofNullable(responseMap.get("ssid")).orElse("");
49         return info;
50     }
51
52     public Map<String, String> getParamString() {
53         Map<String, String> params = new HashMap<>();
54         params.put("ssid", ssid);
55         return params;
56     }
57 }