Skip to content

Commit

Permalink
Process review, update readme, add binding to feature.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
pdegeus committed Oct 19, 2016
1 parent 79253bc commit 46738f6
Show file tree
Hide file tree
Showing 55 changed files with 547 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" modified="modified" configuration-policy="optional" immediate="true" name="org.openhab.imperihome">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" configuration-policy="optional" immediate="true" name="org.openhab.imperihome">
<implementation class="org.openhab.io.imperihome.internal.ImperiHomeApiServlet"/>
<reference bind="setHttpService" cardinality="1..1" interface="org.osgi.service.http.HttpService" name="HttpService" policy="static" unbind="unsetHttpService"/>
<reference bind="setItemRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="dynamic" unbind="unsetItemRegistry"/>
Expand Down
114 changes: 78 additions & 36 deletions addons/io/org.openhab.io.imperihome/README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,112 @@
# ImperiHome integration service

This IO service exposes OpenHAB Items to the Evertygo [ImperiHome](http://www.evertygo.com/imperihome) dashboard app for Android and iOS.
It creates a REST service at ```/imperihome/iss``` that implements the [ImperiHome Standard System API](http://dev.evertygo.com/api/iss) (ISS).
This IO service exposes openHAB Items to the Evertygo [ImperiHome](http://www.evertygo.com/imperihome) dashboard app for Android and iOS.
It creates a REST service at _/imperihome/iss_ that implements the [ImperiHome Standard System API](http://dev.evertygo.com/api/iss) (ISS).

## Installation

At the moment the ImperiHome integration service is not part of the OpenHAB distribution and can't be installed using the Paper UI.
If you want to try it out, [download the latest build](https://dl.dvelop.nl/oh-imperihome/) and drop the JAR file in the ```addons``` directory of OpenHAB.
The ImperiHome integration service can be installed through the Paper UI. Navigate to Extensions &gt; Misc and click Install.

## Configuration

The service itself has no configuration. ImperiHome on the other hand must be configured to connect to your OpenHAB instance.
The service itself has no configuration. ImperiHome on the other hand must be configured to connect to your openHAB instance.

Start ImperiHome, open the menu and go to My Systems. Add a new system (+) and choose 'ImperiHome Standard System' as the object type. Now enter the URL to your OpenHAB instance
as Local URL, followed by ```/imperihome/iss```. For example, if your OH instance is running at ```http://192.168.1.10:8080/```, the Local URL would be ```http://192.168.1.10:8080/imperihome/iss```.
Start ImperiHome, open the menu and go to My Systems. Add a new system (+) and choose 'ImperiHome Standard System' as the object type. Now enter the URL to your openHAB instance
as Local URL, followed by _/imperihome/iss_. For example, if your OH instance is running at _http://192.168.1.10:8080/_, the Local URL would be _http://192.168.1.10:8080/imperihome/iss_.

If you have port forwarding or similar set up to access your OH form the internet, you can also fill the Remote URL in the same way. For example:
```http://my-openhab-url.dyndns.org:8080/imperihome/iss```. Please be aware that this service provides no authentication mechanism, so anyone could use the API to control your
_http://my-openhab-url.dyndns.org:8080/imperihome/iss_. Please be aware that this service provides no authentication mechanism, so anyone could use the API to control your
system when accessible from the internet.

Click Next to let ImperiHome validate the URL. After validation succeeded the system is added and you can continue to configure your Items for use in ImperiHome.

## Device Tagging
Similar to the Hue Emulation service, this service uses Item tags to determine how to expose your Items to ImperiHome.
All tags are formatted ```iss:<tagtype>:<value>```. For example: ```iss:room:Kitchen```.

If you've defined your Items in ```.items``` files, tags can be added using the ```[ "mytag" ]``` syntax (after the ```(Groups)``` and before the ```{channel}```). If you
created your items another way, e.g. using the Paper UI, [HABmin](https://github.com/openhab/org.openhab.ui.habmin) allows you to modify the tags.
This service uses Item tags to determine how to expose your Items to ImperiHome. All tags are formatted like this:

```iss:<tagtype>:<value>```

For example:

```iss:room:Kitchen```

If you've defined your Items in _.items_ files, tags can be added using the

```[ "mytag" ]```

syntax (after the _(Groups)_ and before the _{channel}_).
If you created your items another way, e.g. using the Paper UI, [HABmin](https://github.com/openhab/org.openhab.ui.habmin) allows you to modify the tags.

### Tag: _type_

### Tag: ```type```
Specifies the device type to expose to ImperiHome. Take a look at [Device types](#deviceTypes) below for the supported device types and how to configure them.
If no type is specified, this service will try to auto-detect the type from the Item, based on supported value types (OnOff for a switch, HSB for color light) and Item name.

_Required_: no<br>
_Default_: auto-detect<br>
Example: ```iss:type:DevSwitch```
Example:

```iss:type:DevSwitch```

### Tag: _room_

### Tag: ```room```
Specifies the room the device will show up in in ImperiHome.

_Required_: no<br>
_Default_: 'No Room'<br>
_Example_: ```iss:room:Kitchen```
_Example_:

```iss:room:Kitchen```

### Tag: _label_

### Tag: ```label```
Sets the device label in ImperiHome. If no label is specified, the Item label is used if available. Otherwise the Item name will be used.

_Required_: no<br>
_Default_: Item label or name<br>
_Example_: ```iss:label:Kitchen light```
_Example_:

```iss:label:Kitchen light```

### Tag: _mapping_

### Tag: ```mapping```
Sets the mapping for a ImperiHome MultiSwitch device, just like an OpenHAB sitemap mapping does.
Sets the mapping for a ImperiHome MultiSwitch device, just like an openHAB sitemap mapping does.
In the example below, 'All off', 'Relax' and 'Reading' will be visible in ImperiHome. Clicking one of the options will send
a 0, 1 or 2 value command to the OpenHAB item.
a 0, 1 or 2 value command to the openHAB item.

_Required_: only for MultiSwitch device<br>
_Default_: none<br>
_Example_: ```iss:mapping:0=All off,1=Relax,2=Reading```
_Example_:

```iss:mapping:0=All off,1=Relax,2=Reading```

### Tag: _link_

### Tag: ```link```
Links two devices together, using the value from the linked device as an additional value in the device containing the link tag.
See [Device links](#deviceLinks) for details.

_Required_: no<br>
_Default_: none<br>
_Example_: ```iss:link:energy:Kitchen_Current_Consumption```
_Example_:

```iss:link:energy:Kitchen_Current_Consumption```

### Tag: _unit_

### Tag: ```unit```
Sets the unit for devices with a numeric value, such as ```DevTemperature``` and ```DevGenericSensor```.
Sets the unit for devices with a numeric value, such as _DevTemperature_ and _DevGenericSensor_.
The unit is only used to tell ImperiHome what to display; no conversion is performed.

_Required_: no<br>
_Default_: none<br>
_Example_: ```iss:unit:°C```
_Example_:

```iss:unit:°C```

<a name="deviceTypes"></a>

## Device types
The following table lists the ImperiHome API device types that you can use in a ```iss:type``` tag. Not all device types are currently supported. For those that are supported,

The following table lists the ImperiHome API device types that you can use in a _iss:type_ tag. Not all device types are currently supported. For those that are supported,
the Item types you can use them on are listed.

<table>
Expand Down Expand Up @@ -289,59 +318,72 @@ the Item types you can use them on are listed.
<sup>(1)</sup> When using a String Item for trippable devices, any non-empty value other than 'ok' will set the device to tripped. This makes it compatible with the Nest Protect binding.

<a name="deviceLinks"></a>

## Device links

Some devices can be linked to another device. This allows you to create combined devices reporting multiple values, or reporting the energy consumption with a switch device.

The ```link``` tag refers to the name of the Item it should link to. The item must be an ImperiHome device itself, so it must have at least one ```iss``` tag.
The _link_ tag refers to the name of the Item it should link to. The item must be an ImperiHome device itself, so it must have at least one _iss_ tag.

### Switch energy consumption
ImperiHome allows you to show the current energy consumption for a ```DevDimmer```, ```DevRGBLight``` and ```DevSwitch```.
This example links the ```MyLight_Energy``` Number Item to the ```MyLight``` Switch Item,
so the ```DevSwitch``` device will also report the energy consumption value to ImperiHome:

ImperiHome allows you to show the current energy consumption for a _DevDimmer_, _DevRGBLight_ and _DevSwitch_.
This example links the _MyLight_Energy_ Number Item to the _MyLight_ Switch Item,
so the _DevSwitch_ device will also report the energy consumption value to ImperiHome:

```
Switch MyLight "My Light" ["iss:type:DevSwitch", "iss:link:energy:MyLight_Energy"] { channel="zwave:device:1:node14:switch_binary1" }
Number MyLight_Energy "My Light Usage [%.1f W]" ["iss:type:DevElectricity"] { channel="zwave:device:1:node14:meter_watts1" }
```

### Total energy consumption
The ```DevElectricity``` devices main value is the current consumption in Watts. To add the total consumption in KWh, link your electricity device to

The _DevElectricity_ devices main value is the current consumption in Watts. To add the total consumption in KWh, link your electricity device to
a generic sensor device containing the total energy consumption value:

```
Number MyLight_Energy "My Light Usage [%.1f W]" ["iss:type:DevElectricity", "iss:link:kwh:MyLight_Total_Energy"] { channel="zwave:device:1:node14:meter_watts1" }
Number MyLight_Total_Energy "My Light Total usage [%.1f KWh]" ["iss:type:DevGenericSensor", "iss:unit:KWh"] { channel="zwave:device:1:node14:sensor_power1" }
```

### TempHygro
ImperiHome recognizes the special ```DevTempHygro``` device, combining a temperature and hydrometry sensor. You can create such a device by linking either from a temperature Item to a hygro Item:

ImperiHome recognizes the special _DevTempHygro_ device, combining a temperature and hydrometry sensor. You can create such a device by linking either from a temperature Item to a hygro Item:

```
Number MyTemp "Temperature [%.1f °C]" ["iss:type:DevTempHygro", "iss:link:hygro:MyHum"] { channel="zwave:device:1:node8:sensor_temperature" }
Number MyHum "Humidity [%d%%]" ["iss:type:DevHygrometry"] { channel="zwave:device:1:node8:sensor_relhumidity" }
```

or vise versa:

```
Number MyTemp "Temperature [%.1f °C]" ["iss:type:DevTemperature"] { channel="zwave:device:1:node8:sensor_temperature" }
Number MyHum "Humidity [%d%%]" ["iss:type:DevTempHygro", "iss:link:temp:MyTemp"] { channel="zwave:device:1:node8:sensor_relhumidity" }
```

### Rain accumulation
The ```DevRain``` devices main value is the current instant rain value (default in mm per hour). To add the total rain accumulation value, link your rain device to

The _DevRain_ devices main value is the current instant rain value (default in mm per hour). To add the total rain accumulation value, link your rain device to
a generic sensor device:

```
Number RainCurrent "Rain current [%.1f mm/h]" ["iss:type:DevRain", "iss:link:accum:RainAccumulation"] { channel="..." }
Number RainAccumulation "Rain accumulation [%.1f mm]" ["iss:type:DevGenericSensor", "iss:unit:mm"] { channel="..." }
```

### Wind direction
The ```DevWind``` devices main value is the current wind speed (default in km per hour). To add the wind direction value (default in degrees), link your wind device to

The _DevWind_ devices main value is the current wind speed (default in km per hour). To add the wind direction value (default in degrees), link your wind device to
a generic sensor device:

```
Number WindSpeed "Wind speed [%.1f km/h]" ["iss:type:DevWind", "iss:link:direction:WindDirection"] { channel="..." }
Number WindDirection "Wind direction [%d deg]" ["iss:type:DevGenericSensor", "iss:unit:deg"] { channel="..." }
```

## Items example

```
Color LVR_Billy "Billy" <colorlight> (Lights) ["iss:room:Living room", "iss:type:DevRGBLight"] { channel="hue:0210:001122334455:bulb1:color" }
Switch LVR_TallLamp "Tall lamp" (Lights) ["iss:room:Living room", "iss:type:DevSwitch"] { channel="zwave:device:1:node3:switch_binary" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
Expand Down Expand Up @@ -47,7 +47,7 @@

/**
* Main OSGi service and HTTP servlet for ImperiHome integration.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public class ImperiHomeApiServlet extends HttpServlet {

Expand Down Expand Up @@ -96,10 +96,6 @@ public ImperiHomeApiServlet() {
* @param config Service config.
*/
protected void activate(Map<String, Object> config) {
LOGGER.info("Starting ImperiHome integration service");

modified(config);

systemHandler = new SystemHandler();
deviceRegistry = new DeviceRegistry();
actionRegistry = new ActionRegistry(eventPublisher);
Expand All @@ -118,17 +114,11 @@ protected void activate(Map<String, Object> config) {
}
}

protected void modified(Map<String, ?> config) {

}

/**
* OSGi deactivation callback.
* @param componentContext Context.
*/
protected void deactivate(ComponentContext componentContext) {
LOGGER.info("Stopping ImperiHome integration service");

try {
httpService.unregister(PATH);
} catch (IllegalArgumentException ignored) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.io.imperihome.internal.action;

import org.eclipse.smarthome.core.events.EventPublisher;
Expand All @@ -6,7 +14,7 @@

/**
* Abstract action, called through the API by ImperiHome clients.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public abstract class Action {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.io.imperihome.internal.action;

import java.util.HashMap;
Expand All @@ -7,7 +15,7 @@

/**
* Action registry. Maps ImperiHome API action name to {@link Action} implementation.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public class ActionRegistry {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.io.imperihome.internal.action;

import java.util.List;
Expand All @@ -13,7 +21,7 @@

/**
* Action performed on a DevScene. Sends an {@link OnOffType#ON} or {@link DecimalType} 1 to the Item.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public class LaunchSceneAction extends Action {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.io.imperihome.internal.action;

import java.util.Map;
Expand All @@ -15,7 +23,7 @@

/**
* Action setting a choice from a selection list, e.g. MultiSwitch.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public class SetChoiceAction extends Action {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.io.imperihome.internal.action;

import org.eclipse.smarthome.core.events.EventPublisher;
Expand All @@ -11,7 +19,7 @@

/**
* Items setting RGB color value.
* @author pdegeus
* @author Pepijn de Geus - Initial contribution
*/
public class SetColorAction extends Action {

Expand Down
Loading

0 comments on commit 46738f6

Please sign in to comment.