2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.elroconnects.internal;
15 import java.util.Locale;
17 import java.util.concurrent.ConcurrentHashMap;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.thing.Channel;
22 import org.openhab.core.thing.ChannelUID;
23 import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
24 import org.openhab.core.types.StateDescription;
25 import org.osgi.service.component.annotations.Component;
26 import org.osgi.service.component.annotations.Deactivate;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
32 * @author Mark Herwege - Initial contribution
34 @Component(service = { DynamicStateDescriptionProvider.class, ElroConnectsDynamicStateDescriptionProvider.class })
36 public class ElroConnectsDynamicStateDescriptionProvider implements DynamicStateDescriptionProvider {
38 private final Logger logger = LoggerFactory.getLogger(ElroConnectsDynamicStateDescriptionProvider.class);
40 private final Map<ChannelUID, @Nullable StateDescription> descriptions = new ConcurrentHashMap<>();
42 public void setDescription(ChannelUID channelUID, @Nullable StateDescription description) {
43 logger.debug("Adding command description for channel {}", channelUID);
44 descriptions.put(channelUID, description);
47 public void removeAllDescriptions() {
48 logger.debug("Removing all command descriptions");
53 public @Nullable StateDescription getStateDescription(Channel channel,
54 @Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
55 return descriptions.get(channel.getUID());
59 public void deactivate() {