use of org.openhab.core.thing.ChannelGroupUID in project openhab-addons by openhab.
the class DarkSkyWeatherAndForecastHandler method createChannelsForGroup.
/**
* Creates all {@link Channel}s for the given {@link ChannelGroupTypeUID}.
*
* @param channelGroupId the channel group id
* @param channelGroupTypeUID the {@link ChannelGroupTypeUID}
* @return a list of all {@link Channel}s for the channel group
*/
private List<Channel> createChannelsForGroup(String channelGroupId, ChannelGroupTypeUID channelGroupTypeUID) {
logger.debug("Building channel group '{}' for thing '{}'.", channelGroupId, getThing().getUID());
List<Channel> channels = new ArrayList<>();
ThingHandlerCallback callback = getCallback();
if (callback != null) {
for (ChannelBuilder channelBuilder : callback.createChannelBuilders(new ChannelGroupUID(getThing().getUID(), channelGroupId), channelGroupTypeUID)) {
Channel newChannel = channelBuilder.build(), existingChannel = getThing().getChannel(newChannel.getUID().getId());
if (existingChannel != null) {
logger.trace("Thing '{}' already has an existing channel '{}'. Omit adding new channel '{}'.", getThing().getUID(), existingChannel.getUID(), newChannel.getUID());
continue;
}
channels.add(newChannel);
}
}
return channels;
}
use of org.openhab.core.thing.ChannelGroupUID in project openhab-addons by openhab.
the class DanfossAirUnitHandler method removeDeprecatedChannels.
private void removeDeprecatedChannels() {
ChannelGroupUID mainChannelGroupUid = new ChannelGroupUID(thing.getUID(), ChannelGroup.MAIN.getGroupName());
ChannelUID manualFanSpeedChannelUid = new ChannelUID(mainChannelGroupUid, Channel.CHANNEL_MANUAL_FAN_SPEED.getChannelName());
if (this.isLinked(manualFanSpeedChannelUid)) {
ChannelUID manualFanStepChannelUid = new ChannelUID(mainChannelGroupUid, Channel.CHANNEL_MANUAL_FAN_STEP.getChannelName());
logger.warn("Channel '{}' is deprecated, please use '{}' instead.", manualFanSpeedChannelUid, manualFanStepChannelUid);
} else {
logger.debug("Removing deprecated unlinked channel '{}'.", manualFanSpeedChannelUid);
updateThing(editThing().withoutChannel(manualFanSpeedChannelUid).build());
}
}
use of org.openhab.core.thing.ChannelGroupUID in project openhab-addons by openhab.
the class HDPowerViewHubHandler method updateAutomationStates.
private void updateAutomationStates(List<ScheduledEvent> scheduledEvents) {
ChannelGroupUID channelGroupUid = new ChannelGroupUID(thing.getUID(), HDPowerViewBindingConstants.CHANNEL_GROUP_AUTOMATIONS);
for (ScheduledEvent scheduledEvent : scheduledEvents) {
String scheduledEventId = Integer.toString(scheduledEvent.id);
ChannelUID channelUid = new ChannelUID(channelGroupUid, scheduledEventId);
updateState(channelUid, scheduledEvent.enabled ? OnOffType.ON : OnOffType.OFF);
}
}
use of org.openhab.core.thing.ChannelGroupUID in project openhab-addons by openhab.
the class HDPowerViewHubHandler method updateSceneGroupChannels.
private List<SceneCollection> updateSceneGroupChannels() throws HubInvalidResponseException, HubProcessingException, HubMaintenanceException {
List<SceneCollection> sceneCollections = fetchSceneCollections();
if (sceneCollections.size() == sceneCollectionCache.size() && sceneCollectionCache.containsAll(sceneCollections)) {
// Duplicates are not allowed. Reordering is not supported.
logger.debug("Preserving scene group channels, no changes detected");
return sceneCollections;
}
logger.debug("Updating all scene group channels, changes detected");
sceneCollectionCache = new CopyOnWriteArrayList<SceneCollection>(sceneCollections);
List<Channel> allChannels = new ArrayList<>(getThing().getChannels());
allChannels.removeIf(c -> HDPowerViewBindingConstants.CHANNEL_GROUP_SCENE_GROUPS.equals(c.getUID().getGroupId()));
SceneGroupChannelBuilder channelBuilder = SceneGroupChannelBuilder.create(this.translationProvider, new ChannelGroupUID(thing.getUID(), HDPowerViewBindingConstants.CHANNEL_GROUP_SCENE_GROUPS)).withSceneCollections(sceneCollections).withChannels(allChannels);
updateThing(editThing().withChannels(channelBuilder.build()).build());
return sceneCollections;
}
use of org.openhab.core.thing.ChannelGroupUID in project openhab-addons by openhab.
the class EventFilterHandler method generateExpectedChannelList.
/**
* Generates a list of channel sets according to the required amount.
*
* @param resultCount The required amount of results.
*/
private void generateExpectedChannelList(int resultCount) {
synchronized (resultChannels) {
if (resultChannels.size() == resultCount) {
return;
}
resultChannels.clear();
for (int position = 0; position < resultCount; position++) {
ChannelGroupUID currentGroup = new ChannelGroupUID(getThing().getUID(), RESULT_GROUP_ID_PREFIX + position);
ResultChannelSet current = new ResultChannelSet(currentGroup, new ChannelUID(currentGroup, RESULT_BEGIN_ID), new ChannelUID(currentGroup, RESULT_END_ID), new ChannelUID(currentGroup, RESULT_TITLE_ID));
resultChannels.add(current);
}
}
}
Aggregations