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.daikin.internal.api;
16 import java.util.Optional;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Holds information from the get_sensor_info call.
25 * @author Tim Waterhouse - Initial contribution
29 public class SensorInfo {
30 private static final Logger LOGGER = LoggerFactory.getLogger(SensorInfo.class);
32 public Optional<Double> indoortemp = Optional.empty();
33 public Optional<Double> indoorhumidity = Optional.empty();
34 public Optional<Double> outdoortemp = Optional.empty();
35 public Optional<Double> compressorfrequency = Optional.empty();
37 private SensorInfo() {
40 public static SensorInfo parse(String response) {
41 LOGGER.trace("Parsing string: \"{}\"", response);
43 Map<String, String> responseMap = InfoParser.parse(response);
45 SensorInfo info = new SensorInfo();
46 info.indoortemp = Optional.ofNullable(responseMap.get("htemp")).flatMap(value -> InfoParser.parseDouble(value));
47 info.indoorhumidity = Optional.ofNullable(responseMap.get("hhum"))
48 .flatMap(value -> InfoParser.parseDouble(value));
49 info.outdoortemp = Optional.ofNullable(responseMap.get("otemp"))
50 .flatMap(value -> InfoParser.parseDouble(value));
51 info.compressorfrequency = Optional.ofNullable(responseMap.get("cmpfreq"))
52 .flatMap(value -> InfoParser.parseDouble(value));