2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.opengarage.internal.api;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import com.google.gson.JsonObject;
19 import com.google.gson.JsonParser;
22 * Class for holding the set of parameters used to read the controller variables.
24 * @author Paul Smedley - Initial Contribution
27 public class ControllerVariables {
28 private static Logger LOGGER = LoggerFactory.getLogger(ControllerVariables.class);
40 private ControllerVariables() {
43 public static ControllerVariables parse(String response) {
44 LOGGER.debug("Parsing string: \"{}\"", response);
45 /* parse json string */
46 JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
47 ControllerVariables info = new ControllerVariables();
48 info.dist = jsonObject.get("dist").getAsInt();
49 info.door = jsonObject.get("door").getAsInt();
50 info.vehicle = jsonObject.get("vehicle").getAsInt();
51 info.rcnt = jsonObject.get("rcnt").getAsInt();
52 info.fwv = jsonObject.get("fwv").getAsInt();
53 info.name = jsonObject.get("name").getAsString();
54 info.mac = jsonObject.get("mac").getAsString();
55 info.cid = jsonObject.get("cid").getAsString();
56 info.rssi = jsonObject.get("rssi").getAsInt();