mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
[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:
parent
f3a517e4e1
commit
e7950ddbd1
@ -40,7 +40,7 @@ HomeKit integration supports following accessory types:
|
|||||||
|
|
||||||
- add metadata to an existing item (see [UI based configuration](#UI-based-Configuration))
|
- add metadata to an existing item (see [UI based configuration](#UI-based-Configuration))
|
||||||
|
|
||||||
- go to scan QR code from UI->Setting-HomeKit Integration
|
- scan QR code from UI->Settings->HomeKit Integration
|
||||||
|
|
||||||
![settings_qrcode.png](doc/settings_qrcode.png)
|
![settings_qrcode.png](doc/settings_qrcode.png)
|
||||||
|
|
||||||
@ -70,18 +70,16 @@ Add metadata to more item or fine-tune your configuration using further settings
|
|||||||
|
|
||||||
## Global Configuration
|
## Global Configuration
|
||||||
|
|
||||||
Your first step will be to create the `homekit.cfg` in your `$OPENHAB_CONF/services` folder.
|
You can define HomeKit settings either via mainUI or via `$OPENHAB_CONF/services/homekit.cfg`.
|
||||||
At the very least, you will need to define a pin number for the bridge.
|
HomeKit works with default settings, but we recommend changing the pin for the bridge.
|
||||||
This will be used in iOS when pairing. The pin code is in the form "###-##-###".
|
This will be used in iOS when pairing without QR Code. The pin code is in the form "###-##-###".
|
||||||
Requirements beyond this are not clear, and Apple enforces limitations on eligible pins within iOS.
|
Requirements beyond this are not clear, and Apple enforces limitations on eligible pins within iOS.
|
||||||
At the very least, you cannot use repeating (111-11-111) or sequential (123-45-678) pin codes.
|
At the very least, you cannot use repeating (111-11-111) or sequential (123-45-678) pin codes.
|
||||||
If your home network is secure, a good starting point is the pin code used in most sample applications: 031-45-154.
|
|
||||||
Check for typos in the pin-code if you encounter "Bad Client Credential" errors during pairing.
|
|
||||||
|
|
||||||
Other settings, such as using Fahrenheit temperatures, customizing the thermostat heat/cool/auto modes, and specifying the interface to advertise the HomeKit bridge (which can be edited in Paper UI standard mode) are also illustrated in the following sample:
|
Other settings, such as using Fahrenheit temperatures, customizing the thermostat heat/cool/auto modes, and specifying the interface to advertise the HomeKit bridge are also illustrated in the following sample:
|
||||||
|
|
||||||
```
|
```
|
||||||
org.openhab.homekit:port=9124
|
org.openhab.homekit:port=9123
|
||||||
org.openhab.homekit:pin=031-45-154
|
org.openhab.homekit:pin=031-45-154
|
||||||
org.openhab.homekit:useFahrenheitTemperature=true
|
org.openhab.homekit:useFahrenheitTemperature=true
|
||||||
org.openhab.homekit:thermostatTargetModeCool=CoolOn
|
org.openhab.homekit:thermostatTargetModeCool=CoolOn
|
||||||
@ -89,14 +87,8 @@ org.openhab.homekit:thermostatTargetModeHeat=HeatOn
|
|||||||
org.openhab.homekit:thermostatTargetModeAuto=Auto
|
org.openhab.homekit:thermostatTargetModeAuto=Auto
|
||||||
org.openhab.homekit:thermostatTargetModeOff=Off
|
org.openhab.homekit:thermostatTargetModeOff=Off
|
||||||
org.openhab.homekit:networkInterface=192.168.0.6
|
org.openhab.homekit:networkInterface=192.168.0.6
|
||||||
```
|
org.openhab.homekit:useOHmDNS=false
|
||||||
|
|
||||||
The following additional settings can be added or edited in Paper UI after switching to expert mode:
|
|
||||||
|
|
||||||
```
|
|
||||||
org.openhab.homekit:name=openHAB
|
org.openhab.homekit:name=openHAB
|
||||||
org.openhab.homekit:minimumTemperature=-100
|
|
||||||
org.openhab.homekit:maximumTemperature=100
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Overview of all settings
|
### Overview of all settings
|
||||||
@ -105,6 +97,7 @@ org.openhab.homekit:maximumTemperature=100
|
|||||||
|:-------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------|
|
|:-------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------|
|
||||||
| networkInterface | IP address or domain name under which the HomeKit bridge can be reached. If no value is configured, the add-on uses the first network adapter address configured for openHAB. | (none) |
|
| networkInterface | IP address or domain name under which the HomeKit bridge can be reached. If no value is configured, the add-on uses the first network adapter address configured for openHAB. | (none) |
|
||||||
| port | Port under which the HomeKit bridge can be reached. | 9123 |
|
| port | Port under which the HomeKit bridge can be reached. | 9123 |
|
||||||
|
| useOHmDNS | mDNS service is used to advertise openHAB as HomeKit bridge in the network so that HomeKit clients can find it. openHAB has already mDNS service running. This option defines whether the mDNS service of openHAB or a separate service should be used. | false |
|
||||||
| pin | Pin code used for pairing with iOS devices. Apparently, pin codes are provided by Apple and represent specific device types, so they cannot be chosen freely. The pin code 031-45-154 is used in sample applications and known to work. | 031-45-154 |
|
| pin | Pin code used for pairing with iOS devices. Apparently, pin codes are provided by Apple and represent specific device types, so they cannot be chosen freely. The pin code 031-45-154 is used in sample applications and known to work. | 031-45-154 |
|
||||||
| startDelay | HomeKit start delay in seconds in case the number of accessories is lower than last time. This helps to avoid resetting home app in case not all items have been initialised properly before HomeKit integration start. | 30 |
|
| startDelay | HomeKit start delay in seconds in case the number of accessories is lower than last time. This helps to avoid resetting home app in case not all items have been initialised properly before HomeKit integration start. | 30 |
|
||||||
| useFahrenheitTemperature | Set to true to use Fahrenheit degrees, or false to use Celsius degrees. | false |
|
| useFahrenheitTemperature | Set to true to use Fahrenheit degrees, or false to use Celsius degrees. | false |
|
||||||
@ -112,8 +105,6 @@ org.openhab.homekit:maximumTemperature=100
|
|||||||
| thermostatTargetModeHeat | Word used for activating the heating mode of the device (if applicable). It can be overwritten at item level. | HeatOn |
|
| thermostatTargetModeHeat | Word used for activating the heating mode of the device (if applicable). It can be overwritten at item level. | HeatOn |
|
||||||
| thermostatTargetModeAuto | Word used for activating the automatic mode of the device (if applicable). It can be overwritten at item level. | Auto |
|
| thermostatTargetModeAuto | Word used for activating the automatic mode of the device (if applicable). It can be overwritten at item level. | Auto |
|
||||||
| thermostatTargetModeOff | Word used to set the thermostat mode of the device to off (if applicable). It can be overwritten at item level. | Off |
|
| thermostatTargetModeOff | Word used to set the thermostat mode of the device to off (if applicable). It can be overwritten at item level. | Off |
|
||||||
| minimumTemperature | Lower bound of possible temperatures, used in the user interface of the iOS device to display the allowed temperature range. Note that this setting applies to all devices in HomeKit. | -100 |
|
|
||||||
| maximumTemperature | Upper bound of possible temperatures, used in the user interface of the iOS device to display the allowed temperature range. Note that this setting applies to all devices in HomeKit. | 100 |
|
|
||||||
| name | Name under which this HomeKit bridge is announced on the network. This is also the name displayed on the iOS device when searching for available bridges. | openHAB |
|
| name | Name under which this HomeKit bridge is announced on the network. This is also the name displayed on the iOS device when searching for available bridges. | openHAB |
|
||||||
|
|
||||||
## Item Configuration
|
## Item Configuration
|
||||||
@ -586,7 +577,7 @@ or using UI
|
|||||||
| | | Name | String | Name of the switch |
|
| | | Name | String | Name of the switch |
|
||||||
| Outlet | | | | An accessory that can be turned off and on. While similar to a lightbulb, this will be presented differently in the Siri grammar and iOS apps |
|
| Outlet | | | | An accessory that can be turned off and on. While similar to a lightbulb, this will be presented differently in the Siri grammar and iOS apps |
|
||||||
| | OnState | | Switch | State of the outlet - ON/OFF |
|
| | OnState | | Switch | State of the outlet - ON/OFF |
|
||||||
| | InUseStatus | | Switch | indicates whether current flowing through the outlet |
|
| | InUseStatus | | Switch | Indicates whether the outlet has an appliance e.g., a floor lamp, physically plugged in. This characteristic is set to True even if the plugged-in appliance is off. |
|
||||||
| | | Name | String | Name of the switch |
|
| | | Name | String | Name of the switch |
|
||||||
| Lighting | | | | A lightbulb, can have further optional parameters for brightness, hue, etc |
|
| Lighting | | | | A lightbulb, can have further optional parameters for brightness, hue, etc |
|
||||||
| | OnState | | Switch | State of the light - ON/OFF |
|
| | OnState | | Switch | State of the light - ON/OFF |
|
||||||
|
@ -145,7 +145,8 @@ public class HomekitImpl implements Homekit {
|
|||||||
HomekitSettings oldSettings = settings;
|
HomekitSettings oldSettings = settings;
|
||||||
settings = processConfig(config);
|
settings = processConfig(config);
|
||||||
changeListener.updateSettings(settings);
|
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
|
// the HomeKit server settings changed. we do a complete re-init
|
||||||
stopHomekitServer();
|
stopHomekitServer();
|
||||||
startHomekitServer();
|
startHomekitServer();
|
||||||
@ -205,23 +206,28 @@ public class HomekitImpl implements Homekit {
|
|||||||
|
|
||||||
private void startHomekitServer() throws IOException {
|
private void startHomekitServer() throws IOException {
|
||||||
if (homekitServer == null) {
|
if (homekitServer == null) {
|
||||||
if ((settings.networkInterface == null) || (settings.networkInterface.isEmpty())) {
|
if (settings.useOHmDNS) {
|
||||||
logger.trace(
|
if ((settings.networkInterface == null) || (settings.networkInterface.isEmpty())) {
|
||||||
"No IP address configured in homekit settings. HomeKit will use the first configured address of openHAB");
|
logger.trace(
|
||||||
homekitServer = new HomekitServer(mdnsClient.getClientInstances().iterator().next(), settings.port);
|
"No IP address configured in HomeKit settings. HomeKit will use the first configured address of openHAB");
|
||||||
} else {
|
homekitServer = new HomekitServer(mdnsClient.getClientInstances().iterator().next(), settings.port);
|
||||||
networkInterface = InetAddress.getByName(settings.networkInterface);
|
} else {
|
||||||
for (JmDNS mdns : mdnsClient.getClientInstances()) {
|
networkInterface = InetAddress.getByName(settings.networkInterface);
|
||||||
if (mdns.getInetAddress().equals(networkInterface)) {
|
for (JmDNS mdns : mdnsClient.getClientInstances()) {
|
||||||
logger.trace("suitable mDNS client for IP {} found. Reusing it.", networkInterface);
|
if (mdns.getInetAddress().equals(networkInterface)) {
|
||||||
homekitServer = new HomekitServer(mdns, settings.port);
|
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.",
|
if (homekitServer == null) {
|
||||||
networkInterface);
|
if (settings.useOHmDNS) {
|
||||||
homekitServer = new HomekitServer(networkInterface, settings.port);
|
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();
|
startBridge();
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,6 +31,7 @@ public class HomekitSettings {
|
|||||||
public String qrCode;
|
public String qrCode;
|
||||||
public int startDelay = 30;
|
public int startDelay = 30;
|
||||||
public boolean useFahrenheitTemperature = false;
|
public boolean useFahrenheitTemperature = false;
|
||||||
|
public boolean useOHmDNS = false;
|
||||||
public String thermostatTargetModeHeat = "HeatOn";
|
public String thermostatTargetModeHeat = "HeatOn";
|
||||||
public String thermostatTargetModeCool = "CoolOn";
|
public String thermostatTargetModeCool = "CoolOn";
|
||||||
public String thermostatTargetModeAuto = "Auto";
|
public String thermostatTargetModeAuto = "Auto";
|
||||||
@ -78,6 +79,8 @@ public class HomekitSettings {
|
|||||||
if (other.pin != null) {
|
if (other.pin != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (!useOHmDNS != other.useOHmDNS) {
|
||||||
|
return false;
|
||||||
} else if (!pin.equals(other.pin)) {
|
} else if (!pin.equals(other.pin)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!setupId.equals(other.setupId)) {
|
} else if (!setupId.equals(other.setupId)) {
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
<label>Thermostat Settings</label>
|
<label>Thermostat Settings</label>
|
||||||
<description>General thermostat settings</description>
|
<description>General thermostat settings</description>
|
||||||
</parameter-group>
|
</parameter-group>
|
||||||
|
<parameter-group name="network">
|
||||||
|
<label>Network Settings</label>
|
||||||
|
<description>General network settings</description>
|
||||||
|
</parameter-group>
|
||||||
<parameter-group name="thermostatTargetHeatingCooling">
|
<parameter-group name="thermostatTargetHeatingCooling">
|
||||||
<label>Thermostat Target Heating/Cooling Mapping</label>
|
<label>Thermostat Target Heating/Cooling Mapping</label>
|
||||||
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
||||||
@ -22,6 +26,11 @@
|
|||||||
<label>Thermostat Current Heating/Cooling Mapping</label>
|
<label>Thermostat Current Heating/Cooling Mapping</label>
|
||||||
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
<description>String values used by your thermostat to set different targetHeatingCooling modes</description>
|
||||||
</parameter-group>
|
</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">
|
<parameter name="qrCode" type="text" required="false" groupName="core">
|
||||||
<label>HomeKit QR Code</label>
|
<label>HomeKit QR Code</label>
|
||||||
<context>qrcode</context>
|
<context>qrcode</context>
|
||||||
@ -30,7 +39,7 @@
|
|||||||
<parameter name="port" type="integer" required="true" groupName="core">
|
<parameter name="port" type="integer" required="true" groupName="core">
|
||||||
<label>Port</label>
|
<label>Port</label>
|
||||||
<description>Defines the port the HomeKit integration listens on.</description>
|
<description>Defines the port the HomeKit integration listens on.</description>
|
||||||
<default>9124</default>
|
<default>9123</default>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="pin" type="text" pattern="\d{3}-\d{2}-\d{3}" required="true" groupName="core">
|
<parameter name="pin" type="text" pattern="\d{3}-\d{2}-\d{3}" required="true" groupName="core">
|
||||||
<label>Pin</label>
|
<label>Pin</label>
|
||||||
@ -41,7 +50,7 @@
|
|||||||
<label>Setup ID</label>
|
<label>Setup ID</label>
|
||||||
<description>Setup ID used for pairing using QR Code. Alphanumeric code of length 4.</description>
|
<description>Setup ID used for pairing using QR Code. Alphanumeric code of length 4.</description>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="networkInterface" type="text" required="false" groupName="core">
|
<parameter name="networkInterface" type="text" required="false" groupName="network">
|
||||||
<label>Network Interface</label>
|
<label>Network Interface</label>
|
||||||
<description>Defines the IP address of the network interface to expose the HomeKit integration on.</description>
|
<description>Defines the IP address of the network interface to expose the HomeKit integration on.</description>
|
||||||
</parameter>
|
</parameter>
|
||||||
@ -102,6 +111,10 @@
|
|||||||
target temperature has been reached per the mode).</description>
|
target temperature has been reached per the mode).</description>
|
||||||
<default>Off</default>
|
<default>Off</default>
|
||||||
</parameter>
|
</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-description:config-descriptions>
|
</config-description:config-descriptions>
|
||||||
|
Loading…
Reference in New Issue
Block a user