Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[homeconnect] 2 channels added for washer appliance #11071

Merged
merged 1 commit into from Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions bundles/org.openhab.binding.homeconnect/README.md
Expand Up @@ -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 |
Expand Down
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
Expand Up @@ -16,7 +16,7 @@
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.*;

Expand All @@ -35,6 +35,7 @@

import javax.measure.UnconvertibleException;
import javax.measure.Unit;
import javax.measure.quantity.Mass;
import javax.measure.quantity.Temperature;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand Down Expand Up @@ -675,6 +676,22 @@ protected Unit<Temperature> mapTemperature(@Nullable String unit) {
}
}

/**
* 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.
*
Expand Down Expand Up @@ -1405,7 +1422,8 @@ protected void processProgramOptions(List<Option> options) {

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,
Expand Down Expand Up @@ -1435,6 +1453,8 @@ protected void processProgramOptions(List<Option> options) {
: 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,
Expand Down
Expand Up @@ -75,8 +75,12 @@ protected void configureChannelUpdateHandlers(Map<String, ChannelUpdateHandler>
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,
Expand Down Expand Up @@ -121,7 +125,9 @@ protected boolean isChannelLinkedToProgramOptionNotFullySupportedByApi() {
|| 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();
}
Expand Down Expand Up @@ -173,7 +179,10 @@ protected void resetProgramStateChannels(boolean offline) {
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));
Expand Down
Expand Up @@ -84,8 +84,12 @@ protected void configureChannelUpdateHandlers(Map<String, ChannelUpdateHandler>
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,
Expand Down Expand Up @@ -170,7 +174,9 @@ protected boolean isChannelLinkedToProgramOptionNotFullySupportedByApi() {
|| 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();
}
Expand Down Expand Up @@ -230,7 +236,10 @@ protected void resetProgramStateChannels(boolean offline) {
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));
}
Expand Down
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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"/>
Expand Down Expand Up @@ -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>
Expand Down