@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; } }
/** * 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(); } }
ChannelBuilder channel = ChannelBuilder.create(_channelUID, itemType).withKind(parsedKind).withConfiguration(configuration).withType(channelTypeUID).withLabel(label).withAutoUpdatePolicy(autoUpdatePolicy); Channel _build = channel.build(); channels.add(_build); String _id = it.getId(); ChannelUID _channelUID = new ChannelUID(thingTypeUID, thingUID, _id); Channel _build = ChannelBuilder.create(_channelUID, channelType.getItemType()).withType(it.getChannelTypeUID()).withAutoUpdatePolicy(channelType.getAutoUpdatePolicy()).build(); channels.add(_build); } else {
static ChannelBuilder createChannelBuilder(ChannelUID channelUID, ChannelType channelType, ConfigDescriptionRegistry configDescriptionRegistry) { ChannelBuilder channelBuilder = ChannelBuilder.create(channelUID, channelType.getItemType()) // .withType(channelType.getUID()) // .withDefaultTags(channelType.getTags()) // .withKind(channelType.getKind()) // .withLabel(channelType.getLabel()) // .withAutoUpdatePolicy(channelType.getAutoUpdatePolicy()); channelBuilder = channelBuilder.withDescription(description); channelBuilder = channelBuilder.withConfiguration(config);
private static Channel createChannel(ChannelDefinition channelDefinition, ThingUID thingUID, String groupId, ConfigDescriptionRegistry configDescriptionRegistry) { ChannelType type = withChannelTypeRegistry(channelTypeRegistry -> { return (channelTypeRegistry != null) ? channelTypeRegistry.getChannelType(channelDefinition.getChannelTypeUID()) : null; }); if (type == null) { logger.warn( "Could not create channel '{}' for thing type '{}', because channel type '{}' could not be found.", channelDefinition.getId(), thingUID, channelDefinition.getChannelTypeUID()); return null; } ChannelUID channelUID = new ChannelUID(thingUID, groupId, channelDefinition.getId()); ChannelBuilder channelBuilder = createChannelBuilder(channelUID, type, configDescriptionRegistry); // If we want to override the label, add it... final String label = channelDefinition.getLabel(); if (label != null) { channelBuilder = channelBuilder.withLabel(label); } // If we want to override the description, add it... final String description = channelDefinition.getDescription(); if (description != null) { channelBuilder = channelBuilder.withDescription(description); } channelBuilder = channelBuilder.withProperties(channelDefinition.getProperties()); return channelBuilder.build(); }
@Override public ChannelBuilder editChannel(Thing thing, ChannelUID channelUID) { Channel channel = thing.getChannel(channelUID.getId()); if (channel == null) { throw new IllegalArgumentException( String.format("Channel '%s' does not exist for thing '%s'", channelUID, thing.getUID())); } return ChannelBuilder.create(channel); }
@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(); } }
/** * Creates a channel builder from the given channel. * * @param channel the channel to be changed * @return channel builder */ public static ChannelBuilder create(Channel channel) { ChannelBuilder channelBuilder = create(channel.getUID(), channel.getAcceptedItemType()) .withConfiguration(channel.getConfiguration()).withDefaultTags(channel.getDefaultTags()) .withKind(channel.getKind()).withProperties(channel.getProperties()) .withType(channel.getChannelTypeUID()); String label = channel.getLabel(); if (label != null) { channelBuilder.withLabel(label); } String description = channel.getDescription(); if (description != null) { channelBuilder.withDescription(description); } return channelBuilder; }
@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.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.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.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(); } }
@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(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(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(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(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(); }