diff --git a/addons/io/org.openhab.io.homekit/README.md b/addons/io/org.openhab.io.homekit/README.md
index 4f96fe6b127bb..cb87da1dd878d 100644
--- a/addons/io/org.openhab.io.homekit/README.md
+++ b/addons/io/org.openhab.io.homekit/README.md
@@ -20,7 +20,7 @@ org.openhab.homekit:networkInterface=192.168.0.6
```
## Item Configuration
-After setting this global configuration, you will need to tag your openHAB items in order to map them to the HomeKit ontology. For our purposes, you may consider HomeKit accessories to be of two forms: simple and complex.
+After setting this global configuration, you will need to tag your openHAB items in order to map them to an ontology. For our purposes, you may consider HomeKit accessories to be of two forms: simple and complex.
A simple accessory will be mapped to a single openHAB item (i.e. a Lighbulb is mapped to a Switch, Dimmer, or Color item). A complex accessory will be made up of multiple openHAB items (i.e. a Thermostat is composed of Heating and Cooling thresholds, a mode, and current temperature). Complex accessories require a tag on a Group indicating the accessory type, as well as tags on the items it composes.
@@ -34,31 +34,25 @@ A full list of supported accessory types can be found in the table below.
description |
- Lightbulb |
+ Lighting |
|
Switch, Dimmer, Color |
- A lightbulb |
+ A lightbulb, either switchable or dimmable |
- DimmableLightbulb |
- |
- Dimmer, Color |
- A lightbulb with the ability to set an output level |
-
-
- Switch |
+ Switchable |
|
Switch, Dimmer, Color |
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 |
- TemperatureSensor |
+ CurrentTemperature |
|
Number |
An accessory that provides a single read-only temperature value. The units default to celsius but can be overridden globally using the useFahrenheitTemperature global property |
- HumiditySensor |
+ CurrentHumidity |
|
Number |
An accessory that provides a single read-only value indicating the relative humidity. |
@@ -71,34 +65,34 @@ A full list of supported accessory types can be found in the table below.
|
- currentTemperature |
+ CurrentTemperature |
Number |
- The current temperature, using the same unit rules as TemperatureSensor |
+ The current temperature, same as above |
|
- heatingCoolingMode |
+ homekit:HeatingCoolingMode |
String |
- Indicates the current mode of the device: OFF, AUTO, HEAT, COOL. The string's value must match those defined in the thermostat*Mode properties. |
+ Indicates the current mode of the device: OFF, AUTO, HEAT, COOL. The string's value must match those defined in the thermostat*Mode properties. This is a homekit-specific term and therefore the tags needs to be prefixed with "homekit:" |
|
- targetTemperature |
+ TargetTemperature |
Number |
A target temperature that will engage the thermostat's heating and cooling actions as necessary, depending on the heatingCoolingMode |
-Tags are applied to items using the prefix "homekit:". See the sample below for example items:
+See the sample below for example items:
```
-Switch KitchenLights "Kitchen Lights" (gKitchen) [ "homekit:Lightbulb" ]
-Dimmer BedroomLights "Bedroom Lights" (gBedroom) [ "homekit:DimmableLightbulb" ]
-Number BedroomTemperature "Bedroom Temperature" (gBedroom) [ "homekit:TemperatureSensor" ]
-Group gDownstairsThermostat "Downstairs Thermostat" (gFF) [ "homekit:Thermostat" ]
-Number DownstairsThermostatCurrentTemp "Downstairs Thermostat Current Temperature" (gDownstairsThermostat) [ "homekit:currentTemperature" ]
-Number DownstairsThermostatTargetTemperature "Downstairs Thermostat Target Temperature" (gDownstairsThermostat) [ "homekit:targetTemperature" ]
-String DownstairsThermostatHeatingCoolingMode "Downstairs Thermostat Heating/Cooling Mode" (gDownstairsThermostat) [ "homekit:heatingCoolingMode" ]
+Switch KitchenLights "Kitchen Lights" (gKitchen) [ "Lighting" ]
+Dimmer BedroomLights "Bedroom Lights" (gBedroom) [ "Lighting" ]
+Number BedroomTemperature "Bedroom Temperature" (gBedroom) [ "CurrentTemperature" ]
+Group gDownstairsThermostat "Downstairs Thermostat" (gFF) [ "Thermostat" ]
+Number DownstairsThermostatCurrentTemp "Downstairs Thermostat Current Temperature" (gDownstairsThermostat) [ "CurrentTemperature" ]
+Number DownstairsThermostatTargetTemperature "Downstairs Thermostat Target Temperature" (gDownstairsThermostat) [ "TargetTemperature" ]
+String DownstairsThermostatHeatingCoolingMode "Downstairs Thermostat Heating/Cooling Mode" (gDownstairsThermostat) [ "homekit:HeatingCoolingMode" ]
```
## Additional Notes
diff --git a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java
index 3cfe6149c2fac..3dfe41e518246 100644
--- a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java
+++ b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java
@@ -19,9 +19,9 @@
*/
public enum HomekitCharacteristicType {
- CURRENT_TEMPERATURE("currentTemperature"),
- TARGET_TEMPERATURE("targetTemperature"),
- HEATING_COOLING_MODE("heatingCoolingMode");
+ CURRENT_TEMPERATURE("CurrentTemperature"),
+ TARGET_TEMPERATURE("TargetTemperature"),
+ HEATING_COOLING_MODE("homekit:HeatingCoolingMode");
private static final Map tagMap = new HashMap<>();
diff --git a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitDeviceType.java b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitDeviceType.java
index 974836678d829..a328301dcd72d 100644
--- a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitDeviceType.java
+++ b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitDeviceType.java
@@ -13,17 +13,17 @@
/**
* Enum of the possible device types. The defined tag string can be used
- * as a homekit:{tag} tag on an item to enable it for Homekit.
+ * as a tag on an item to enable it for Homekit.
*
* @author Andy Lintner
*/
public enum HomekitDeviceType {
- DIMMABLE_LIGHTBULB("DimmableLightbulb"),
- HUMIDITY_SENSOR("HumiditySensor"),
- LIGHTBULB("Lightbulb"),
- SWITCH("Switch"),
- TEMPERATURE_SENSOR("TemperatureSensor"),
+ DIMMABLE_LIGHTBULB("DimmableLighting"),
+ HUMIDITY_SENSOR("CurrentHumidity"),
+ LIGHTBULB("Lighting"),
+ SWITCH("Switchable"),
+ TEMPERATURE_SENSOR("CurrentTemperature"),
THERMOSTAT("Thermostat");
private static final Map tagMap = new HashMap<>();
diff --git a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java
index d3d355476701a..840de11aa7694 100644
--- a/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java
+++ b/addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitTaggedItem.java
@@ -13,11 +13,12 @@
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.eclipse.smarthome.core.items.Item;
+import org.eclipse.smarthome.core.library.items.DimmerItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Wraps an Item with data derived from any homekit: tags defined.
+ * Wraps an Item with data derived from supported tags defined.
*
* @author Andy Lintner
*/
@@ -34,15 +35,12 @@ public class HomekitTaggedItem {
public HomekitTaggedItem(Item item) {
this.item = item;
for (String tag : item.getTags()) {
- if (tag.startsWith("homekit:")) {
- String tagValue = tag.substring("homekit:".length()).trim();
- homekitDeviceType = HomekitDeviceType.valueOfTag(tagValue);
- if (homekitDeviceType == null) {
- homekitCharacteristicType = HomekitCharacteristicType.valueOfTag(tagValue);
- if (homekitCharacteristicType == null) {
- logger.error("Unrecognized homekit type: " + tagValue);
- }
- }
+ if (item instanceof DimmerItem) {
+ tag = "Dimmable" + tag;
+ }
+ homekitDeviceType = HomekitDeviceType.valueOfTag(tag);
+ if (homekitDeviceType == null) {
+ homekitCharacteristicType = HomekitCharacteristicType.valueOfTag(tag);
}
}
if (homekitDeviceType != null) {
diff --git a/addons/io/org.openhab.io.hueemulation/META-INF/MANIFEST.MF b/addons/io/org.openhab.io.hueemulation/META-INF/MANIFEST.MF
index 7ea495a2019e8..0f889c82c2e39 100644
--- a/addons/io/org.openhab.io.hueemulation/META-INF/MANIFEST.MF
+++ b/addons/io/org.openhab.io.hueemulation/META-INF/MANIFEST.MF
@@ -6,10 +6,11 @@ Bundle-Vendor: openHAB
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .
-Import-Package: com.google.gson;version="2.2.4",
+Import-Package: com.google.gson,
javax.servlet,
javax.servlet.http,
org.apache.commons.io,
+ org.apache.commons.lang,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.core.events,
org.eclipse.smarthome.core.items,
diff --git a/addons/io/org.openhab.io.hueemulation/README.md b/addons/io/org.openhab.io.hueemulation/README.md
index 1c506ce72cf1c..348b5bfd47ca6 100644
--- a/addons/io/org.openhab.io.hueemulation/README.md
+++ b/addons/io/org.openhab.io.hueemulation/README.md
@@ -5,22 +5,26 @@
Hue Emulation exposes openHAB items as Hue devices to other Hue HTTP API compatible applications like an Amazon Echo.
##Features:
+
* UPNP automatic discovery
* Support ON/OFF and Percent/Decimal item types
* Can expose any type of item, not just lights
* Pairing (security) can be enabled/disabled in real time using the configuration service (under services in the PaperUI for example)
##Configuration:
+
Pairing can be turned on and off:
```
org.openhab.hueemulation:pairingEnabled=false
```
+
##Device Taging
-To expose an item on the service apply any Apple HomeKit style tag to it. The item label will be used as the Hue Device name.
+To expose an item on the service apply a supported tag (which are "Lighting", "Switchable", "TargetTemperature") to it. The item label will be used as the Hue device name.
+
+```
+Switch TestSwitch1 "Kitchen Switch" [ "Switchable" ]
+Switch TestSwitch2 "Bathroom" [ "Lighting" ]
+Dimmer TestDimmer3 "Hallway" [ "Lighting" ]
+Number TestNumber4 "Temperature Set Point" [ "TargetTemperature" ]
```
-Switch TestSwitch1 "Kitchen Switch" ["homekit:Switch"]
-Switch TestSwitch2 "Bathroom" ["homekit:Lightbulb"]
-Dimmer TestDimmer3 "Hallway" ["homekit:DimmableLightbulb"]
-Number TestNumber4 "Cool Set Point" ["homekit:coolingThreshold"]
-```
\ No newline at end of file
diff --git a/addons/io/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationServlet.java b/addons/io/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationServlet.java
index 4f3e7e559348b..a72875f908ec8 100644
--- a/addons/io/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationServlet.java
+++ b/addons/io/org.openhab.io.hueemulation/src/main/java/org/openhab/io/hueemulation/internal/HueEmulationServlet.java
@@ -33,6 +33,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
import org.eclipse.smarthome.config.core.ConfigConstants;
import org.eclipse.smarthome.core.events.EventPublisher;
import org.eclipse.smarthome.core.items.Item;
@@ -67,7 +68,6 @@ public class HueEmulationServlet extends HttpServlet {
private Logger logger = LoggerFactory.getLogger(HueEmulationServlet.class);
private static final String CONFIG_PAIRING_ENABLED = "pairingEnabled";
private static final String PATH = "/api";
- private static final String HOMEKIT_PREFIX = "homekit:";
private static final String METHOD_POST = "POST";
private static final String METHOD_PUT = "PUT";
private static final String APPLICATION_XML = "application/xml";
@@ -80,6 +80,8 @@ public class HueEmulationServlet extends HttpServlet {
private static final File UDN_FILE = new File(
ConfigConstants.getUserDataFolder() + File.separator + "hueemulation" + File.separator + "udn");
+ private static final String[] SUPPORTED_TAGS = new String[] { "Switchable", "Lighting", "TargetTemperature" };
+
/**
* This parses "/api/{username}/{lights}/{id}/{state}"
*/
@@ -424,9 +426,9 @@ public Map getHueDeviceNames() {
}
/**
- * Converts an VoiceItem to a HueDevice
+ * Converts an Item to a HueDevice
*
- * @param voiceItem
+ * @param item
* @return
* HueDevice
*/
@@ -452,7 +454,7 @@ private Collection- getTaggedItems() {
Collection
- items = new LinkedList
- ();
for (Item item : itemRegistry.getItems()) {
for (String tag : item.getTags()) {
- if (tag.startsWith(HOMEKIT_PREFIX)) {
+ if (ArrayUtils.contains(SUPPORTED_TAGS, tag)) {
items.add(item);
break;
}