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.wundergroundupdatereceiver.internal;
15 import static org.openhab.binding.wundergroundupdatereceiver.internal.WundergroundUpdateReceiverBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.Channel;
20 import org.openhab.core.thing.profiles.ProfileAdvisor;
21 import org.openhab.core.thing.profiles.ProfileTypeUID;
22 import org.openhab.core.thing.profiles.SystemProfiles;
23 import org.openhab.core.thing.type.ChannelType;
24 import org.openhab.core.thing.type.ChannelTypeUID;
25 import org.osgi.service.component.annotations.Component;
28 * The {@link WundergroundUpdateReceiverProfileAdvisor} suggests the default profile for
29 * all channels except last updated.
31 * @author Daniel Demus - Initial contribution
35 public class WundergroundUpdateReceiverProfileAdvisor implements ProfileAdvisor {
38 public @Nullable ProfileTypeUID getSuggestedProfileTypeUID(Channel channel, @Nullable String itemType) {
39 return getSuggestedProfileTypeUID(channel.getChannelTypeUID());
43 public @Nullable ProfileTypeUID getSuggestedProfileTypeUID(ChannelType channelType, @Nullable String itemType) {
44 return getSuggestedProfileTypeUID(channelType.getUID());
47 private @Nullable ProfileTypeUID getSuggestedProfileTypeUID(@Nullable ChannelTypeUID channelTypeUID) {
48 if (channelTypeUID == null || !channelTypeUID.getBindingId().equals(BINDING_ID)) {
51 if (LAST_RECEIVED_DATETIME_CHANNELTYPEUID.equals(channelTypeUID)) {
52 return SystemProfiles.TIMESTAMP_UPDATE;
54 return SystemProfiles.DEFAULT;