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