[mielecloud] Add channels energy and water consumption (#14456)
* Add POJOs for ecoFeedback from Miele REST API * DeviceState offers water and energy consumption * Convert Quantity to State for channel population * Add eco feedback channels to devices * Fix item types and categories * Add update instructions for eco feedback channels Signed-off-by: Björn Lange <bjoern.lange@itemis.de>
This commit is contained in:
@@ -209,7 +209,8 @@ public abstract class AbstractMieleThingHandlerTest extends JavaOSGiTest {
|
||||
}
|
||||
|
||||
protected AbstractMieleThingHandler createThingHandler(ThingTypeUID thingTypeUid, ThingUID thingUid,
|
||||
Class<? extends AbstractMieleThingHandler> expectedHandlerClass, String deviceIdentifier) {
|
||||
Class<? extends AbstractMieleThingHandler> expectedHandlerClass, String deviceIdentifier,
|
||||
String thingTypeVersion) {
|
||||
ThingRegistry registry = getThingRegistry();
|
||||
|
||||
List<Channel> channels = createChannelsForThingHandler(thingTypeUid, thingUid);
|
||||
@@ -217,7 +218,8 @@ public abstract class AbstractMieleThingHandlerTest extends JavaOSGiTest {
|
||||
Thing thing = ThingBuilder.create(thingTypeUid, thingUid)
|
||||
.withConfiguration(new Configuration(Collections
|
||||
.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, deviceIdentifier)))
|
||||
.withBridge(getBridge().getUID()).withChannels(channels).withLabel("DA-6996").build();
|
||||
.withBridge(getBridge().getUID()).withChannels(channels).withLabel("DA-6996")
|
||||
.withProperty("thingTypeVersion", thingTypeVersion).build();
|
||||
assertNotNull(thing);
|
||||
|
||||
registry.add(thing);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CoffeeDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_COFFEE_SYSTEM, COFFEE_SYSTEM_THING_UID,
|
||||
CoffeeSystemThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
CoffeeSystemThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CoolingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_FRIDGE_FREEZER, FRIDGE_FREEZER_DEVICE_THING_UID,
|
||||
CoolingDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
CoolingDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DishWarmerDeviceThingHandlerTest extends AbstractMieleThingHandlerT
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_DISH_WARMER,
|
||||
MieleCloudBindingIntegrationTestConstants.DISH_WARMER_DEVICE_THING_UID,
|
||||
DishWarmerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
DishWarmerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,22 +28,25 @@ import org.openhab.binding.mielecloud.internal.webservice.api.ActionsState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.DeviceState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.PowerStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.ProgramStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.Quantity;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.json.StateType;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
|
||||
/**
|
||||
* @author Björn Lange - Initial contribution
|
||||
* @author Benjamin Bolte - Add info state channel and map signal flags from API tests
|
||||
* @author Björn Lange - Add elapsed time channel
|
||||
* @author Björn Lange - Add elapsed time, current water and energy consumption channels
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class DishwasherDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_DISHWASHER, DISHWASHER_DEVICE_THING_UID,
|
||||
DishwasherDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
DishwasherDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,6 +67,8 @@ public class DishwasherDeviceThingHandlerTest extends AbstractMieleThingHandlerT
|
||||
when(deviceState.getStartTime()).thenReturn(Optional.empty());
|
||||
when(deviceState.getElapsedTime()).thenReturn(Optional.empty());
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.empty());
|
||||
when(deviceState.getCurrentWaterConsumption()).thenReturn(Optional.empty());
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.empty());
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -81,6 +86,8 @@ public class DishwasherDeviceThingHandlerTest extends AbstractMieleThingHandlerT
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(DELAYED_START_TIME));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(PROGRAM_ELAPSED_TIME));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(DOOR_STATE));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(WATER_CONSUMPTION_CURRENT));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,6 +112,8 @@ public class DishwasherDeviceThingHandlerTest extends AbstractMieleThingHandlerT
|
||||
when(deviceState.hasError()).thenReturn(false);
|
||||
when(deviceState.hasInfo()).thenReturn(true);
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.of(true));
|
||||
when(deviceState.getCurrentWaterConsumption()).thenReturn(Optional.of(new Quantity(1.0, "l")));
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.of(new Quantity(2.5, "kWh")));
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -124,6 +133,8 @@ public class DishwasherDeviceThingHandlerTest extends AbstractMieleThingHandlerT
|
||||
assertEquals(OnOffType.OFF, getChannelState(ERROR_STATE));
|
||||
assertEquals(OnOffType.ON, getChannelState(INFO_STATE));
|
||||
assertEquals(OnOffType.ON, getChannelState(DOOR_STATE));
|
||||
assertEquals(new QuantityType<>(1.0, Units.LITRE), getChannelState(WATER_CONSUMPTION_CURRENT));
|
||||
assertEquals(new QuantityType<>(2.5, Units.KILOWATT_HOUR), getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -28,22 +28,25 @@ import org.openhab.binding.mielecloud.internal.webservice.api.ActionsState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.DeviceState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.PowerStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.ProgramStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.Quantity;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.json.StateType;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
|
||||
/**
|
||||
* @author Björn Lange - Initial contribution
|
||||
* @author Benjamin Bolte - Add info state channel and map signal flags from API tests
|
||||
* @author Björn Lange - Add elapsed time channel
|
||||
* @author Björn Lange - Add elapsed time, current water and energy consumption channels
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class DryerDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_DRYER, DRYER_DEVICE_THING_UID,
|
||||
DryerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
DryerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,6 +70,7 @@ public class DryerDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
when(deviceState.getDryingTargetRaw()).thenReturn(Optional.empty());
|
||||
when(deviceState.getLightState()).thenReturn(Optional.empty());
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.empty());
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.empty());
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -87,6 +91,7 @@ public class DryerDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(DRYING_TARGET_RAW));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(LIGHT_SWITCH));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(DOOR_STATE));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,6 +119,7 @@ public class DryerDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
when(deviceState.hasInfo()).thenReturn(true);
|
||||
when(deviceState.getLightState()).thenReturn(Optional.of(false));
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.of(false));
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.of(new Quantity(2.5, "Wh")));
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -136,6 +142,7 @@ public class DryerDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
assertEquals(OnOffType.ON, getChannelState(INFO_STATE));
|
||||
assertEquals(OnOffType.OFF, getChannelState(LIGHT_SWITCH));
|
||||
assertEquals(OnOffType.OFF, getChannelState(DOOR_STATE));
|
||||
assertEquals(new QuantityType<>(2.5, Units.WATT_HOUR), getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class HobDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_HOB, HOB_DEVICE_THING_UID,
|
||||
HobDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
HobDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,7 +40,7 @@ public class HoodDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_HOOD, HOOD_DEVICE_THING_UID,
|
||||
HoodDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
HoodDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -184,7 +184,7 @@ public class MieleHandlerFactoryTest extends JavaOSGiTest {
|
||||
}
|
||||
|
||||
private void testHandlerCanBeCreatedForMieleDevice(ThingTypeUID thingTypeUid, ThingUID thingUid, String label,
|
||||
Class<? extends ThingHandler> expectedHandlerClass)
|
||||
Class<? extends ThingHandler> expectedHandlerClass, String thingTypeVersion)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
// given:
|
||||
MieleWebservice webservice = mock(MieleWebservice.class);
|
||||
@@ -196,7 +196,7 @@ public class MieleHandlerFactoryTest extends JavaOSGiTest {
|
||||
Thing device = ThingBuilder.create(thingTypeUid, thingUid)
|
||||
.withConfiguration(new Configuration(Collections
|
||||
.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, DEVICE_IDENTIFIER)))
|
||||
.withLabel(label).build();
|
||||
.withLabel(label).withProperty("thingTypeVersion", thingTypeVersion).build();
|
||||
|
||||
assertNotNull(device);
|
||||
verifyHandlerCreation(webservice, device, expectedHandlerClass);
|
||||
@@ -227,77 +227,77 @@ public class MieleHandlerFactoryTest extends JavaOSGiTest {
|
||||
public void testHandlerCanBeCreatedForWashingDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_WASHING_MACHINE,
|
||||
WASHING_MACHINE_TYPE, "DA-6996", WashingDeviceThingHandler.class);
|
||||
WASHING_MACHINE_TYPE, "DA-6996", WashingDeviceThingHandler.class, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForOvenDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_OVEN, OVEN_DEVICE_TYPE, "OV-6887",
|
||||
OvenDeviceThingHandler.class);
|
||||
OvenDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForHobDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_HOB, HOB_DEVICE_TYPE, "HB-3887",
|
||||
HobDeviceThingHandler.class);
|
||||
HobDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForFridgeFreezerDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_FRIDGE_FREEZER,
|
||||
FRIDGE_FREEZER_DEVICE_TYPE, "CD-6097", CoolingDeviceThingHandler.class);
|
||||
FRIDGE_FREEZER_DEVICE_TYPE, "CD-6097", CoolingDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForHoodDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_HOOD, HOOD_DEVICE_TYPE, "HD-2097",
|
||||
HoodDeviceThingHandler.class);
|
||||
HoodDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForCoffeeDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_COFFEE_SYSTEM, COFFEE_DEVICE_TYPE,
|
||||
"DA-6997", CoffeeSystemThingHandler.class);
|
||||
"DA-6997", CoffeeSystemThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForWineStorageDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_WINE_STORAGE,
|
||||
WINE_STORAGE_DEVICE_TYPE, "WS-6907", WineStorageDeviceThingHandler.class);
|
||||
WINE_STORAGE_DEVICE_TYPE, "WS-6907", WineStorageDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForDryerDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_DRYER, DRYER_DEVICE_TYPE, "DR-0907",
|
||||
DryerDeviceThingHandler.class);
|
||||
DryerDeviceThingHandler.class, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForDishwasherDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_DISHWASHER, DISHWASHER_DEVICE_TYPE,
|
||||
"DR-0907", DishwasherDeviceThingHandler.class);
|
||||
"DR-0907", DishwasherDeviceThingHandler.class, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForDishWarmerDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_DISH_WARMER,
|
||||
DISH_WARMER_DEVICE_TYPE, "DW-0907", DishWarmerDeviceThingHandler.class);
|
||||
DISH_WARMER_DEVICE_TYPE, "DW-0907", DishWarmerDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerCanBeCreatedForRoboticVacuumCleanerDevice()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
testHandlerCanBeCreatedForMieleDevice(MieleCloudBindingConstants.THING_TYPE_ROBOTIC_VACUUM_CLEANER,
|
||||
ROBOTIC_VACUUM_CLEANER_DEVICE_TYPE, "RVC-0907", RoboticVacuumCleanerDeviceThingHandler.class);
|
||||
ROBOTIC_VACUUM_CLEANER_DEVICE_TYPE, "RVC-0907", RoboticVacuumCleanerDeviceThingHandler.class, "0");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,7 @@ public class OvenDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_OVEN, OVEN_DEVICE_THING_UID,
|
||||
OvenDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
OvenDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,7 +41,8 @@ public class RoboticVacuumCleanerDeviceThingHandlerTest extends AbstractMieleThi
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_ROBOTIC_VACUUM_CLEANER,
|
||||
MieleCloudBindingIntegrationTestConstants.ROBOTIC_VACUUM_CLEANER_THING_UID,
|
||||
RoboticVacuumCleanerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
RoboticVacuumCleanerDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER,
|
||||
"0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,17 +28,19 @@ import org.openhab.binding.mielecloud.internal.webservice.api.ActionsState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.DeviceState;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.PowerStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.ProgramStatus;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.Quantity;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.api.json.StateType;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.library.unit.SIUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
|
||||
/**
|
||||
* @author Björn Lange - Initial contribution
|
||||
* @author Benjamin Bolte - Add info state channel and map signal flags from API tests
|
||||
* @author Björn Lange - Add elapsed time channel
|
||||
* @author Björn Lange - Add elapsed time, current water and energy consumption channels
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest {
|
||||
@@ -46,7 +48,7 @@ public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_WASHING_MACHINE, WASHING_MACHINE_THING_UID,
|
||||
WashingDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
WashingDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,6 +73,8 @@ public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
when(deviceState.getTargetTemperature(0)).thenReturn(Optional.empty());
|
||||
when(deviceState.getLightState()).thenReturn(Optional.empty());
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.empty());
|
||||
when(deviceState.getCurrentWaterConsumption()).thenReturn(Optional.empty());
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.empty());
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -92,6 +96,8 @@ public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(TEMPERATURE_TARGET));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(LIGHT_SWITCH));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(DOOR_STATE));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(WATER_CONSUMPTION_CURRENT));
|
||||
assertEquals(NULL_VALUE_STATE, getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,6 +126,8 @@ public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
when(deviceState.hasInfo()).thenReturn(true);
|
||||
when(deviceState.getLightState()).thenReturn(Optional.of(false));
|
||||
when(deviceState.getDoorState()).thenReturn(Optional.of(true));
|
||||
when(deviceState.getCurrentWaterConsumption()).thenReturn(Optional.of(new Quantity(0.5, "l")));
|
||||
when(deviceState.getCurrentEnergyConsumption()).thenReturn(Optional.of(new Quantity(1.5, "kWh")));
|
||||
|
||||
// when:
|
||||
getBridgeHandler().onDeviceStateUpdated(deviceState);
|
||||
@@ -143,6 +151,8 @@ public class WashingDeviceThingHandlerTest extends AbstractMieleThingHandlerTest
|
||||
assertEquals(OnOffType.ON, getChannelState(INFO_STATE));
|
||||
assertEquals(OnOffType.OFF, getChannelState(LIGHT_SWITCH));
|
||||
assertEquals(OnOffType.ON, getChannelState(DOOR_STATE));
|
||||
assertEquals(new QuantityType<>(0.5, Units.LITRE), getChannelState(WATER_CONSUMPTION_CURRENT));
|
||||
assertEquals(new QuantityType<>(1.5, Units.KILOWATT_HOUR), getChannelState(ENERGY_CONSUMPTION_CURRENT));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class WineStorageDeviceThingHandlerTest extends AbstractMieleThingHandler
|
||||
@Override
|
||||
protected AbstractMieleThingHandler setUpThingHandler() {
|
||||
return createThingHandler(MieleCloudBindingConstants.THING_TYPE_WINE_STORAGE, WINE_STORAGE_DEVICE_THING_UID,
|
||||
WineStorageDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER);
|
||||
WineStorageDeviceThingHandler.class, MieleCloudBindingIntegrationTestConstants.SERIAL_NUMBER, "0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user