Search in sources :

Example 11 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.

the class DeviceHandler method checkOutputChannel.

private void checkOutputChannel() {
    if (device == null) {
        logger.debug("Can not load a channel without a device!");
        return;
    }
    // if the device have no output channel or it is disabled all output channels will be deleted
    if (!device.isDeviceWithOutput()) {
        loadOutputChannel(null, null);
    }
    String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(device.getFunctionalColorGroup(), device.getOutputMode());
    logger.debug("load channel: typeID={}, itemType={}", DsChannelTypeProvider.getOutputChannelTypeID(device.getFunctionalColorGroup(), device.getOutputMode()), DsChannelTypeProvider.getItemType(channelTypeID));
    if (channelTypeID != null && (currentChannel == null || currentChannel != channelTypeID)) {
        loadOutputChannel(new ChannelTypeUID(BINDING_ID, channelTypeID), DsChannelTypeProvider.getItemType(channelTypeID));
    }
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID)

Example 12 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.

the class DeviceHandler method onDeviceAdded.

@Override
public synchronized void onDeviceAdded(GeneralDeviceInformation device) {
    if (device instanceof Device) {
        this.device = (Device) device;
        if (this.device.isPresent()) {
            ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
            updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
            logger.debug("Set status to {}", getThing().getStatus());
            // load scene configurations persistently into the thing
            for (Short i : this.device.getSavedScenes()) {
                onSceneConfigAdded(i);
            }
            logger.debug("Load saved scene specification into device");
            this.device.saveConfigSceneSpecificationIntoDevice(getThing().getProperties());
            checkDeviceInfoProperties(this.device);
            // load sensor priorities into the device and load sensor channels of the thing
            if (!this.device.isShade()) {
                loadSensorChannels();
                // check and load output channel of the thing
                checkOutputChannel();
            } else if (this.device.isBlind()) {
                // load channel for set the angle of jalousie devices
                String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(((Device) device).getFunctionalColorGroup(), ((Device) device).getOutputMode());
                loadOutputChannel(new ChannelTypeUID(BINDING_ID, channelTypeID), DsChannelTypeProvider.getItemType(channelTypeID));
            }
            // load first channel values
            onDeviceStateInitial(this.device);
            return;
        }
    }
    onDeviceRemoved(device);
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 13 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID 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)

Example 14 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.

the class ChannelTypeConverter method unmarshalType.

@Override
protected ChannelTypeXmlResult unmarshalType(HierarchicalStreamReader reader, UnmarshallingContext context, Map<String, String> attributes, NodeIterator nodeIterator) throws ConversionException {
    boolean advanced = readBoolean(attributes, "advanced", false);
    boolean system = readBoolean(attributes, "system", false);
    String uid = system ? XmlHelper.getSystemUID(super.getID(attributes)) : super.getUID(attributes, context);
    ChannelTypeUID channelTypeUID = new ChannelTypeUID(uid);
    String itemType = readItemType(nodeIterator);
    String kind = readKind(nodeIterator);
    String label = super.readLabel(nodeIterator);
    String description = super.readDescription(nodeIterator);
    String category = readCategory(nodeIterator);
    Set<String> tags = readTags(nodeIterator);
    StateDescription stateDescription = readStateDescription(nodeIterator);
    EventDescription eventDescription = readEventDescription(nodeIterator);
    Object[] configDescriptionObjects = super.getConfigDescriptionObjects(nodeIterator);
    if (kind == null) {
        // Default for kind is 'state'
        kind = "state";
    }
    ChannelType channelType = new ChannelType(channelTypeUID, advanced, itemType, ChannelKind.parse(kind), label, description, category, tags, stateDescription, eventDescription, (URI) configDescriptionObjects[0]);
    ChannelTypeXmlResult channelTypeXmlResult = new ChannelTypeXmlResult(channelType, (ConfigDescription) configDescriptionObjects[1], system);
    return channelTypeXmlResult;
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) EventDescription(org.eclipse.smarthome.core.types.EventDescription) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) StateDescription(org.eclipse.smarthome.core.types.StateDescription)

Example 15 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.

the class ChannelTypeResource method getLinkableItemTypes.

@GET
@Path("/{channelTypeUID}/linkableItemTypes")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets the item types the given trigger channel type UID can be linked to.", response = String.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class, responseContainer = "Set"), @ApiResponse(code = 204, message = "No content: channel type has no linkable items or is no trigger channel."), @ApiResponse(code = 404, message = "Given channel type UID not found.") })
public Response getLinkableItemTypes(@PathParam("channelTypeUID") @ApiParam(value = "channelTypeUID") String channelTypeUID) {
    ChannelTypeUID ctUID = new ChannelTypeUID(channelTypeUID);
    ChannelType channelType = channelTypeRegistry.getChannelType(ctUID);
    if (channelType == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (channelType.getKind() != ChannelKind.TRIGGER) {
        return Response.noContent().build();
    }
    Set<String> result = new HashSet<>();
    for (ProfileType profileType : profileTypeRegistry.getProfileTypes()) {
        if (profileType instanceof TriggerProfileType) {
            if (((TriggerProfileType) profileType).getSupportedChannelTypeUIDs().contains(ctUID)) {
                for (String itemType : profileType.getSupportedItemTypes()) {
                    result.add(itemType);
                }
            }
        }
    }
    if (result.isEmpty()) {
        return Response.noContent().build();
    }
    return Response.ok(result).build();
}
Also used : ProfileType(org.eclipse.smarthome.core.thing.profiles.ProfileType) TriggerProfileType(org.eclipse.smarthome.core.thing.profiles.TriggerProfileType) TriggerProfileType(org.eclipse.smarthome.core.thing.profiles.TriggerProfileType) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)16 ChannelType (org.eclipse.smarthome.core.thing.type.ChannelType)9 StateDescription (org.eclipse.smarthome.core.types.StateDescription)4 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MeteringTypeEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum)2 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)2 Channel (org.eclipse.smarthome.core.thing.Channel)2 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)2 TriggerProfileType (org.eclipse.smarthome.core.thing.profiles.TriggerProfileType)2 ChannelTypeProvider (org.eclipse.smarthome.core.thing.type.ChannelTypeProvider)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1