Skip to content

Commit

Permalink
Merge pull request openhab#1 from kubawolanin/mihome
Browse files Browse the repository at this point in the history
Xiaomi Smart Home Binding - code review followup + battery level report
  • Loading branch information
pboos authored Feb 20, 2017
2 parents 22f4d0c + 1303801 commit 0b7fdd5
Show file tree
Hide file tree
Showing 21 changed files with 555 additions and 368 deletions.
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.mihome/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions addons/binding/org.openhab.binding.mihome/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.mihome</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

<name>Xiaomi Mi Smart Home Binding</name>
<description>This is the binding for Xiaomi Mi Smart Home.</description>
<description>Connects to Xiaomi Smart Gateway v2 and allows to communicate with Xiaomi Mi Smart Home suite (also called Xiaomi Aqara).
The Gateway connects with a range of Xiaomi Zigbee sensors such as Wireless Switch, Wall Plug or Temperature Sensor.</description>
<author>Patrick Boos</author>

</binding:binding>
14 changes: 10 additions & 4 deletions addons/binding/org.openhab.binding.mihome/ESH-INF/thing/bridge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<!-- Xiaomi Mi Smart Home Bridge -->
<bridge-type id="bridge">
<label>Xiaomi Mi Smart Home Bridge</label>
<description>The Xiaomi Mi Smart Home Bride.</description>
<description>Multifunctional Gateway - a bridge for the sensors. One button click turns on/off the device. Two clicks toggle "home security" feature.
Three button clicks allow you to link the Xiaomi Zigbee devices with the Gateway. After you press the button 3 times, the light will flash blue;
After that you'll be able to add new sensors by pressing their hole button for 3 seconds.</description>

<properties>
<property name="vendor">Xiaomi</property>
Expand All @@ -16,22 +18,25 @@
<config-description>
<parameter name="serialNumber" type="text" readOnly="true">
<label>Serial Number</label>
<description>Serial number of the xiaomi bridge.</description>
<description>Serial number of the Xiaomi bridge.</description>
<required>true</required>
</parameter>

<parameter name="ipAddress" type="text" readOnly="true">
<context>network_address</context>
<label>Network Address</label>
<description>Network address of the xiaomi bridge.</description>
<description>Network address of the Xiaomi bridge.</description>
<required>true</required>
</parameter>

<parameter name="port" type="integer" readOnly="true">
<context>network_address</context>
<label>Port</label>
<description>Port of the xiaomi bridge.</description>
<description>Port of the Xiaomi bridge.</description>
<required>true</required>
<default>9898</default>
</parameter>

<parameter name="key" type="text">
<context>password</context>
<label>Developer Key</label>
Expand All @@ -40,6 +45,7 @@
</description>
<required>false</required>
</parameter>

<parameter name="pollingInterval" type="integer" min="1" step="1">
<label>Polling Interval</label>
<description>Seconds between fetching values from the Bridge.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>

<label>Gateway</label>
<description>Gateway</description>
<label>Xiaomi Mi Smart Home Gateway</label>
<description>Multifunctional Gateway. One button click turns on/off the device. Two clicks toggle "home security" feature.
Three button clicks allow you to link the Xiaomi Zigbee devices with the Gateway. After you press the button 3 times, the light will flash blue;
After that you'll be able to add new sensors by pressing their hole button for 3 seconds.
</description>

<channels>
<channel id="brightness" typeId="brightness"/>
Expand Down Expand Up @@ -39,22 +42,25 @@
<tag>Lighting</tag>
</tags>
</channel-type>

<channel-type id="color">
<item-type>Color</item-type>
<label>Color</label>
<description>The color channel allows to control the color of a light.</description>
<description>Control the color of light.</description>
<category>ColorLight</category>
<tags>
<tag>Lighting</tag>
</tags>
</channel-type>

<channel-type id="colorTemperature">
<item-type>Dimmer</item-type>
<label>ColorTemperature</label>
<description>The CT channel allows to control the CT of a light.</description>
<label>Color Temperature</label>
<description>Allows to control the color temperature of light.</description>
<category>DimmableCT</category>
<tags>
<tag>ColorTemperature</tag>
</tags>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>

<label>Cube</label>
<description>Magic Controller (Cube)</description>
<label>Xiaomi Mi Smart Cube</label>
<description>Multifunctional controller equipped with an accelerometer and a gyroscope. Triggers the following actions: move, rotate, rotate, flip 90, flip 180, tap twice, shake air, free fall, alert.</description>

<channels>
<channel id="action" typeId="action"/>
Expand All @@ -25,7 +25,7 @@
</config-description>
</thing-type>

<channel-type id="action" advanced="true">
<channel-type id="action">
<kind>trigger</kind>
<label>Cube event</label>
<event>
Expand Down
117 changes: 70 additions & 47 deletions addons/binding/org.openhab.binding.mihome/ESH-INF/thing/sensor_ht.xml
Original file line number Diff line number Diff line change
@@ -1,49 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="mihome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

<thing-type id="sensor_ht">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>

<label>Temperature &amp; Humidity Sensor</label>
<description>Temperature &amp; Humidity Sensor</description>

<channels>
<channel id="temperature" typeId="temperature"/>
<channel id="humidity" typeId="humidity"/>
</channels>

<config-description>
<parameter name="itemId" type="text" readOnly="true">
<label>Item ID</label>
<description>An identifier for the item connected.</description>
<required>true</required>
</parameter>
</config-description>
</thing-type>

<channel-type id="temperature" advanced="true">
<item-type>Number</item-type>
<label>Temperature</label>
<category>Temperature</category>
<tags>
<tag>weather</tag>
</tags>
<state min="-50" max="60" step="0.1" pattern="%.1f °C" readOnly="true">
</state>
</channel-type>
<channel-type id="humidity" advanced="true">
<item-type>Number</item-type>
<label>Humidity</label>
<category>Humidity</category>
<tags>
<tag>weather</tag>
</tags>
<state min="0" max="100" step="0.1" pattern="%.1f%%" readOnly="true">
</state>
</channel-type>
<thing:thing-descriptions bindingId="mihome" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

<thing-type id="sensor_ht">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge" />
</supported-bridge-type-refs>

<label>Xiaomi Mi Temperature &amp; Humidity Sensor</label>
<description>Reports temperature and humidity. Operating temperature: −20°C to 60°C. Operating humidity: 0 to 100%.
Sensor reports the temperature when there's a difference around 0.5°C. If there is no significant temperature change, sensor reports temperature once a 50 minutes.\
</description>

<channels>
<channel id="temperature" typeId="temperature" />
<channel id="humidity" typeId="humidity" />
<channel id="voltage" typeId="voltage" />
<channel id="batteryLevel" typeId="batteryLevel" />
</channels>

<config-description>
<parameter name="itemId" type="text" readOnly="true">
<label>Item ID</label>
<description>An identifier for the item connected.</description>
<required>true</required>
</parameter>
</config-description>
</thing-type>

<channel-type id="temperature">
<item-type>Number</item-type>
<label>Temperature</label>
<category>Temperature</category>
<tags>
<tag>weather</tag>
</tags>
<state min="-50" max="60" step="0.1" pattern="%.1f °C" readOnly="true">
</state>
</channel-type>

<channel-type id="humidity">
<item-type>Number</item-type>
<label>Humidity</label>
<category>Humidity</category>
<tags>
<tag>weather</tag>
</tags>
<state min="0" max="100" step="0.1" pattern="%.1f%%" readOnly="true">
</state>
</channel-type>

<channel-type id="voltage" advanced="true">
<item-type>Number</item-type>
<label>Battery Voltage</label>
<category>Battery Voltage</category>
<state pattern="%d mv" readOnly="true"></state>
</channel-type>

<channel-type id="batteryLevel" advanced="true">
<kind>trigger</kind>
<label>Low Battery Level</label>
<description>Triggers LOW event when voltage is below 2800 mv</description>
<event>
<options>
<option value="LOW">low</option>
</options>
</event>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="mihome"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

<thing-type id="sensor_magnet">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>

<label>Door/Window Sensor</label>
<description>Sensor for Door/Window to detect open/closed state.</description>

<channels>
<channel id="isOpen" typeId="isOpen"/>
</channels>

<config-description>
<parameter name="itemId" type="text" readOnly="true">
<label>Item ID</label>
<description>An identifier for the item connected.</description>
<required>true</required>
</parameter>
</config-description>
</thing-type>

<channel-type id="isOpen" advanced="true">
<item-type>Contact</item-type>
<label>Open Status</label>
<category>Contact</category>
<state readOnly="true"></state>
</channel-type>
<thing:thing-descriptions bindingId="mihome" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

<thing-type id="sensor_magnet">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge" />
</supported-bridge-type-refs>

<label>Xiaomi Door/Window Sensor</label>
<description>Contact sensor mounted on doors or windows. Detects states: open and closed.</description>

<channels>
<channel id="isOpen" typeId="isOpen" />
<channel id="voltage" typeId="voltage" />
<channel id="batteryLevel" typeId="batteryLevel" />
</channels>

<config-description>
<parameter name="itemId" type="text" readOnly="true">
<label>Item ID</label>
<description>An identifier for the item connected.</description>
<required>true</required>
</parameter>
</config-description>
</thing-type>

<channel-type id="isOpen">
<item-type>Contact</item-type>
<label>Open Status</label>
<category>Contact</category>
<state readOnly="true"></state>
</channel-type>

<channel-type id="voltage" advanced="true">
<item-type>Number</item-type>
<label>Battery Voltage</label>
<category>Battery Voltage</category>
<state pattern="%d mv" readOnly="true"></state>
</channel-type>

<channel-type id="batteryLevel" advanced="true">
<kind>trigger</kind>
<label>Low Battery Level</label>
<description>Triggers LOW event when voltage is below 2800 mv</description>
<event>
<options>
<option value="LOW">low</option>
</options>
</event>
</channel-type>

</thing:thing-descriptions>
Loading

0 comments on commit 0b7fdd5

Please sign in to comment.