]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homeconnect] 2 channels added for washer appliance (#11071)
authorlolodomo <lg.hc@free.fr>
Sat, 7 Aug 2021 18:55:32 +0000 (20:55 +0200)
committerGitHub <noreply@github.com>
Sat, 7 Aug 2021 18:55:32 +0000 (20:55 +0200)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.homeconnect/README.md
bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/HomeConnectBindingConstants.java
bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/AbstractHomeConnectThingHandler.java
bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherDryerHandler.java
bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/handler/HomeConnectWasherHandler.java
bundles/org.openhab.binding.homeconnect/src/main/resources/OH-INF/thing/thing-types.xml

index 530c16c6fbc098bad1c2b61a694a136256f16e02..6612b0545426d59d499e4152f5bb525796f26784 100644 (file)
@@ -64,7 +64,9 @@ After the bridge has been added and authorized, devices are discovered automatic
 | laundry_care_washer_less_ironing | Switch | true | This status indicates whether less ironing is activated for a washer program of the home appliance. | washer, washerdryer | 
 | laundry_care_washer_pre_wash | Switch | true | This status indicates whether the pre-wash is activated for a washer program of the home appliance. | washer, washerdryer | 
 | laundry_care_washer_rinse_plus | String | true | This status defines the number of additional rinses of a washer program of the home appliance. | washer, washerdryer | 
+| laundry_care_washer_rinse_hold | Switch | true | This status indicates whether the spin function is deactivated for a washer program of the home appliance (washing will remain in the water after the last rinse cycle). | washer, washerdryer | 
 | laundry_care_washer_soak | Switch | true | This status indicates whether the soaking is activated for a washer program of the home appliance. | washer, washerdryer | 
+| laundry_care_washer_load_recommendation | Number:Mass | true | This channel indicates the maximum laundry load recommended for a program of the home appliance. | washer, washerdryer | 
 | program_energy | Number:Dimensionless | true | This channel provides the estimated energy required in percentage for a program of the home appliance. | washer, washerdryer | 
 | program_water | Number:Dimensionless | true | This channel provides the estimated water required in percentage for a program of the home appliance. | washer, washerdryer | 
 | dryer_drying_target | String | false | This status defines the desired dryness of a program of the home appliance. | dryer, washerdryer | 
index f07647d256cc8cb1f25ed9e6078cdf5ba852f4c2..6718f41ac0834b01cea5697091a955b766461133 100644 (file)
@@ -128,7 +128,9 @@ public class HomeConnectBindingConstants {
     public static final String CHANNEL_WASHER_LESS_IRONING = "laundry_care_washer_less_ironing";
     public static final String CHANNEL_WASHER_PRE_WASH = "laundry_care_washer_pre_wash";
     public static final String CHANNEL_WASHER_RINSE_PLUS = "laundry_care_washer_rinse_plus";
+    public static final String CHANNEL_WASHER_RINSE_HOLD = "laundry_care_washer_rinse_hold";
     public static final String CHANNEL_WASHER_SOAK = "laundry_care_washer_soak";
+    public static final String CHANNEL_WASHER_LOAD_RECOMMENDATION = "laundry_care_washer_load_recommendation";
     public static final String CHANNEL_PROGRAM_ENERGY = "program_energy";
     public static final String CHANNEL_PROGRAM_WATER = "program_water";
     public static final String CHANNEL_REFRIGERATOR_SETPOINT_TEMPERATURE = "setpoint_temperature_refrigerator";
@@ -188,7 +190,9 @@ public class HomeConnectBindingConstants {
     public static final String OPTION_WASHER_LESS_IRONING = "LaundryCare.Washer.Option.LessIroning";
     public static final String OPTION_WASHER_PRE_WASH = "LaundryCare.Washer.Option.Prewash";
     public static final String OPTION_WASHER_RINSE_PLUS = "LaundryCare.Washer.Option.RinsePlus";
+    public static final String OPTION_WASHER_RINSE_HOLD = "LaundryCare.Washer.Option.RinseHold";
     public static final String OPTION_WASHER_SOAK = "LaundryCare.Washer.Option.Soak";
+    public static final String OPTION_WASHER_LOAD_RECOMMENDATION = "LaundryCare.Common.Option.LoadRecommendation";
     public static final String OPTION_WASHER_ENERGY_FORECAST = "BSH.Common.Option.EnergyForecast";
     public static final String OPTION_WASHER_WATER_FORECAST = "BSH.Common.Option.WaterForecast";
     public static final String OPTION_DRYER_DRYING_TARGET = "LaundryCare.Dryer.Option.DryingTarget";
index dd2957fde0650603a09c414753bf9b617ef70092..183c4039b49372c434c88de5242bc2d86bf348a4 100644 (file)
@@ -16,7 +16,7 @@ import static java.util.Collections.emptyList;
 import static org.openhab.binding.homeconnect.internal.HomeConnectBindingConstants.*;
 import static org.openhab.binding.homeconnect.internal.client.model.EventType.*;
 import static org.openhab.core.library.unit.ImperialUnits.FAHRENHEIT;
-import static org.openhab.core.library.unit.SIUnits.CELSIUS;
+import static org.openhab.core.library.unit.SIUnits.*;
 import static org.openhab.core.library.unit.Units.*;
 import static org.openhab.core.thing.ThingStatus.*;
 
@@ -35,6 +35,7 @@ import java.util.stream.Collectors;
 
 import javax.measure.UnconvertibleException;
 import javax.measure.Unit;
+import javax.measure.quantity.Mass;
 import javax.measure.quantity.Temperature;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -675,6 +676,22 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
         }
     }
 
+    /**
+     * Map unit string (returned by home connect api) to Unit
+     *
+     * @param unit String eg. "gram"
+     * @return Unit
+     */
+    protected Unit<Mass> mapMass(@Nullable String unit) {
+        if ("gram".equalsIgnoreCase(unit)) {
+            return GRAM;
+        } else if ("kilogram".equalsIgnoreCase(unit)) {
+            return KILOGRAM;
+        } else {
+            return GRAM;
+        }
+    }
+
     /**
      * Map hex representation of color to HSB type.
      *
@@ -1405,7 +1422,8 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
 
         Map.of(CHANNEL_WASHER_IDOS1, OPTION_WASHER_IDOS_1_ACTIVE, CHANNEL_WASHER_IDOS2, OPTION_WASHER_IDOS_2_ACTIVE,
                 CHANNEL_WASHER_LESS_IRONING, OPTION_WASHER_LESS_IRONING, CHANNEL_WASHER_PRE_WASH,
-                OPTION_WASHER_PRE_WASH, CHANNEL_WASHER_SOAK, OPTION_WASHER_SOAK)
+                OPTION_WASHER_PRE_WASH, CHANNEL_WASHER_SOAK, OPTION_WASHER_SOAK, CHANNEL_WASHER_RINSE_HOLD,
+                OPTION_WASHER_RINSE_HOLD)
                 .forEach((channel, option) -> setOnOffChannelFromOption(channel, options, option, OnOffType.OFF));
 
         setStringChannelFromOption(CHANNEL_HOOD_INTENSIVE_LEVEL, options, OPTION_HOOD_INTENSIVE_LEVEL,
@@ -1435,6 +1453,8 @@ public abstract class AbstractHomeConnectThingHandler extends BaseThingHandler i
                         : null);
         setStringChannelFromOption(CHANNEL_WASHER_RINSE_PLUS, options, OPTION_WASHER_RINSE_PLUS,
                 new StringType("LaundryCare.Washer.EnumType.RinsePlus.Off"));
+        setQuantityChannelFromOption(CHANNEL_WASHER_LOAD_RECOMMENDATION, options, OPTION_WASHER_LOAD_RECOMMENDATION,
+                unit -> mapMass(unit), UnDefType.UNDEF);
         setQuantityChannelFromOption(CHANNEL_PROGRAM_ENERGY, options, OPTION_WASHER_ENERGY_FORECAST, unit -> PERCENT,
                 UnDefType.UNDEF);
         setQuantityChannelFromOption(CHANNEL_PROGRAM_WATER, options, OPTION_WASHER_WATER_FORECAST, unit -> PERCENT,
index 329a2aefe274ab410beed73f2c7dbd4eda8e33a3..8c5c9c9dc31b212823b44282db8d1dc74b72cbef 100644 (file)
@@ -75,8 +75,12 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_WASHER_RINSE_PLUS,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
+        handlers.put(CHANNEL_WASHER_RINSE_HOLD,
+                getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_WASHER_SOAK,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
+        handlers.put(CHANNEL_WASHER_LOAD_RECOMMENDATION,
+                getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_PROGRAM_ENERGY,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_PROGRAM_WATER,
@@ -121,7 +125,9 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl
                 || getLinkedChannel(CHANNEL_WASHER_LESS_IRONING).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_PRE_WASH).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_RINSE_PLUS).isPresent()
+                || getLinkedChannel(CHANNEL_WASHER_RINSE_HOLD).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_SOAK).isPresent()
+                || getLinkedChannel(CHANNEL_WASHER_LOAD_RECOMMENDATION).isPresent()
                 || getLinkedChannel(CHANNEL_PROGRAM_ENERGY).isPresent()
                 || getLinkedChannel(CHANNEL_PROGRAM_WATER).isPresent();
     }
@@ -173,7 +179,10 @@ public class HomeConnectWasherDryerHandler extends AbstractHomeConnectThingHandl
             getLinkedChannel(CHANNEL_WASHER_LESS_IRONING).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_PRE_WASH).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_RINSE_PLUS).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
+            getLinkedChannel(CHANNEL_WASHER_RINSE_HOLD).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_SOAK).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
+            getLinkedChannel(CHANNEL_WASHER_LOAD_RECOMMENDATION)
+                    .ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_PROGRAM_ENERGY).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_PROGRAM_WATER).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_DRYER_DRYING_TARGET).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
index 3d458b15bc229a198b2c9dec24645c2bbaaf8378..94e96db613978edf7302730dbded57c921fc06d2 100644 (file)
@@ -84,8 +84,12 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler {
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_WASHER_RINSE_PLUS,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
+        handlers.put(CHANNEL_WASHER_RINSE_HOLD,
+                getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_WASHER_SOAK,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
+        handlers.put(CHANNEL_WASHER_LOAD_RECOMMENDATION,
+                getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_PROGRAM_ENERGY,
                 getAndUpdateProgramOptionsStateDescriptionsAndSelectedProgramStateUpdateHandler());
         handlers.put(CHANNEL_PROGRAM_WATER,
@@ -170,7 +174,9 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler {
                 || getLinkedChannel(CHANNEL_WASHER_LESS_IRONING).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_PRE_WASH).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_RINSE_PLUS).isPresent()
+                || getLinkedChannel(CHANNEL_WASHER_RINSE_HOLD).isPresent()
                 || getLinkedChannel(CHANNEL_WASHER_SOAK).isPresent()
+                || getLinkedChannel(CHANNEL_WASHER_LOAD_RECOMMENDATION).isPresent()
                 || getLinkedChannel(CHANNEL_PROGRAM_ENERGY).isPresent()
                 || getLinkedChannel(CHANNEL_PROGRAM_WATER).isPresent();
     }
@@ -230,7 +236,10 @@ public class HomeConnectWasherHandler extends AbstractHomeConnectThingHandler {
             getLinkedChannel(CHANNEL_WASHER_LESS_IRONING).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_PRE_WASH).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_RINSE_PLUS).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
+            getLinkedChannel(CHANNEL_WASHER_RINSE_HOLD).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_WASHER_SOAK).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
+            getLinkedChannel(CHANNEL_WASHER_LOAD_RECOMMENDATION)
+                    .ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_PROGRAM_ENERGY).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
             getLinkedChannel(CHANNEL_PROGRAM_WATER).ifPresent(c -> updateState(c.getUID(), UnDefType.UNDEF));
         }
index 99ed635b43a2bef857bfe0ec3958fcd6f59c2d9a..d6c94234aa4e215f223d70254ecd9691c81529e4 100644 (file)
                        <channel id="laundry_care_washer_less_ironing" typeId="laundry_care_washer_less_ironing"/>
                        <channel id="laundry_care_washer_pre_wash" typeId="laundry_care_washer_pre_wash"/>
                        <channel id="laundry_care_washer_rinse_plus" typeId="laundry_care_washer_rinse_plus"/>
+                       <channel id="laundry_care_washer_rinse_hold" typeId="laundry_care_washer_rinse_hold"/>
                        <channel id="laundry_care_washer_soak" typeId="laundry_care_washer_soak"/>
+                       <channel id="laundry_care_washer_load_recommendation" typeId="laundry_care_washer_load_recommendation"/>
                        <channel id="program_energy" typeId="program_energy"/>
                        <channel id="program_water" typeId="program_water"/>
                        <channel id="basic_actions_state" typeId="basic_actions_state"/>
                        <channel id="laundry_care_washer_less_ironing" typeId="laundry_care_washer_less_ironing"/>
                        <channel id="laundry_care_washer_pre_wash" typeId="laundry_care_washer_pre_wash"/>
                        <channel id="laundry_care_washer_rinse_plus" typeId="laundry_care_washer_rinse_plus"/>
+                       <channel id="laundry_care_washer_rinse_hold" typeId="laundry_care_washer_rinse_hold"/>
                        <channel id="laundry_care_washer_soak" typeId="laundry_care_washer_soak"/>
+                       <channel id="laundry_care_washer_load_recommendation" typeId="laundry_care_washer_load_recommendation"/>
                        <channel id="program_energy" typeId="program_energy"/>
                        <channel id="program_water" typeId="program_water"/>
                        <channel id="dryer_drying_target" typeId="dryer_drying_target"/>
                        </options>
                </state>
        </channel-type>
+       <channel-type id="laundry_care_washer_rinse_hold" advanced="true">
+               <item-type>Switch</item-type>
+               <label>Rinse Hold</label>
+               <description>This status indicates whether the spin function is deactivated for a washer program of the home appliance
+                       (washing will remain in the water after the last rinse cycle).</description>
+               <state readOnly="true"/>
+       </channel-type>
        <channel-type id="laundry_care_washer_soak" advanced="true">
                <item-type>Switch</item-type>
                <label>Soaking</label>
                <description>This status indicates whether the soaking is activated for a washer program of the home appliance.</description>
                <state readOnly="true"/>
        </channel-type>
+       <channel-type id="laundry_care_washer_load_recommendation" advanced="true">
+               <item-type>Number:Mass</item-type>
+               <label>Load Recommendation</label>
+               <description>This channel indicates the maximum laundry load recommended for a program of the home appliance.</description>
+               <state readOnly="true" min="0" pattern="%.1f %unit%"/>
+       </channel-type>
        <channel-type id="program_energy" advanced="true">
                <item-type>Number:Dimensionless</item-type>
                <label>Program Energy</label>