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_year_power_ex call.
25 * @author Lukas Agethen - Initial contribution
29 public class EnergyInfoYear {
30 private static final Logger LOGGER = LoggerFactory.getLogger(EnergyInfoYear.class);
32 public Optional<Integer[]> energyHeatingThisYear = Optional.empty();
34 public Optional<Integer[]> energyCoolingThisYear = Optional.empty();
36 private EnergyInfoYear() {
39 public static EnergyInfoYear parse(String response) {
40 LOGGER.trace("Parsing string: \"{}\"", response);
42 Map<String, String> responseMap = InfoParser.parse(response);
44 EnergyInfoYear info = new EnergyInfoYear();
45 info.energyHeatingThisYear = Optional.ofNullable(responseMap.get("curr_year_heat"))
46 .flatMap(value -> InfoParser.parseArrayOfInt(value, 12));
48 info.energyCoolingThisYear = Optional.ofNullable(responseMap.get("curr_year_cool"))
49 .flatMap(value -> InfoParser.parseArrayOfInt(value, 12));