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.modbus.sunspec.internal.discovery;
15 import static org.openhab.binding.modbus.sunspec.internal.SunSpecConstants.SUPPORTED_THING_TYPES_UIDS;
17 import java.util.HashSet;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.modbus.discovery.ModbusDiscoveryListener;
22 import org.openhab.binding.modbus.discovery.ModbusDiscoveryParticipant;
23 import org.openhab.binding.modbus.handler.EndpointNotInitializedException;
24 import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler;
25 import org.openhab.core.thing.ThingTypeUID;
26 import org.osgi.service.component.annotations.Component;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * Discovery service for sunspec
33 * @author Nagy Attila Gabor - initial contribution
38 public class SunspecDiscoveryParticipant implements ModbusDiscoveryParticipant {
40 private final Logger logger = LoggerFactory.getLogger(SunspecDiscoveryParticipant.class);
43 public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
44 return new HashSet<ThingTypeUID>(SUPPORTED_THING_TYPES_UIDS.values());
48 public void startDiscovery(ModbusEndpointThingHandler handler, ModbusDiscoveryListener listener) {
49 logger.trace("Starting sunspec discovery");
51 new SunspecDiscoveryProcess(handler, listener).detectModel();
52 } catch (EndpointNotInitializedException ex) {
53 logger.debug("Could not start discovery process");
54 listener.discoveryFinished();