public static final String NORMALIZE_ID_REGEX = "[^a-zA-Z0-9_]";
- //
+ public static final String DISCOVERY_LABEL_PATTERN = "Philips Hue (%s)";
+
+ // I18N string references
public static final String TEXT_OFFLINE_COMMUNICATION_ERROR = "@text/offline.communication-error";
public static final String TEXT_OFFLINE_CONFIGURATION_ERROR_INVALID_SSL_CERIFICATE = "@text/offline.conf-error-invalid-ssl-certificate";
if (uid != null) {
String host = service.getHostAddresses()[0];
String id = service.getPropertyString(MDNS_PROPERTY_BRIDGE_ID);
- String friendlyName = String.format("%s (%s)", service.getName(), host);
+ String friendlyName = String.format(DISCOVERY_LABEL_PATTERN, host);
return DiscoveryResultBuilder.create(uid) //
.withProperties(Map.of( //
HOST, host, //
@NonNullByDefault
public class HueBridgeNupnpDiscovery extends AbstractDiscoveryService {
- private static final String MODEL_NAME_PHILIPS_HUE = "\"name\":\"Philips hue\"";
protected static final String BRIDGE_INDICATOR = "fffe";
+
+ private static final String MODEL_NAME_PHILIPS_HUE = "\"name\":\"Philips hue\"";
private static final String DISCOVERY_URL = "https://discovery.meethue.com/";
- protected static final String LABEL_PATTERN = "Philips Hue (%s)";
private static final String CONFIG_URL_PATTERN = "http://%s/api/0/config";
private static final int REQUEST_TIMEOUT = 5000;
private static final int DISCOVERY_TIMEOUT = 10;
.withProperties(Map.of( //
HOST, host, //
Thing.PROPERTY_SERIAL_NUMBER, serialNumber)) //
- .withLabel(String.format(LABEL_PATTERN, host)) //
+ .withLabel(String.format(DISCOVERY_LABEL_PATTERN, host)) //
.withRepresentationProperty(Thing.PROPERTY_SERIAL_NUMBER) //
.build();
thingDiscovered(result);
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.openhab.binding.hue.internal.HueBindingConstants;
import org.openhab.core.config.discovery.DiscoveryListener;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryService;
private void checkDiscoveryResult(DiscoveryResult result, String expIp, String expSn) {
assertThat(result.getBridgeUID(), nullValue());
- assertThat(result.getLabel(), is(String.format(HueBridgeNupnpDiscovery.LABEL_PATTERN, expIp)));
+ assertThat(result.getLabel(), is(String.format(HueBindingConstants.DISCOVERY_LABEL_PATTERN, expIp)));
assertThat(result.getProperties().get("ipAddress"), is(expIp));
assertThat(result.getProperties().get("serialNumber"), is(expSn));
}