]> git.basschouten.com Git - openhab-addons.git/blob
ce91144df093e9e2b8edcf298cbc908ca7e81c80
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.generacmobilelink.internal.discovery;
14
15 import static org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants.*;
16
17 import java.util.Set;
18
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;
27
28 /**
29  * The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering device things
30  *
31  * @author Dan Cunningham - Initial contribution
32  */
33 @NonNullByDefault
34 public class GeneracMobileLinkDiscoveryService extends AbstractDiscoveryService {
35     private static final Set<ThingTypeUID> SUPPORTED_DISCOVERY_THING_TYPES_UIDS = Set.of(THING_TYPE_GENERATOR);
36
37     public GeneracMobileLinkDiscoveryService() {
38         super(SUPPORTED_DISCOVERY_THING_TYPES_UIDS, 0);
39     }
40
41     @Override
42     public Set<ThingTypeUID> getSupportedThingTypes() {
43         return SUPPORTED_DISCOVERY_THING_TYPES_UIDS;
44     }
45
46     @Override
47     public void startScan() {
48     }
49
50     @Override
51     public boolean isBackgroundDiscoveryEnabled() {
52         return false;
53     }
54
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, apparatus.serialNumber)
60                 .withProperty(PROPERTY_GENERATOR_ID, String.valueOf(apparatus.apparatusId))
61                 .withRepresentationProperty(PROPERTY_GENERATOR_ID).withBridge(bridgeUID).build();
62         thingDiscovered(result);
63     }
64 }