[homekit] make usage of mDNS configurable (#10286)
* make usage of mDNS configurable Signed-off-by: Eugen Freiter <freiter@gmx.de>
This commit is contained in:
@@ -145,7 +145,8 @@ public class HomekitImpl implements Homekit {
|
||||
HomekitSettings oldSettings = settings;
|
||||
settings = processConfig(config);
|
||||
changeListener.updateSettings(settings);
|
||||
if (!oldSettings.networkInterface.equals(settings.networkInterface) || oldSettings.port != settings.port) {
|
||||
if (!oldSettings.networkInterface.equals(settings.networkInterface) || oldSettings.port != settings.port
|
||||
|| oldSettings.useOHmDNS != settings.useOHmDNS) {
|
||||
// the HomeKit server settings changed. we do a complete re-init
|
||||
stopHomekitServer();
|
||||
startHomekitServer();
|
||||
@@ -205,23 +206,28 @@ public class HomekitImpl implements Homekit {
|
||||
|
||||
private void startHomekitServer() throws IOException {
|
||||
if (homekitServer == null) {
|
||||
if ((settings.networkInterface == null) || (settings.networkInterface.isEmpty())) {
|
||||
logger.trace(
|
||||
"No IP address configured in homekit settings. HomeKit will use the first configured address of openHAB");
|
||||
homekitServer = new HomekitServer(mdnsClient.getClientInstances().iterator().next(), settings.port);
|
||||
} else {
|
||||
networkInterface = InetAddress.getByName(settings.networkInterface);
|
||||
for (JmDNS mdns : mdnsClient.getClientInstances()) {
|
||||
if (mdns.getInetAddress().equals(networkInterface)) {
|
||||
logger.trace("suitable mDNS client for IP {} found. Reusing it.", networkInterface);
|
||||
homekitServer = new HomekitServer(mdns, settings.port);
|
||||
if (settings.useOHmDNS) {
|
||||
if ((settings.networkInterface == null) || (settings.networkInterface.isEmpty())) {
|
||||
logger.trace(
|
||||
"No IP address configured in HomeKit settings. HomeKit will use the first configured address of openHAB");
|
||||
homekitServer = new HomekitServer(mdnsClient.getClientInstances().iterator().next(), settings.port);
|
||||
} else {
|
||||
networkInterface = InetAddress.getByName(settings.networkInterface);
|
||||
for (JmDNS mdns : mdnsClient.getClientInstances()) {
|
||||
if (mdns.getInetAddress().equals(networkInterface)) {
|
||||
logger.trace("Suitable mDNS client for IP {} found and will be used for HomeKit",
|
||||
networkInterface);
|
||||
homekitServer = new HomekitServer(mdns, settings.port);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (homekitServer == null) {
|
||||
logger.trace("Not suitable mDNS client fpr IP {} found. Create new mDNS instance.",
|
||||
networkInterface);
|
||||
homekitServer = new HomekitServer(networkInterface, settings.port);
|
||||
}
|
||||
if (homekitServer == null) {
|
||||
if (settings.useOHmDNS) {
|
||||
logger.trace("Not suitable mDNS server for IP {} found", networkInterface);
|
||||
}
|
||||
logger.trace("Create HomeKit server with dedicated mDNS server");
|
||||
homekitServer = new HomekitServer(networkInterface, settings.port);
|
||||
}
|
||||
startBridge();
|
||||
} else {
|
||||
|
||||
@@ -31,6 +31,7 @@ public class HomekitSettings {
|
||||
public String qrCode;
|
||||
public int startDelay = 30;
|
||||
public boolean useFahrenheitTemperature = false;
|
||||
public boolean useOHmDNS = false;
|
||||
public String thermostatTargetModeHeat = "HeatOn";
|
||||
public String thermostatTargetModeCool = "CoolOn";
|
||||
public String thermostatTargetModeAuto = "Auto";
|
||||
@@ -78,6 +79,8 @@ public class HomekitSettings {
|
||||
if (other.pin != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!useOHmDNS != other.useOHmDNS) {
|
||||
return false;
|
||||
} else if (!pin.equals(other.pin)) {
|
||||
return false;
|
||||
} else if (!setupId.equals(other.setupId)) {
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
<label>Thermostat Settings</label>
|
||||
<description>General thermostat settings</description>
|
||||
</parameter-group>
|
||||
<parameter-group name="network">
|
||||
<label>Network Settings</label>
|
||||
<description>General network settings</description>
|
||||
</parameter-group>
|
||||
<parameter-group name="thermostatTargetHeatingCooling">
|
||||
<label>Thermostat Target Heating/Cooling Mapping</label>
|
||||
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
||||
@@ -22,6 +26,11 @@
|
||||
<label>Thermostat Current Heating/Cooling Mapping</label>
|
||||
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
||||
</parameter-group>
|
||||
<parameter name="name" type="text" required="false" groupName="core">
|
||||
<label>Bridge name</label>
|
||||
<description>Name of the HomeKit bridge</description>
|
||||
<default>openHAB</default>
|
||||
</parameter>
|
||||
<parameter name="qrCode" type="text" required="false" groupName="core">
|
||||
<label>HomeKit QR Code</label>
|
||||
<context>qrcode</context>
|
||||
@@ -30,7 +39,7 @@
|
||||
<parameter name="port" type="integer" required="true" groupName="core">
|
||||
<label>Port</label>
|
||||
<description>Defines the port the HomeKit integration listens on.</description>
|
||||
<default>9124</default>
|
||||
<default>9123</default>
|
||||
</parameter>
|
||||
<parameter name="pin" type="text" pattern="\d{3}-\d{2}-\d{3}" required="true" groupName="core">
|
||||
<label>Pin</label>
|
||||
@@ -41,7 +50,7 @@
|
||||
<label>Setup ID</label>
|
||||
<description>Setup ID used for pairing using QR Code. Alphanumeric code of length 4.</description>
|
||||
</parameter>
|
||||
<parameter name="networkInterface" type="text" required="false" groupName="core">
|
||||
<parameter name="networkInterface" type="text" required="false" groupName="network">
|
||||
<label>Network Interface</label>
|
||||
<description>Defines the IP address of the network interface to expose the HomeKit integration on.</description>
|
||||
</parameter>
|
||||
@@ -102,6 +111,10 @@
|
||||
target temperature has been reached per the mode).</description>
|
||||
<default>Off</default>
|
||||
</parameter>
|
||||
|
||||
<parameter name="useOHmDNS" type="boolean" required="false" groupName="network">
|
||||
<label>Use openHAB mDNS service</label>
|
||||
<description>Defines whether mDNS service of openHAB or a separate instance of mDNS should be used.</description>
|
||||
<default>false</default>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</config-description:config-descriptions>
|
||||
|
||||
Reference in New Issue
Block a user