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.homematic.internal.discovery;
15 import static org.openhab.binding.homematic.internal.HomematicBindingConstants.THING_TYPE_BRIDGE;
17 import java.util.HashMap;
21 import org.jupnp.model.meta.DeviceDetails;
22 import org.jupnp.model.meta.RemoteDevice;
23 import org.openhab.core.config.discovery.DiscoveryResult;
24 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
25 import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant;
26 import org.openhab.core.thing.ThingTypeUID;
27 import org.openhab.core.thing.ThingUID;
28 import org.osgi.service.component.annotations.Component;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * The {@link HomegearDiscoveryParticipant} is responsible for discovering new Homegear gateways on the network.
35 * @author Gerhard Riegler - Initial contribution
38 public class HomegearDiscoveryParticipant implements UpnpDiscoveryParticipant {
39 private final Logger logger = LoggerFactory.getLogger(HomegearDiscoveryParticipant.class);
42 public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
43 return Set.of(THING_TYPE_BRIDGE);
47 public DiscoveryResult createResult(RemoteDevice device) {
48 ThingUID uid = getThingUID(device);
50 DeviceDetails details = device.getDetails();
51 Map<String, Object> properties = new HashMap<>(3);
52 properties.put("gatewayAddress", details.getBaseURL().getHost());
54 logger.debug("Discovered a Homegear gateway with serial number '{}'", details.getSerialNumber());
55 return DiscoveryResultBuilder.create(uid).withProperties(properties)
56 .withLabel(details.getModelDetails().getModelNumber()).build();
62 public ThingUID getThingUID(RemoteDevice device) {
63 DeviceDetails details = device.getDetails();
64 String modelName = details.getModelDetails().getModelName();
65 if ("HOMEGEAR".equalsIgnoreCase(modelName)) {
66 return new ThingUID(THING_TYPE_BRIDGE, details.getSerialNumber());