]> git.basschouten.com Git - openhab-addons.git/commitdiff
[daikin] Fix Special Mode and Streamer support (#12324)
authorjimtng <2554958+jimtng@users.noreply.github.com>
Wed, 23 Feb 2022 07:37:25 +0000 (17:37 +1000)
committerGitHub <noreply@github.com>
Wed, 23 Feb 2022 07:37:25 +0000 (08:37 +0100)
* [daikin] Fix Special Mode support

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
bundles/org.openhab.binding.daikin/README.md
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinBindingConstants.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/DaikinWebTargets.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/ControlInfo.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/api/Enums.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinAcUnitHandler.java
bundles/org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal/handler/DaikinBaseHandler.java
bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/i18n/daikin.properties
bundles/org.openhab.binding.daikin/src/main/resources/OH-INF/thing/thing-types.xml

index f2ded25e3664b8f309e1dfe93cb1fe7cec41c863..839f354fca9f418f4008c32eb75c1f0c438b0c14 100644 (file)
@@ -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 <https://www.uuidgenerator.net/>.
 * `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:
 
 ```
index 0beef31057e7b6aedaa30c13f6ee85e3f3d21cb3..dff80333f09341fbb70998ce30fc00879303b0da 100644 (file)
@@ -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";
index cc68a6b607287493d726c51453212427e470169d..878e1d783854b31a85f0ef9ad071fdd05d94f705 100644 (file)
@@ -30,7 +30,7 @@ import org.openhab.binding.daikin.internal.api.BasicInfo;
 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 class DaikinWebTargets {
         return EnergyInfoDayAndWeek.parse(response);
     }
 
-    public boolean setSpecialMode(SpecialModeKind specialModeKind, boolean state) throws DaikinCommunicationException {
+    public void setSpecialMode(SpecialMode specialMode) throws DaikinCommunicationException {
         Map<String, String> 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<String, String> queryParams = new HashMap<>();
+        queryParams.put("en_streamer", state ? "1" : "0");
         String response = invoke(setSpecialModeUri, queryParams);
-        return !response.contains("ret=OK");
     }
 
     // Daikin Airbase API
index 96da99e413ba1245a87dcd3155a311bfaa86348d..629994ef7cb090b329415341e0a49af69951f82b 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Map;
 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<Integer> targetHumidity = Optional.empty();
-    public SpecialMode specialMode = SpecialMode.UNKNOWN;
+    public AdvancedMode advancedMode = AdvancedMode.UNKNOWN;
 
     private ControlInfo() {
     }
@@ -66,8 +67,8 @@ public class ControlInfo {
                 .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 class ControlInfo {
 
         return params;
     }
+
+    public SpecialMode getSpecialMode() {
+        return SpecialMode.fromAdvancedMode(advancedMode);
+    }
 }
index 2e5daeb2fea499bc17a2ea98d671b2fa08d616fa..8f90c82635742153788740da1fa76b66bd8ae65f 100644 (file)
@@ -139,7 +139,7 @@ public class Enums {
         }
     }
 
-    public enum SpecialMode {
+    public enum AdvancedMode {
         STREAMER("13"),
         ECO("12"),
         POWERFUL("2"),
@@ -148,10 +148,10 @@ public class Enums {
         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 class Enums {
             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 class Enums {
             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;
         }
     }
 }
index a96dd1d952f9eb07c24608e293b8c1169c16fbcc..1a9c052b0510d708dfd6f0c1a6c863638ee01e42 100644 (file)
@@ -22,7 +22,6 @@ import org.eclipse.jetty.client.HttpClient;
 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.FanMovement;
 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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
         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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
             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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
                     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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
 
     @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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
 
     @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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
 
     @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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
 
     @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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
     }
 
     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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
         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 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
             return;
         }
         try {
-            DaikinWebTargets webTargets = this.webTargets;
-            if (webTargets == null) {
-                return;
-            }
             webTargets.registerUuid(key);
         } catch (DaikinCommunicationException e) {
             // suppress exceptions
index 53e487813f0d14d9b8ff663d41d1205e2cc52373..c108c810184741ce98ca50f4aa39d4741115e2cf 100644 (file)
@@ -92,6 +92,10 @@ public abstract class DaikinBaseHandler extends BaseThingHandler {
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
+        if (webTargets == null) {
+            logger.warn("webTargets is null. This is possibly a bug.");
+            return;
+        }
         try {
             if (handleCommandInternal(channelUID, command)) {
                 return;
index e7b19d70231d3567db2a2698eb63951e685a1e18..cab464409c624f2043338aff38077f68cdaec8a3 100644 (file)
@@ -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
index db54c426857c7bc3245f836f5c5ea388f1d05234..de7b442854204877a9e9acce80b15f7ba33f6ca3 100644 (file)
@@ -20,7 +20,7 @@
                        <channel id="fandir" typeId="acunit-fandir"/>
                        <channel id="cmpfrequency" typeId="acunit-cmpfrequency"></channel>
                        <channel id="specialmode" typeId="acunit-specialmode"></channel>
-                       <channel id="specialmode-powerful" typeId="acunit-specialmode-powerful"></channel>
+                       <channel id="streamer" typeId="acunit-streamer"></channel>
                        <channel id="energyheatingtoday" typeId="acunit-energyheatingtoday"/>
                        <channel id="energyheatingthisweek" typeId="acunit-energyheatingthisweek"/>
                        <channel id="energyheatinglastweek" typeId="acunit-energyheatinglastweek"/>
@@ -87,6 +87,7 @@
                <item-type>Switch</item-type>
                <label>Power</label>
                <description>Power for the AC unit</description>
+               <category>Switch</category>
        </channel-type>
 
        <channel-type id="acunit-settemp">
                <item-type>Number:Dimensionless</item-type>
                <label>Indoor Humidity</label>
                <description>The indoor humidity as measured by the A/C unit</description>
+               <category>Humidity</category>
                <state readOnly="true" pattern="%.0f %unit%"/>
        </channel-type>
 
                </state>
        </channel-type>
 
+       <channel-type id="acunit-cmpfrequency" advanced="true">
+               <item-type>Number:Dimensionless</item-type>
+               <label>Compressor Frequency</label>
+               <description>Current compressor frequency</description>
+               <state readOnly="true" pattern="%.0f %unit%"></state>
+       </channel-type>
+
+       <channel-type id="acunit-specialmode" advanced="true">
+               <item-type>String</item-type>
+               <label>Special Mode</label>
+               <state>
+                       <options>
+                               <option value="NORMAL">Normal</option>
+                               <option value="ECO">ECO</option>
+                               <option value="POWERFUL">Powerful</option>
+                       </options>
+               </state>
+       </channel-type>
+
+       <channel-type id="acunit-streamer" advanced="true">
+               <item-type>Switch</item-type>
+               <label>Streamer</label>
+               <description>Streamer Mode</description>
+       </channel-type>
+
        <channel-type id="acunit-energyheatingtoday" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Today</label>
                <state readOnly="true" pattern="%.1f %unit%"></state>
        </channel-type>
 
-       <channel-type id="acunit-cmpfrequency" advanced="true">
-               <item-type>Number:Dimensionless</item-type>
-               <label>Compressor Frequency</label>
-               <description>Current compressor frequency</description>
-               <state readOnly="true" pattern="%.0f %unit%"></state>
-       </channel-type>
-       <channel-type id="acunit-specialmode" advanced="true">
-               <item-type>String</item-type>
-               <label>Special Mode</label>
-               <description>Current special mode</description>
-               <state readOnly="true" pattern="%s"></state>
-       </channel-type>
-       <channel-type id="acunit-specialmode-powerful" advanced="true">
-               <item-type>Switch</item-type>
-               <label>Powerful Mode</label>
-               <description>Powerful mode switch</description>
-       </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-1" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year January</label>
                <description>The energy usage for heating this year January</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-2" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year February</label>
                <description>The energy usage for heating this year February</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
-
        <channel-type id="acunit-energyheatingcurrentyear-3" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year March</label>
                <description>The energy usage for heating this year March</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
-
        <channel-type id="acunit-energyheatingcurrentyear-4" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year April</label>
                <description>The energy usage for heating this year April</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-5" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year May</label>
                <description>The energy usage for heating this year May</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-6" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year June</label>
                <description>The energy usage for heating this year June</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-7" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year July</label>
                <description>The energy usage for heating this year July</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-8" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year August</label>
                <description>The energy usage for heating this year August</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-9" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year September</label>
                <description>The energy usage for heating this year September</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-10" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year October</label>
                <description>The energy usage for heating this year October</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-11" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year November</label>
                <description>The energy usage for heating this year November</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energyheatingcurrentyear-12" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Heating Current Year December</label>
                <description>The energy usage for heating this year December</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-1" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year January</label>
                <description>The energy usage for cooling this year January</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-2" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year February</label>
                <description>The energy usage for cooling this year February</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
-
        <channel-type id="acunit-energycoolingcurrentyear-3" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year March</label>
                <description>The energy usage for cooling this year March</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
-
        <channel-type id="acunit-energycoolingcurrentyear-4" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year April</label>
                <description>The energy usage for cooling this year April</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-5" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year May</label>
                <description>The energy usage for cooling this year May</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-6" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year June</label>
                <description>The energy usage for cooling this year June</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-7" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year July</label>
                <description>The energy usage for cooling this year July</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-8" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year August</label>
                <description>The energy usage for cooling this year August</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-9" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year September</label>
                <description>The energy usage for cooling this year September</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-10" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year October</label>
                <description>The energy usage for cooling this year October</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-11" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year November</label>
                <description>The energy usage for cooling this year November</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="acunit-energycoolingcurrentyear-12" advanced="true">
                <item-type>Number:Energy</item-type>
                <label>Energy Cooling Current Year December</label>
                <description>The energy usage for cooling this year December</description>
+               <category>Energy</category>
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>