2 * Copyright (c) 2010-2024 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.electroluxair.internal.discovery;
15 import static org.openhab.binding.electroluxair.internal.ElectroluxAirBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.electroluxair.internal.ElectroluxAirConfiguration;
19 import org.openhab.binding.electroluxair.internal.handler.ElectroluxAirBridgeHandler;
20 import org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService;
21 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
22 import org.openhab.core.thing.ThingUID;
23 import org.osgi.service.component.annotations.Component;
24 import org.osgi.service.component.annotations.ServiceScope;
27 * The {@link ElectroluxAirDiscoveryService} searches for available
28 * Electrolux Pure A9 discoverable through Electrolux Delta API.
30 * @author Jan Gustafsson - Initial contribution
32 @Component(scope = ServiceScope.PROTOTYPE, service = ElectroluxAirDiscoveryService.class)
34 public class ElectroluxAirDiscoveryService extends AbstractThingHandlerDiscoveryService<ElectroluxAirBridgeHandler> {
35 private static final int SEARCH_TIME = 2;
37 public ElectroluxAirDiscoveryService() {
38 super(ElectroluxAirBridgeHandler.class, SUPPORTED_THING_TYPES_UIDS, SEARCH_TIME);
42 protected void startScan() {
43 ThingUID bridgeUID = thingHandler.getThing().getUID();
44 thingHandler.getElectroluxAirThings().entrySet().stream().forEach(thing -> {
45 thingDiscovered(DiscoveryResultBuilder
46 .create(new ThingUID(THING_TYPE_ELECTROLUX_PURE_A9, bridgeUID, thing.getKey()))
47 .withLabel("Electrolux Pure A9").withBridge(bridgeUID)
48 .withProperty(ElectroluxAirConfiguration.DEVICE_ID_LABEL, thing.getKey())
49 .withRepresentationProperty(ElectroluxAirConfiguration.DEVICE_ID_LABEL).build());