Search in sources :

Example 21 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.

the class UidUtilsTest method testGeneratedChannelUIDHasExpectedFormat.

@Test
public void testGeneratedChannelUIDHasExpectedFormat() {
    HmDatapoint hmDatapoint = createDimmerHmDatapoint();
    ThingUID thingUID = createDimmerThingUID();
    ChannelUID channelUID = UidUtils.generateChannelUID(hmDatapoint, thingUID);
    assertThat(channelUID.getAsString(), is("homematic:HM-LC-Dim1-Pl3:ABC12345678:1#DIMMER"));
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) DimmerHelper.createDimmerThingUID(org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerThingUID) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) DimmerHelper.createDimmerHmDatapoint(org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerHmDatapoint) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint) Test(org.junit.Test)

Example 22 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.

the class UidUtilsTest method testGeneratedChannelTypeUIDHasExpectedFormat.

@Test
public void testGeneratedChannelTypeUIDHasExpectedFormat() {
    HmDatapoint hmDatapoint = createDimmerHmDatapoint();
    ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(hmDatapoint);
    assertThat(channelTypeUID.getAsString(), is("homematic:HM-LC-Dim1-Pl3_1_DIMMER"));
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) DimmerHelper.createDimmerHmDatapoint(org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerHmDatapoint) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint) Test(org.junit.Test)

Example 23 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.

the class DimmerHelper method createDimmerHmDatapoint.

public static HmDatapoint createDimmerHmDatapoint() {
    HmDatapoint hmDatapoint = new HmDatapoint();
    hmDatapoint.setName("DIMMER");
    hmDatapoint.setChannel(createDimmerHmChannel());
    return hmDatapoint;
}
Also used : HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 24 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.

the class PercentTypeConverter method commandToBinding.

@Override
protected Object commandToBinding(Command command, HmDatapoint dp) throws ConverterException {
    if (command.getClass() == IncreaseDecreaseType.class) {
        PercentType type = convertFromBinding(dp);
        int percent = type.intValue();
        percent += command.equals(IncreaseDecreaseType.INCREASE) ? 10 : -10;
        percent = (percent / 10) * 10;
        percent = Math.min(100, percent);
        percent = Math.max(0, percent);
        return convertToBinding(new PercentType(percent), dp);
    } else if (command.getClass() == OnOffType.class) {
        PercentType type = new PercentType(command.equals(OnOffType.ON) ? 100 : 0);
        return convertToBinding(type, dp);
    } else if (command.getClass() == UpDownType.class) {
        int result = command.equals(UpDownType.UP) ? 100 : 0;
        if (MetadataUtils.isRollerShutter(dp)) {
            result = command.equals(UpDownType.UP) ? 0 : 100;
        }
        return convertToBinding(new PercentType(result), dp);
    } else {
        return super.commandToBinding(command, dp);
    }
}
Also used : OnOffType(org.eclipse.smarthome.core.library.types.OnOffType) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 25 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.

the class PercentTypeConverter method fromBinding.

@Override
protected PercentType fromBinding(HmDatapoint dp) throws ConverterException {
    Double number = ((Number) dp.getValue()).doubleValue();
    int percent = (int) ((100 / dp.getMaxValue().doubleValue()) * number);
    if (MetadataUtils.isRollerShutter(dp)) {
        percent = 100 - percent;
    }
    return new PercentType(percent);
}
Also used : PercentType(org.eclipse.smarthome.core.library.types.PercentType) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Aggregations

HmDatapoint (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)55 HmChannel (org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)21 HmDatapointInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo)12 HmDatapointConfig (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig)7 HmDevice (org.eclipse.smarthome.binding.homematic.internal.model.HmDevice)7 Test (org.junit.Test)6 IOException (java.io.IOException)5 HomematicClientException (org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException)5 ArrayList (java.util.ArrayList)4 HomematicGateway (org.eclipse.smarthome.binding.homematic.internal.communicator.HomematicGateway)4 Channel (org.eclipse.smarthome.core.thing.Channel)4 JavaTest (org.eclipse.smarthome.test.java.JavaTest)4 Map (java.util.Map)3 TclScriptDataEntry (org.eclipse.smarthome.binding.homematic.internal.model.TclScriptDataEntry)3 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)3 HashMap (java.util.HashMap)2 BatteryTypeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.BatteryTypeVirtualDatapointHandler)2 ButtonVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ButtonVirtualDatapointHandler)2 DeleteDeviceModeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceModeVirtualDatapointHandler)2 DeleteDeviceVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceVirtualDatapointHandler)2