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.generacmobilelink.internal.discovery;
15 import static org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.generacmobilelink.internal.dto.Apparatus;
21 import org.openhab.core.config.discovery.AbstractDiscoveryService;
22 import org.openhab.core.config.discovery.DiscoveryResult;
23 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
24 import org.openhab.core.thing.Thing;
25 import org.openhab.core.thing.ThingTypeUID;
26 import org.openhab.core.thing.ThingUID;
29 * The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering device things
31 * @author Dan Cunningham - Initial contribution
34 public class GeneracMobileLinkDiscoveryService extends AbstractDiscoveryService {
35 private static final Set<ThingTypeUID> SUPPORTED_DISCOVERY_THING_TYPES_UIDS = Set.of(THING_TYPE_GENERATOR);
37 public GeneracMobileLinkDiscoveryService() {
38 super(SUPPORTED_DISCOVERY_THING_TYPES_UIDS, 0);
42 public Set<ThingTypeUID> getSupportedThingTypes() {
43 return SUPPORTED_DISCOVERY_THING_TYPES_UIDS;
47 public void startScan() {
51 public boolean isBackgroundDiscoveryEnabled() {
55 public void generatorDiscovered(Apparatus apparatus, ThingUID bridgeUID) {
56 DiscoveryResult result = DiscoveryResultBuilder
57 .create(new ThingUID(THING_TYPE_GENERATOR, bridgeUID, String.valueOf(apparatus.apparatusId)))
58 .withLabel("MobileLink Generator " + apparatus.name)
59 .withProperty(Thing.PROPERTY_SERIAL_NUMBER, String.valueOf(apparatus.serialNumber))
60 .withProperty(PROPERTY_GENERATOR_ID, String.valueOf(apparatus.apparatusId))
61 .withRepresentationProperty(PROPERTY_GENERATOR_ID).withBridge(bridgeUID).build();
62 thingDiscovered(result);