[homeconnect] 2 channels added for washer appliance (#11071)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-08-07 20:55:32 +02:00 committed by GitHub
parent e3b8b937c4
commit bcd89086f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 2 deletions

View 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 |

View 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";

View 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,

View 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));

View 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));
}

View File

@ -116,7 +116,9 @@
<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"/>
@ -153,7 +155,9 @@
<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"/>
@ -547,12 +551,25 @@
</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>