Search in sources :

Example 1 with MeteringTypeEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum in project smarthome by eclipse.

the class CircuitHandler method channelLinked.

@Override
public void channelLinked(ChannelUID channelUID) {
    if (circuit != null) {
        MeteringTypeEnum meteringType = DsChannelTypeProvider.getMeteringType(channelUID.getId());
        double val = circuit.getMeteringValue(meteringType, MeteringUnitsEnum.WH);
        if (val > -1) {
            if (meteringType.equals(MeteringTypeEnum.ENERGY)) {
                updateState(channelUID, new DecimalType(val * 0.001));
            } else {
                updateState(channelUID, new DecimalType(val));
            }
        }
    }
}
Also used : MeteringTypeEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType)

Example 2 with MeteringTypeEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum in project smarthome by eclipse.

the class DsDeviceThingTypeProvider method getThingType.

@Override
public ThingType getThingType(ThingTypeUID thingTypeUID, Locale locale) {
    try {
        SupportedThingTypes supportedThingType = SupportedThingTypes.valueOf(thingTypeUID.getId());
        ThingTypeBuilder thingTypeBuilder = ThingTypeBuilder.instance(thingTypeUID, getLabelText(thingTypeUID.getId(), locale)).withSupportedBridgeTypeUIDs(Arrays.asList(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE.getAsString())).withDescription(getDescText(thingTypeUID.getId(), locale));
        try {
            if (supportedThingType.havePowerSensors) {
                thingTypeBuilder.withConfigDescriptionURI(new URI(DEVICE_WITH_POWER_SENSORS));
            } else {
                thingTypeBuilder.withConfigDescriptionURI(new URI(DEVICE_WITHOUT_POWER_SENSORS));
            }
        } catch (URISyntaxException e) {
            logger.debug("An URISyntaxException occurred: ", e);
        }
        if (SupportedThingTypes.GR.equals(supportedThingType)) {
            thingTypeBuilder.withChannelDefinitions(Arrays.asList(new ChannelDefinition(DsChannelTypeProvider.SHADE, new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, DsChannelTypeProvider.SHADE))));
        }
        if (SupportedThingTypes.circuit.equals(supportedThingType)) {
            List<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>(3);
            for (MeteringTypeEnum meteringType : MeteringTypeEnum.values()) {
                channelDefinitions.add(new ChannelDefinition(DsChannelTypeProvider.getMeteringChannelID(meteringType, MeteringUnitsEnum.WH, false), new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, DsChannelTypeProvider.getMeteringChannelID(meteringType, MeteringUnitsEnum.WH, false))));
            }
            thingTypeBuilder.withChannelDefinitions(channelDefinitions);
        }
        return thingTypeBuilder.build();
    } catch (IllegalArgumentException e) {
    // ignore
    }
    return null;
}
Also used : ThingTypeBuilder(org.eclipse.smarthome.core.thing.type.ThingTypeBuilder) MeteringTypeEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelDefinition(org.eclipse.smarthome.core.thing.type.ChannelDefinition) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 3 with MeteringTypeEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum in project smarthome by eclipse.

the class DsChannelTypeProvider method getChannelTypes.

@Override
public Collection<ChannelType> getChannelTypes(Locale locale) {
    List<ChannelType> channelTypeList = new LinkedList<ChannelType>();
    for (String channelTypeId : supportedOutputChannelTypes) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, channelTypeId), locale));
    }
    for (SensorEnum sensorType : SensorEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(sensorType)), locale));
    }
    for (MeteringTypeEnum meteringType : MeteringTypeEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(meteringType, MeteringUnitsEnum.WH)), locale));
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(TOTAL_PRE, meteringType, MeteringUnitsEnum.WH)), locale));
    }
    for (DeviceBinarayInputEnum binaryInput : DeviceBinarayInputEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(BINARY_INPUT_PRE, binaryInput)), locale));
    }
    return channelTypeList;
}
Also used : MeteringTypeEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) SensorEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum) DeviceBinarayInputEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) LinkedList(java.util.LinkedList)

Aggregations

MeteringTypeEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum)3 ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 DeviceBinarayInputEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum)1 SensorEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum)1 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)1 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)1 ChannelType (org.eclipse.smarthome.core.thing.type.ChannelType)1 ThingTypeBuilder (org.eclipse.smarthome.core.thing.type.ThingTypeBuilder)1