From adfd120c2826cf453251065732962316313ac1a1 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Sun, 20 Feb 2022 08:32:36 +1000 Subject: [PATCH] [daikin] Fix Special Mode support Signed-off-by: Jimmy Tanagra --- bundles/org.openhab.binding.daikin/README.md | 126 +++++++++--------- .../internal/DaikinBindingConstants.java | 2 +- .../daikin/internal/DaikinWebTargets.java | 19 ++- .../daikin/internal/api/ControlInfo.java | 11 +- .../binding/daikin/internal/api/Enums.java | 42 +++--- .../internal/handler/DaikinAcUnitHandler.java | 75 ++++------- .../internal/handler/DaikinBaseHandler.java | 4 + .../resources/OH-INF/i18n/daikin.properties | 8 +- .../resources/OH-INF/thing/thing-types.xml | 74 +++++++--- 9 files changed, 195 insertions(+), 166 deletions(-) diff --git a/bundles/org.openhab.binding.daikin/README.md b/bundles/org.openhab.binding.daikin/README.md index f2ded25e3664b..839f354fca9f4 100644 --- a/bundles/org.openhab.binding.daikin/README.md +++ b/bundles/org.openhab.binding.daikin/README.md @@ -33,79 +33,78 @@ A BRP072C42 adapter requires a registered UUID to authenticate. Upon discovery, ### Additional Thing configurations for BRP072C42 adapter * `secure` - Must be set to true for BRP072C42 to access it through https. -* `uuid` - A UUID used to access the BRP072C42 adapter. A handy UUID generator can be found at https://www.uuidgenerator.net/. +* `uuid` - A UUID used to access the BRP072C42 adapter. A handy UUID generator can be found at . * `key` - The 13-digit key from the Daikin adapter. - ## Channels The temperature channels have a precision of one half degree Celsius. For the BRP072A42 and BRP072C42: -| Channel Name | Description | -|--------------|---------------------------------------------------------------------------------------------| -| power | Turns the power on/off for the air conditioning unit. | -| settemp | The temperature set for the air conditioning unit. | -| indoortemp | The indoor temperature as measured by the unit. | -| outdoortemp | The outdoor temperature as measured by the external part of the air conditioning system. May not be available when unit is off. | -| humidity | The indoor humidity as measured by the unit. This is not available on all units. | -| mode | The mode set for the unit (AUTO, DEHUMIDIFIER, COLD, HEAT, FAN) | -| homekitmode | A mode that is compatible with homekit/alexa/google home (off, auto, heat, cool). Not tested for BRP069B41 | -| fanspeed | The fan speed set for the unit (AUTO, SILENCE, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5) | -| fandir | The fan blade direction (STOPPED, VERTICAL, HORIZONTAL, VERTICAL_AND_HORIZONTAL) | -| cmpfrequency | The compressor frequency | -| specialmode | The special mode currently active (OFF, STREAMER, ECO, POWERFUL, POWERFUL & STREAMER, ECO & STREAMER). Not all modes might be available on the unit. | -| specialmode-powerful | Turns the powerful mode on/off for the air conditioning unit. | -| energyheatingtoday | The energy consumption when heating for today | -| energyheatingthisweek | The energy consumption when heating for this week | -| energyheatinglastweek | The energy consumption when heating for last week | -| energyheatingcurrentyear-1 | The energy consumption when heating for current year January | -| energyheatingcurrentyear-2 | The energy consumption when heating for current year February | -| energyheatingcurrentyear-3 | The energy consumption when heating for current year March | -| energyheatingcurrentyear-4 | The energy consumption when heating for current year April | -| energyheatingcurrentyear-5 | The energy consumption when heating for current year May | -| energyheatingcurrentyear-6 | The energy consumption when heating for current year June | -| energyheatingcurrentyear-7 | The energy consumption when heating for current year July | -| energyheatingcurrentyear-8 | The energy consumption when heating for current year August | -| energyheatingcurrentyear-9 | The energy consumption when heating for current year September | -| energyheatingcurrentyear-10| The energy consumption when heating for current year October | -| energyheatingcurrentyear-11| The energy consumption when heating for current year November | -| energyheatingcurrentyear-12| The energy consumption when heating for current year December | -| energycoolingtoday | The energy consumption when cooling for today | -| energycoolingthisweek | The energy consumption when cooling for this week | -| energycoolinglastweek | The energy consumption when cooling for last week | -| energycoolingcurrentyear-1 | The energy consumption when cooling for current year January | -| energycoolingcurrentyear-2 | The energy consumption when cooling for current year February | -| energycoolingcurrentyear-3 | The energy consumption when cooling for current year March | -| energycoolingcurrentyear-4 | The energy consumption when cooling for current year April | -| energycoolingcurrentyear-5 | The energy consumption when cooling for current year May | -| energycoolingcurrentyear-6 | The energy consumption when cooling for current year June | -| energycoolingcurrentyear-7 | The energy consumption when cooling for current year July | -| energycoolingcurrentyear-8 | The energy consumption when cooling for current year August | -| energycoolingcurrentyear-9 | The energy consumption when cooling for current year September | -| energycoolingcurrentyear-10| The energy consumption when cooling for current year October | -| energycoolingcurrentyear-11| The energy consumption when cooling for current year November | -| energycoolingcurrentyear-12| The energy consumption when cooling for current year December | +| Channel Name | Description | +| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| power | Turns the power on/off for the air conditioning unit. | +| settemp | The temperature set for the air conditioning unit. | +| indoortemp | The indoor temperature as measured by the unit. | +| outdoortemp | The outdoor temperature as measured by the external part of the air conditioning system. May not be available when unit is off. | +| humidity | The indoor humidity as measured by the unit. This is not available on all units. | +| mode | The mode set for the unit (AUTO, DEHUMIDIFIER, COLD, HEAT, FAN) | +| homekitmode | A mode that is compatible with homekit/alexa/google home (off, auto, heat, cool). Not tested for BRP069B41 | +| fanspeed | The fan speed set for the unit (AUTO, SILENCE, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5) | +| fandir | The fan blade direction (STOPPED, VERTICAL, HORIZONTAL, VERTICAL_AND_HORIZONTAL) | +| cmpfrequency | The compressor frequency | +| specialmode | The special mode set for the unit (NORMAL, ECO, POWERFUL). This is not available on all units. | +| streamer | Turns the streamer feature on/off for the air conditioning unit. This is not available on all units. | +| energyheatingtoday | The energy consumption when heating for today | +| energyheatingthisweek | The energy consumption when heating for this week | +| energyheatinglastweek | The energy consumption when heating for last week | +| energyheatingcurrentyear-1 | The energy consumption when heating for current year January | +| energyheatingcurrentyear-2 | The energy consumption when heating for current year February | +| energyheatingcurrentyear-3 | The energy consumption when heating for current year March | +| energyheatingcurrentyear-4 | The energy consumption when heating for current year April | +| energyheatingcurrentyear-5 | The energy consumption when heating for current year May | +| energyheatingcurrentyear-6 | The energy consumption when heating for current year June | +| energyheatingcurrentyear-7 | The energy consumption when heating for current year July | +| energyheatingcurrentyear-8 | The energy consumption when heating for current year August | +| energyheatingcurrentyear-9 | The energy consumption when heating for current year September | +| energyheatingcurrentyear-10 | The energy consumption when heating for current year October | +| energyheatingcurrentyear-11 | The energy consumption when heating for current year November | +| energyheatingcurrentyear-12 | The energy consumption when heating for current year December | +| energycoolingtoday | The energy consumption when cooling for today | +| energycoolingthisweek | The energy consumption when cooling for this week | +| energycoolinglastweek | The energy consumption when cooling for last week | +| energycoolingcurrentyear-1 | The energy consumption when cooling for current year January | +| energycoolingcurrentyear-2 | The energy consumption when cooling for current year February | +| energycoolingcurrentyear-3 | The energy consumption when cooling for current year March | +| energycoolingcurrentyear-4 | The energy consumption when cooling for current year April | +| energycoolingcurrentyear-5 | The energy consumption when cooling for current year May | +| energycoolingcurrentyear-6 | The energy consumption when cooling for current year June | +| energycoolingcurrentyear-7 | The energy consumption when cooling for current year July | +| energycoolingcurrentyear-8 | The energy consumption when cooling for current year August | +| energycoolingcurrentyear-9 | The energy consumption when cooling for current year September | +| energycoolingcurrentyear-10 | The energy consumption when cooling for current year October | +| energycoolingcurrentyear-11 | The energy consumption when cooling for current year November | +| energycoolingcurrentyear-12 | The energy consumption when cooling for current year December | For the BRP15B61: -| Channel Name | Description | -|-----------------|---------------------------------------------------------------------------------------------| -| power | Turns the power on/off for the air conditioning unit. | -| settemp | The temperature set for the air conditioning unit. | -| indoortemp | The indoor temperature as measured by the unit. | -| outdoortemp | The outdoor temperature as measured by the external part of the air conditioning system. May not be available when unit is off. | -| mode | The mode set for the unit (AUTO, DEHUMIDIFIER, COLD, HEAT, FAN) | -| homekitmode | A mode that is compatible with homekit/alexa/google home (off, auto, heat, cool) | -| airbasefanspeed | The fan speed set for the unit (AUTO, AIRSIDE, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5, AUTO_LEVEL_1, AUTO_LEVEL_2, AUTO_LEVEL_3, AUTO_LEVEL_4, AUTO_LEVEL_5) | -| zone1 | Turns zone 1 on/off for the air conditioning unit (if a zone controller is installed.) | -| zone2 | Turns zone 2 on/off for the air conditioning unit. | -| zone3 | Turns zone 3 on/off for the air conditioning unit. | -| zone4 | Turns zone 4 on/off for the air conditioning unit. | -| zone5 | Turns zone 5 on/off for the air conditioning unit. | -| zone6 | Turns zone 6 on/off for the air conditioning unit. | -| zone7 | Turns zone 7 on/off for the air conditioning unit. | -| zone8 | Turns zone 8 on/off for the air conditioning unit. | +| Channel Name | Description | +| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| power | Turns the power on/off for the air conditioning unit. | +| settemp | The temperature set for the air conditioning unit. | +| indoortemp | The indoor temperature as measured by the unit. | +| outdoortemp | The outdoor temperature as measured by the external part of the air conditioning system. May not be available when unit is off. | +| mode | The mode set for the unit (AUTO, DEHUMIDIFIER, COLD, HEAT, FAN) | +| homekitmode | A mode that is compatible with homekit/alexa/google home (off, auto, heat, cool) | +| airbasefanspeed | The fan speed set for the unit (AUTO, AIRSIDE, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5, AUTO_LEVEL_1, AUTO_LEVEL_2, AUTO_LEVEL_3, AUTO_LEVEL_4, AUTO_LEVEL_5) | +| zone1 | Turns zone 1 on/off for the air conditioning unit (if a zone controller is installed.) | +| zone2 | Turns zone 2 on/off for the air conditioning unit. | +| zone3 | Turns zone 3 on/off for the air conditioning unit. | +| zone4 | Turns zone 4 on/off for the air conditioning unit. | +| zone5 | Turns zone 5 on/off for the air conditioning unit. | +| zone6 | Turns zone 6 on/off for the air conditioning unit. | +| zone7 | Turns zone 7 on/off for the air conditioning unit. | +| zone8 | Turns zone 8 on/off for the air conditioning unit. | ## Full Example @@ -120,7 +119,6 @@ daikin:ac_unit:living_room_ac [ host="192.168.0.5", secure=true, uuid="xxxxxxxx- daikin:airbase_ac_unit:living_room_ac [ host="192.168.0.5" ] ``` - daikin.items: ``` diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinBindingConstants.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinBindingConstants.java index 0beef31057e7b..dff80333f0934 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinBindingConstants.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinBindingConstants.java @@ -62,7 +62,7 @@ public class DaikinBindingConstants { public static final String CHANNEL_ENERGY_STRING_FORMAT = "%s-%d"; public static final String CHANNEL_AC_SPECIALMODE = "specialmode"; - public static final String CHANNEL_AC_SPECIALMODE_POWERFUL = "specialmode-powerful"; + public static final String CHANNEL_AC_STREAMER = "streamer"; // additional channels for Airbase Controller public static final String CHANNEL_AIRBASE_AC_FAN_SPEED = "airbasefanspeed"; diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinWebTargets.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinWebTargets.java index cc68a6b607287..878e1d783854b 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinWebTargets.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinWebTargets.java @@ -30,7 +30,7 @@ import org.openhab.binding.daikin.internal.api.ControlInfo; import org.openhab.binding.daikin.internal.api.EnergyInfoDayAndWeek; import org.openhab.binding.daikin.internal.api.EnergyInfoYear; -import org.openhab.binding.daikin.internal.api.Enums.SpecialModeKind; +import org.openhab.binding.daikin.internal.api.Enums.SpecialMode; import org.openhab.binding.daikin.internal.api.SensorInfo; import org.openhab.binding.daikin.internal.api.airbase.AirbaseBasicInfo; import org.openhab.binding.daikin.internal.api.airbase.AirbaseControlInfo; @@ -137,12 +137,21 @@ public EnergyInfoDayAndWeek getEnergyInfoDayAndWeek() throws DaikinCommunication return EnergyInfoDayAndWeek.parse(response); } - public boolean setSpecialMode(SpecialModeKind specialModeKind, boolean state) throws DaikinCommunicationException { + public void setSpecialMode(SpecialMode specialMode) throws DaikinCommunicationException { Map queryParams = new HashMap<>(); - queryParams.put("spmode_kind", String.valueOf(specialModeKind.getValue())); - queryParams.put("set_spmode", state ? "1" : "0"); + if (specialMode == SpecialMode.NORMAL) { + queryParams.put("set_spmode", "0"); + } else { + queryParams.put("set_spmode", "1"); + queryParams.put("spmode_kind", Integer.toString(specialMode.getValue())); + } + String response = invoke(setSpecialModeUri, queryParams); + } + + public void setStreamerMode(boolean state) throws DaikinCommunicationException { + Map queryParams = new HashMap<>(); + queryParams.put("en_streamer", state ? "1" : "0"); String response = invoke(setSpecialModeUri, queryParams); - return !response.contains("ret=OK"); } // Daikin Airbase API diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java index 96da99e413ba1..629994ef7cb09 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java @@ -17,6 +17,7 @@ import java.util.Optional; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.daikin.internal.api.Enums.AdvancedMode; import org.openhab.binding.daikin.internal.api.Enums.FanMovement; import org.openhab.binding.daikin.internal.api.Enums.FanSpeed; import org.openhab.binding.daikin.internal.api.Enums.Mode; @@ -44,7 +45,7 @@ public class ControlInfo { public FanMovement fanMovement = FanMovement.STOPPED; /* Not supported by all units. Sets the target humidity for dehumidifying. */ public Optional targetHumidity = Optional.empty(); - public SpecialMode specialMode = SpecialMode.UNKNOWN; + public AdvancedMode advancedMode = AdvancedMode.UNKNOWN; private ControlInfo() { } @@ -66,8 +67,8 @@ public static ControlInfo parse(String response) { .map(value -> FanMovement.fromValue(value)).orElse(FanMovement.STOPPED); info.targetHumidity = Optional.ofNullable(responseMap.get("shum")).flatMap(value -> InfoParser.parseInt(value)); - info.specialMode = Optional.ofNullable(responseMap.get("adv")).map(value -> SpecialMode.fromValue(value)) - .orElse(SpecialMode.UNKNOWN); + info.advancedMode = Optional.ofNullable(responseMap.get("adv")).map(value -> AdvancedMode.fromValue(value)) + .orElse(AdvancedMode.UNKNOWN); return info; } @@ -82,4 +83,8 @@ public Map getParamString() { return params; } + + public SpecialMode getSpecialMode() { + return SpecialMode.fromAdvancedMode(advancedMode); + } } diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/Enums.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/Enums.java index 2e5daeb2fea49..e17adf81c1412 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/Enums.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/Enums.java @@ -139,7 +139,7 @@ public String getValue() { } } - public enum SpecialMode { + public enum AdvancedMode { STREAMER("13"), ECO("12"), POWERFUL("2"), @@ -148,10 +148,10 @@ public enum SpecialMode { OFF(""), UNKNOWN("??"); - private static final Logger LOGGER = LoggerFactory.getLogger(SpecialMode.class); + private static final Logger logger = LoggerFactory.getLogger(AdvancedMode.class); private final String value; - SpecialMode(String value) { + AdvancedMode(String value) { this.value = value; } @@ -159,37 +159,35 @@ public String getValue() { return value; } - public boolean isPowerfulActive() { - return this.equals(POWERFUL) || this.equals(POWERFUL_STREAMER); + public boolean isStreamerActive() { + return this.equals(STREAMER) || this.equals(POWERFUL_STREAMER) || this.equals(ECO_STREAMER); } public boolean isUndefined() { return this.equals(UNKNOWN); } - public static SpecialMode fromValue(String value) { - for (SpecialMode m : SpecialMode.values()) { + public static AdvancedMode fromValue(String value) { + for (AdvancedMode m : AdvancedMode.values()) { if (m.getValue().equals(value)) { return m; } } - LOGGER.debug("Unexpected SpecialMode value of \"{}\"", value); + logger.debug("Unexpected AdvancedMode value of \"{}\"", value); // Default to UNKNOWN return UNKNOWN; } } - public enum SpecialModeKind { - UNKNOWN(-1), - STREAMER(0), + public enum SpecialMode { + NORMAL(0), POWERFUL(1), ECO(2); - private static final Logger LOGGER = LoggerFactory.getLogger(SpecialModeKind.class); private final int value; - SpecialModeKind(int value) { + SpecialMode(int value) { this.value = value; } @@ -197,16 +195,16 @@ public int getValue() { return value; } - public static SpecialModeKind fromValue(int value) { - for (SpecialModeKind m : SpecialModeKind.values()) { - if (m.getValue() == value) { - return m; - } + public static SpecialMode fromAdvancedMode(AdvancedMode advMode) { + switch (advMode) { + case POWERFUL: + case POWERFUL_STREAMER: + return SpecialMode.POWERFUL; + case ECO: + case ECO_STREAMER: + return SpecialMode.ECO; } - LOGGER.debug("Unexpected SpecialModeKind value of \"{}\"", value); - - // Default to UNKNOWN - return UNKNOWN; + return NORMAL; } } } diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java index a96dd1d952f9e..1a9c052b0510d 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java @@ -22,7 +22,6 @@ import org.openhab.binding.daikin.internal.DaikinBindingConstants; import org.openhab.binding.daikin.internal.DaikinCommunicationException; import org.openhab.binding.daikin.internal.DaikinDynamicStateDescriptionProvider; -import org.openhab.binding.daikin.internal.DaikinWebTargets; import org.openhab.binding.daikin.internal.api.ControlInfo; import org.openhab.binding.daikin.internal.api.EnergyInfoDayAndWeek; import org.openhab.binding.daikin.internal.api.EnergyInfoYear; @@ -30,7 +29,7 @@ import org.openhab.binding.daikin.internal.api.Enums.FanSpeed; import org.openhab.binding.daikin.internal.api.Enums.HomekitMode; import org.openhab.binding.daikin.internal.api.Enums.Mode; -import org.openhab.binding.daikin.internal.api.Enums.SpecialModeKind; +import org.openhab.binding.daikin.internal.api.Enums.SpecialMode; import org.openhab.binding.daikin.internal.api.SensorInfo; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; @@ -69,7 +68,7 @@ protected void pollStatus() throws DaikinCommunicationException { if (!"OK".equals(controlInfo.ret)) { throw new DaikinCommunicationException("Invalid response from host"); } - updateState(DaikinBindingConstants.CHANNEL_AC_POWER, controlInfo.power ? OnOffType.ON : OnOffType.OFF); + updateState(DaikinBindingConstants.CHANNEL_AC_POWER, OnOffType.from(controlInfo.power)); updateTemperatureChannel(DaikinBindingConstants.CHANNEL_AC_TEMP, controlInfo.temp); updateState(DaikinBindingConstants.CHANNEL_AC_MODE, new StringType(controlInfo.mode.name())); @@ -86,13 +85,14 @@ protected void pollStatus() throws DaikinCommunicationException { updateState(DaikinBindingConstants.CHANNEL_AC_HOMEKITMODE, new StringType(HomekitMode.AUTO.getValue())); } - updateState(DaikinBindingConstants.CHANNEL_AC_SPECIALMODE, new StringType(controlInfo.specialMode.name())); - - if (controlInfo.specialMode.isUndefined()) { - updateState(DaikinBindingConstants.CHANNEL_AC_SPECIALMODE_POWERFUL, UnDefType.UNDEF); + if (controlInfo.advancedMode.isUndefined()) { + updateState(DaikinBindingConstants.CHANNEL_AC_STREAMER, UnDefType.UNDEF); + updateState(DaikinBindingConstants.CHANNEL_AC_SPECIALMODE, UnDefType.UNDEF); } else { - updateState(DaikinBindingConstants.CHANNEL_AC_SPECIALMODE_POWERFUL, - controlInfo.specialMode.isPowerfulActive() ? OnOffType.ON : OnOffType.OFF); + updateState(DaikinBindingConstants.CHANNEL_AC_STREAMER, + OnOffType.from(controlInfo.advancedMode.isStreamerActive())); + updateState(DaikinBindingConstants.CHANNEL_AC_SPECIALMODE, + new StringType(controlInfo.getSpecialMode().name())); } SensorInfo sensorInfo = webTargets.getSensorInfo(); @@ -161,9 +161,15 @@ protected boolean handleCommandInternal(ChannelUID channelUID, Command command) return true; } break; - case DaikinBindingConstants.CHANNEL_AC_SPECIALMODE_POWERFUL: + case DaikinBindingConstants.CHANNEL_AC_SPECIALMODE: + if (command instanceof StringType) { + changeSpecialMode(((StringType) command).toString()); + return true; + } + break; + case DaikinBindingConstants.CHANNEL_AC_STREAMER: if (command instanceof OnOffType) { - changeSpecialModePowerful(((OnOffType) command).equals(OnOffType.ON)); + changeStreamer(((OnOffType) command).equals(OnOffType.ON)); return true; } break; @@ -173,10 +179,6 @@ protected boolean handleCommandInternal(ChannelUID channelUID, Command command) @Override protected void changePower(boolean power) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } ControlInfo info = webTargets.getControlInfo(); info.power = power; webTargets.setControlInfo(info); @@ -184,10 +186,6 @@ protected void changePower(boolean power) throws DaikinCommunicationException { @Override protected void changeSetPoint(double newTemperature) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } ControlInfo info = webTargets.getControlInfo(); info.temp = Optional.of(newTemperature); webTargets.setControlInfo(info); @@ -195,10 +193,6 @@ protected void changeSetPoint(double newTemperature) throws DaikinCommunicationE @Override protected void changeMode(String mode) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } Mode newMode; try { newMode = Mode.valueOf(mode); @@ -213,10 +207,6 @@ protected void changeMode(String mode) throws DaikinCommunicationException { @Override protected void changeFanSpeed(String fanSpeed) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } FanSpeed newSpeed; try { newSpeed = FanSpeed.valueOf(fanSpeed); @@ -230,10 +220,6 @@ protected void changeFanSpeed(String fanSpeed) throws DaikinCommunicationExcepti } protected void changeFanDir(String fanDir) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } FanMovement newMovement; try { newMovement = FanMovement.valueOf(fanDir); @@ -246,18 +232,19 @@ protected void changeFanDir(String fanDir) throws DaikinCommunicationException { webTargets.setControlInfo(info); } - /** - * - * @param powerfulMode - * @return Is change successful - * @throws DaikinCommunicationException - */ - protected boolean changeSpecialModePowerful(boolean powerfulMode) throws DaikinCommunicationException { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return false; + protected void changeSpecialMode(String specialMode) throws DaikinCommunicationException { + SpecialMode newMode; + try { + newMode = SpecialMode.valueOf(specialMode); + } catch (IllegalArgumentException e) { + logger.warn("Invalid specialmode: {}. Valid values: {}", specialMode, SpecialMode.values()); + return; } - return webTargets.setSpecialMode(SpecialModeKind.POWERFUL, powerfulMode); + webTargets.setSpecialMode(newMode); + } + + protected void changeStreamer(boolean streamerMode) throws DaikinCommunicationException { + webTargets.setStreamerMode(streamerMode); } /** @@ -295,10 +282,6 @@ protected void registerUuid(@Nullable String key) { return; } try { - DaikinWebTargets webTargets = this.webTargets; - if (webTargets == null) { - return; - } webTargets.registerUuid(key); } catch (DaikinCommunicationException e) { // suppress exceptions diff --git a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java index 53e487813f0d1..5f229ca53f5f6 100644 --- a/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java +++ b/bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java @@ -92,6 +92,10 @@ public DaikinBaseHandler(Thing thing, DaikinDynamicStateDescriptionProvider stat @Override public void handleCommand(ChannelUID channelUID, Command command) { + if (webTargets == null) { + logger.error("Unable to handle commands. Check Daikin binding configurations"); + return; + } try { if (handleCommandInternal(channelUID, command)) { return; diff --git a/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/i18n/daikin.properties b/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/i18n/daikin.properties index e7b19d70231d3..cab464409c624 100644 --- a/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/i18n/daikin.properties +++ b/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/i18n/daikin.properties @@ -125,10 +125,12 @@ channel-type.daikin.acunit-power.label = Power channel-type.daikin.acunit-power.description = Power for the AC unit channel-type.daikin.acunit-settemp.label = Set Point channel-type.daikin.acunit-settemp.description = The set point temperature -channel-type.daikin.acunit-specialmode-powerful.label = Powerful Mode -channel-type.daikin.acunit-specialmode-powerful.description = Powerful mode switch channel-type.daikin.acunit-specialmode.label = Special Mode -channel-type.daikin.acunit-specialmode.description = Current special mode +channel-type.daikin.acunit-specialmode.state.option.NORMAL = Normal +channel-type.daikin.acunit-specialmode.state.option.ECO = ECO +channel-type.daikin.acunit-specialmode.state.option.POWERFUL = Powerful +channel-type.daikin.acunit-streamer.label = Streamer +channel-type.daikin.acunit-streamer.description = Streamer Mode channel-type.daikin.airbase-acunit-fan.label = Fan channel-type.daikin.airbase-acunit-fan.description = Current fan speed setting of the AC unit channel-type.daikin.airbase-acunit-zone1.label = Zone 1 diff --git a/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/thing/thing-types.xml index db54c426857c7..de7b442854204 100644 --- a/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/thing/thing-types.xml @@ -20,7 +20,7 @@ - + @@ -87,6 +87,7 @@ Switch Power for the AC unit + Switch @@ -117,6 +118,7 @@ Number:Dimensionless The indoor humidity as measured by the A/C unit + Humidity @@ -180,6 +182,31 @@ + + Number:Dimensionless + + Current compressor frequency + + + + + String + + + + + + + + + + + + Switch + + Streamer Mode + + Number:Energy @@ -228,169 +255,172 @@ - - Number:Dimensionless - - Current compressor frequency - - - - String - - Current special mode - - - - Switch - - Powerful mode switch - Number:Energy The energy usage for heating this year January + Energy Number:Energy The energy usage for heating this year February + Energy - Number:Energy The energy usage for heating this year March + Energy - Number:Energy The energy usage for heating this year April + Energy Number:Energy The energy usage for heating this year May + Energy Number:Energy The energy usage for heating this year June + Energy Number:Energy The energy usage for heating this year July + Energy Number:Energy The energy usage for heating this year August + Energy Number:Energy The energy usage for heating this year September + Energy Number:Energy The energy usage for heating this year October + Energy Number:Energy The energy usage for heating this year November + Energy Number:Energy The energy usage for heating this year December + Energy Number:Energy The energy usage for cooling this year January + Energy Number:Energy The energy usage for cooling this year February + Energy - Number:Energy The energy usage for cooling this year March + Energy - Number:Energy The energy usage for cooling this year April + Energy Number:Energy The energy usage for cooling this year May + Energy Number:Energy The energy usage for cooling this year June + Energy Number:Energy The energy usage for cooling this year July + Energy Number:Energy The energy usage for cooling this year August + Energy Number:Energy The energy usage for cooling this year September + Energy Number:Energy The energy usage for cooling this year October + Energy Number:Energy The energy usage for cooling this year November + Energy Number:Energy The energy usage for cooling this year December + Energy