forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[daikin] Add Energy, compressor frequency and special mode channels (o…
…penhab#7708) * [daikin] Add Energy, compressor frequency and special mode channels openhab#6980: Add compressor frequency channel openhab#6115: Add energy current year channels * Update small typos and code refactoring as suggested by cpmeister * Update small typos and added units where possible Signed-off-by: Lukas Agethen <[email protected]>
- Loading branch information
Showing
16 changed files
with
568 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
....binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/EnergyInfoYear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.daikin.internal.api; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Holds information from the get_year_power_ex call. | ||
* | ||
* @author Lukas Agethen - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class EnergyInfoYear { | ||
private static final Logger logger = LoggerFactory.getLogger(EnergyInfoYear.class); | ||
|
||
public Optional<Integer[]> energyHeatingThisYear = Optional.empty(); | ||
|
||
public Optional<Integer[]> energyCoolingThisYear = Optional.empty(); | ||
|
||
private EnergyInfoYear() { | ||
} | ||
|
||
public static EnergyInfoYear parse(String response) { | ||
logger.debug("Parsing string: \"{}\"", response); | ||
|
||
Map<String, String> responseMap = InfoParser.parse(response); | ||
|
||
EnergyInfoYear info = new EnergyInfoYear(); | ||
info.energyHeatingThisYear = Optional.ofNullable(responseMap.get("curr_year_heat")) | ||
.flatMap(value -> InfoParser.parseArrayofInt(value, 12)); | ||
|
||
info.energyCoolingThisYear = Optional.ofNullable(responseMap.get("curr_year_cool")) | ||
.flatMap(value -> InfoParser.parseArrayofInt(value, 12)); | ||
|
||
return info; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,14 @@ | |
package org.openhab.binding.daikin.internal.api; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Container class for enums related to Daikin A/C systems | ||
* | ||
* @author Tim Waterhouse <[email protected]> - Initial contribution | ||
* @author Lukas Agethen - Add special modes | ||
* | ||
*/ | ||
@NonNullByDefault | ||
|
@@ -138,4 +138,75 @@ public String getValue() { | |
return value; | ||
} | ||
} | ||
|
||
public enum SpecialMode { | ||
STREAMER("13"), | ||
ECO("12"), | ||
POWERFUL("2"), | ||
POWERFUL_STREAMER("2/13"), | ||
ECO_STREAMER("12/13"), | ||
OFF(""), | ||
UNKNOWN("??"); | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(SpecialMode.class); | ||
private final String value; | ||
|
||
SpecialMode(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public boolean isPowerfulActive() { | ||
return this.equals(POWERFUL) || this.equals(POWERFUL_STREAMER); | ||
} | ||
|
||
public boolean isUndefined() { | ||
return this.equals(UNKNOWN); | ||
} | ||
|
||
public static SpecialMode fromValue(String value) { | ||
for (SpecialMode m : SpecialMode.values()) { | ||
if (m.getValue().equals(value)) { | ||
return m; | ||
} | ||
} | ||
LOGGER.debug("Unexpected SpecialMode value of \"{}\"", value); | ||
|
||
// Default to UNKNOWN | ||
return UNKNOWN; | ||
} | ||
} | ||
|
||
public enum SpecialModeKind { | ||
UNKNOWN(-1), | ||
STREAMER(0), | ||
POWERFUL(1), | ||
ECO(2); | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(SpecialModeKind.class); | ||
private final int value; | ||
|
||
SpecialModeKind(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
public static SpecialModeKind fromValue(int value) { | ||
for (SpecialModeKind m : SpecialModeKind.values()) { | ||
if (m.getValue() == value) { | ||
return m; | ||
} | ||
} | ||
LOGGER.debug("Unexpected SpecialModeKind value of \"{}\"", value); | ||
|
||
// Default to UNKNOWN | ||
return UNKNOWN; | ||
} | ||
} | ||
} |
Oops, something went wrong.