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.dwdpollenflug.internal.discovery;
15 import static org.openhab.binding.dwdpollenflug.internal.DWDPollenflugBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.config.discovery.AbstractDiscoveryService;
19 import org.openhab.core.config.discovery.DiscoveryResult;
20 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
21 import org.openhab.core.config.discovery.DiscoveryService;
22 import org.openhab.core.thing.ThingUID;
23 import org.osgi.service.component.annotations.Component;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * The {@link DWDPollenflugDiscoveryService} create a default bridge thing.
30 * @author Johannes Ott - Initial contribution
33 @Component(service = DiscoveryService.class, configurationPid = "discovery.dwdpollenflug")
34 public class DWDPollenflugDiscoveryService extends AbstractDiscoveryService {
35 private static final ThingUID BRIDGE_THING_UID = new ThingUID(THING_TYPE_BRIDGE, DWD);
36 private static final int DISCOVER_TIMEOUT_SECONDS = 2;
38 private final Logger logger = LoggerFactory.getLogger(DWDPollenflugDiscoveryService.class);
40 public DWDPollenflugDiscoveryService() throws IllegalArgumentException {
41 super(SUPPORTED_THING_TYPES_UIDS, DISCOVER_TIMEOUT_SECONDS, true);
45 protected void startScan() {
46 logger.debug("Manual DWDPollenflug discovery scan.");
51 protected void startBackgroundDiscovery() {
52 logger.debug("Background DWDPollenflug discovery scan.");
56 private void addBridge() {
58 DiscoveryResult bridge = DiscoveryResultBuilder
59 .create(BRIDGE_THING_UID)
60 .withLabel(BRIDGE_LABEL)
64 thingDiscovered(bridge);