Search in sources :

Example 1 with ChannelGroupUID

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;
}
Also used : ChannelGroupUID(org.openhab.core.thing.ChannelGroupUID) Channel(org.openhab.core.thing.Channel) ArrayList(java.util.ArrayList) ThingHandlerCallback(org.openhab.core.thing.binding.ThingHandlerCallback) ChannelBuilder(org.openhab.core.thing.binding.builder.ChannelBuilder)

Example 2 with ChannelGroupUID

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());
    }
}
Also used : ChannelGroupUID(org.openhab.core.thing.ChannelGroupUID) ChannelUID(org.openhab.core.thing.ChannelUID)

Example 3 with ChannelGroupUID

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);
    }
}
Also used : ScheduledEvent(org.openhab.binding.hdpowerview.internal.api.responses.ScheduledEvents.ScheduledEvent) ChannelGroupUID(org.openhab.core.thing.ChannelGroupUID) ChannelUID(org.openhab.core.thing.ChannelUID)

Example 4 with ChannelGroupUID

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;
}
Also used : ChannelGroupUID(org.openhab.core.thing.ChannelGroupUID) Channel(org.openhab.core.thing.Channel) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) SceneGroupChannelBuilder(org.openhab.binding.hdpowerview.internal.builders.SceneGroupChannelBuilder) SceneCollection(org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections.SceneCollection)

Example 5 with ChannelGroupUID

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);
        }
    }
}
Also used : ChannelGroupUID(org.openhab.core.thing.ChannelGroupUID) ChannelUID(org.openhab.core.thing.ChannelUID)

Aggregations

ChannelGroupUID (org.openhab.core.thing.ChannelGroupUID)14 Channel (org.openhab.core.thing.Channel)9 ChannelUID (org.openhab.core.thing.ChannelUID)7 ArrayList (java.util.ArrayList)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 Scene (org.openhab.binding.hdpowerview.internal.api.responses.Scenes.Scene)2 ScheduledEvent (org.openhab.binding.hdpowerview.internal.api.responses.ScheduledEvents.ScheduledEvent)2 ThingUID (org.openhab.core.thing.ThingUID)2 ThingHandlerCallback (org.openhab.core.thing.binding.ThingHandlerCallback)2 ChannelBuilder (org.openhab.core.thing.binding.builder.ChannelBuilder)2 SceneCollection (org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections.SceneCollection)1 AutomationChannelBuilder (org.openhab.binding.hdpowerview.internal.builders.AutomationChannelBuilder)1 SceneChannelBuilder (org.openhab.binding.hdpowerview.internal.builders.SceneChannelBuilder)1 SceneGroupChannelBuilder (org.openhab.binding.hdpowerview.internal.builders.SceneGroupChannelBuilder)1 OnOffValue (org.openhab.binding.mqtt.generic.values.OnOffValue)1 Value (org.openhab.binding.mqtt.generic.values.Value)1 MqttBrokerConnection (org.openhab.core.io.transport.mqtt.MqttBrokerConnection)1 ChannelTypeUID (org.openhab.core.thing.type.ChannelTypeUID)1 Command (org.openhab.core.types.Command)1