private void checkDuplicateChannelLabels(List<Channel> channels) { channels.stream().collect(Collectors.groupingBy(Channel::getLabel)) .values().stream().filter(list -> list.size() > 1).flatMap(List::stream).forEach(channel -> { String serviceUUID = channel.getProperties().get(BluetoothBindingConstants.PROPERTY_SERVICE_UUID); if (serviceUUID != null) { Service service = getParser().getService(serviceUUID); channels.remove(channel); channels.add(ChannelBuilder.create(channel.getUID(), channel.getAcceptedItemType()) .withType(channel.getChannelTypeUID()) .withProperties(channel.getProperties()) .withLabel(service.getName() + " / " + channel.getLabel()) .build()); } }); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclTemperatureMeasurementCluster.CLUSTER_ID) == null) { logger.trace("{}: Temperature measurement cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_TEMPERATURE_VALUE), ZigBeeBindingConstants.ITEM_TYPE_NUMBER_TEMPERATURE) .withType(ZigBeeBindingConstants.CHANNEL_TEMPERATURE_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_TEMPERATURE_VALUE) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclOccupancySensingCluster.CLUSTER_ID) == null) { logger.trace("{}: Occupancy sensing cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_OCCUPANCY_SENSOR), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_OCCUPANCY_SENSOR) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_OCCUPANCY_SENSOR) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclRelativeHumidityMeasurementCluster.CLUSTER_ID) == null) { logger.trace("{}: Relative humidity cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_HUMIDITY_VALUE), ZigBeeBindingConstants.ITEM_TYPE_NUMBER) .withType(ZigBeeBindingConstants.CHANNEL_HUMIDITY_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_HUMIDITY_VALUE) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclIlluminanceMeasurementCluster.CLUSTER_ID) == null) { logger.trace("{}: Illuminance measurement cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_ILLUMINANCE_VALUE), ZigBeeBindingConstants.ITEM_TYPE_NUMBER) .withType(ZigBeeBindingConstants.CHANNEL_ILLUMINANCE_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_ILLUMINANCE_VALUE) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclPressureMeasurementCluster.CLUSTER_ID) == null) { logger.trace("{}: Pressure measurement cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_PRESSURE_VALUE), ZigBeeBindingConstants.ITEM_TYPE_NUMBER_PRESSURE) .withType(ZigBeeBindingConstants.CHANNEL_PRESSURE_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_PRESSURE_VALUE) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclLevelControlCluster.CLUSTER_ID) == null) { logger.trace("{}: Level control cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_SWITCH_LEVEL), ZigBeeBindingConstants.ITEM_TYPE_DIMMER) .withType(ZigBeeBindingConstants.CHANNEL_SWITCH_LEVEL) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_SWITCH_LEVEL).withProperties(createProperties(endpoint)) .build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclDoorLockCluster.CLUSTER_ID) == null) { logger.trace("{}: Door lock cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_DOORLOCK_STATE), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_DOORLOCK_STATE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_DOORLOCK_STATE) .withProperties(createProperties(endpoint)).build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID) == null && endpoint.getOutputCluster(ZclOnOffCluster.CLUSTER_ID) == null) { logger.trace("{}: OnOff cluster not found", endpoint.getIeeeAddress()); return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_SWITCH_ONOFF), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_SWITCH_ONOFF) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_SWITCH_ONOFF).withProperties(createProperties(endpoint)) .build(); }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (hasIasZoneInputCluster(endpoint)) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_TAMPER), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_TAMPER) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_TAMPER) .withProperties(createProperties(endpoint)).build(); } else { return null; } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.CO_SENSOR)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_CODETECTOR), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_CODETECTOR) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_CODETECTOR) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.WATER_SENSOR)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_WATERSENSOR), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_WATERSENSOR) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_WATERSENSOR) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.MOTION_SENSOR)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_MOTIONPRESENCE), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_MOTIONPRESENCE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_MOTIONPRESENCE) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.MOTION_SENSOR)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_MOTIONINTRUSION), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_MOTIONINTRUSION) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_MOTIONINTRUSION) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.FIRE_SENSOR)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_FIREINDICATION), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_FIREINDICATION) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_FIREINDICATION) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (hasIasZoneInputCluster(endpoint)) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_LOWBATTERY), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_LOWBATTERY) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_LOWBATTERY) .withProperties(createProperties(endpoint)).build(); } else { return null; } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.CONTACT_SWITCH)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_CONTACTPORTAL1), ZigBeeBindingConstants.ITEM_TYPE_CONTACT) .withType(ZigBeeBindingConstants.CHANNEL_IAS_CONTACTPORTAL1) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_CONTACTPORTAL1) .withProperties(createProperties(endpoint)).build(); } }
@Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (!supportsIasChannel(endpoint, ZoneTypeEnum.STANDARD_CIE)) { return null; } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_IAS_STANDARDCIESYSTEM), ZigBeeBindingConstants.ITEM_TYPE_SWITCH) .withType(ZigBeeBindingConstants.CHANNEL_IAS_STANDARDCIESYSTEM) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_IAS_STANDARDCIESYSTEM) .withProperties(createProperties(endpoint)).build(); } }
protected Channel buildBinaryChannel(URL characteristicURL, boolean advanced, boolean readOnly) { ChannelUID channelUID = new ChannelUID(handler.getThing().getUID(), BluetoothUtils.getChannelUID(characteristicURL)); String channelType = getChannelType(advanced, readOnly); ChannelTypeUID channelTypeUID = new ChannelTypeUID(BluetoothBindingConstants.BINDING_ID, channelType); return ChannelBuilder.create(channelUID, "String") .withType(channelTypeUID) .withLabel(characteristicURL.getCharacteristicUUID()) .build(); }
/** * Maps channel DTO into channel object. * * @param channelDTO the channel DTO * @return the channel object */ public static Channel map(ChannelDTO channelDTO) { ChannelUID channelUID = new ChannelUID(channelDTO.uid); ChannelTypeUID channelTypeUID = new ChannelTypeUID(channelDTO.channelTypeUID); return ChannelBuilder.create(channelUID, channelDTO.itemType) .withConfiguration(new Configuration(channelDTO.configuration)).withLabel(channelDTO.label) .withDescription(channelDTO.description).withProperties(channelDTO.properties).withType(channelTypeUID) .withDefaultTags(channelDTO.defaultTags).withKind(ChannelKind.parse(channelDTO.kind)).build(); } }