Search in sources :

Example 1 with DsAPI

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.serverconnection.DsAPI in project smarthome by eclipse.

the class BridgeMDNSDiscoveryParticipant method getThingUID.

@Override
public ThingUID getThingUID(ServiceInfo service) {
    if (service.getApplication().contains("dssweb")) {
        String hostAddress = service.getName() + "." + service.getDomain() + ".";
        DsAPI digitalSTROMClient = new DsAPIImpl(hostAddress, Config.DEFAULT_CONNECTION_TIMEOUT, Config.DEFAULT_READ_TIMEOUT, true);
        Map<String, String> dsidMap = digitalSTROMClient.getDSID(null);
        String dSID = null;
        if (dsidMap != null) {
            dSID = dsidMap.get(JSONApiResponseKeysEnum.DSID.getKey());
        }
        if (StringUtils.isNotBlank(dSID)) {
            return new ThingUID(DigitalSTROMBindingConstants.THING_TYPE_DSS_BRIDGE, dSID);
        } else {
            logger.error("Can't get server dSID to generate thing UID. Please add the server manually.");
        }
    }
    return null;
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) DsAPI(org.eclipse.smarthome.binding.digitalstrom.internal.lib.serverconnection.DsAPI) DsAPIImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.serverconnection.impl.DsAPIImpl)

Aggregations

DsAPI (org.eclipse.smarthome.binding.digitalstrom.internal.lib.serverconnection.DsAPI)1 DsAPIImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.serverconnection.impl.DsAPIImpl)1 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)1