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));
}
}
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);
}
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;
}
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;
}
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();
}
Aggregations