forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DWDPollenflug] Small code improvments (openhab#7395)
* [DWDPollenflug] Small refactoring and improvements * [DWDPollenflug] Added DiscoveryService Signed-off-by: Johannes DerOetzi Ott <info@johannes-ott.net>
- Loading branch information
Showing
9 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...a/org/openhab/binding/dwdpollenflug/internal/discovery/DWDPollenflugDiscoveryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.dwdpollenflug.internal.discovery; | ||
|
||
import static org.openhab.binding.dwdpollenflug.internal.DWDPollenflugBindingConstants.*; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService; | ||
import org.eclipse.smarthome.config.discovery.DiscoveryResult; | ||
import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; | ||
import org.eclipse.smarthome.config.discovery.DiscoveryService; | ||
import org.eclipse.smarthome.core.thing.ThingUID; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link DWDPollenflugDiscoveryService} create a default bridge thing. | ||
* | ||
* @author Johannes Ott - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
@Component(service = DiscoveryService.class, immediate = true, configurationPid = "discovery.dwdpollenflug") | ||
public class DWDPollenflugDiscoveryService extends AbstractDiscoveryService { | ||
private static final ThingUID BRIDGE_THING_UID = new ThingUID(THING_TYPE_BRIDGE, DWD); | ||
private static final int DISCOVER_TIMEOUT_SECONDS = 2; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(DWDPollenflugDiscoveryService.class); | ||
|
||
public DWDPollenflugDiscoveryService() throws IllegalArgumentException { | ||
super(SUPPORTED_THING_TYPES_UIDS, DISCOVER_TIMEOUT_SECONDS, true); | ||
} | ||
|
||
@Override | ||
protected void startScan() { | ||
logger.debug("Manual DWDPollenflug discovery scan."); | ||
addBridge(); | ||
} | ||
|
||
@Override | ||
protected void startBackgroundDiscovery() { | ||
logger.debug("Background DWDPollenflug discovery scan."); | ||
addBridge(); | ||
} | ||
|
||
private void addBridge() { | ||
// @formatter:off | ||
DiscoveryResult bridge = DiscoveryResultBuilder | ||
.create(BRIDGE_THING_UID) | ||
.withLabel(BRIDGE_LABEL) | ||
.build(); | ||
// @formatter:on | ||
|
||
thingDiscovered(bridge); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters