]> git.basschouten.com Git - openhab-addons.git/blob
486e8683f15411b9c79411232e40a1984fd315e8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.airbase;
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.openhab.binding.daikin.internal.api.InfoParser;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * Holds information from the basic_info call.
26  *
27  * @author Paul Smedley - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class AirbaseBasicInfo {
32     private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseBasicInfo.class);
33
34     public String mac = "";
35     public String ret = "";
36     public String ssid = "";
37
38     private AirbaseBasicInfo() {
39     }
40
41     public static AirbaseBasicInfo parse(String response) {
42         LOGGER.trace("Parsing string: \"{}\"", response);
43
44         Map<String, String> responseMap = InfoParser.parse(response);
45
46         AirbaseBasicInfo info = new AirbaseBasicInfo();
47         info.mac = Optional.ofNullable(responseMap.get("mac")).orElse("");
48         info.ret = Optional.ofNullable(responseMap.get("ret")).orElse("");
49         info.ssid = Optional.ofNullable(responseMap.get("ssid")).orElse("");
50         return info;
51     }
52
53     public Map<String, String> getParamString() {
54         Map<String, String> params = new HashMap<>();
55         if (!"".equals(ssid)) {
56             params.put("ssid", ssid);
57         }
58         return params;
59     }
60 }