Skip to content

Commit

Permalink
AirQuality binding (openhab#1738)
Browse files Browse the repository at this point in the history
* AirQuality binding - initial commit

Also-by: Łukasz Dywicki <luke@code-house.org>
Signed-off-by: Kuba Wolanin <hi@kubawolanin.com>
  • Loading branch information
kubawolanin authored and cweitkamp committed Mar 26, 2017
1 parent 9541848 commit 5a0c89d
Show file tree
Hide file tree
Showing 23 changed files with 1,385 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.airquality/.classpath
@@ -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.airquality/.project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.airquality</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>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="airquality"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

<name>Air Quality Binding</name>
<description>Measure Air Quality Index and details about pollution particles for a given location</description>
<author>Kuba Wolanin</author>

</binding:binding>
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="airquality" 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">

<!-- Air Quality Thing -->
<thing-type id="aqi">
<label>Air Quality</label>
<description>
Provides various air quality data from the World Air Quality Project.
In order to receive the data, you must register an account on http://aqicn.org/data-platform/token/ and get your API token.
</description>

<channels>
<channel id="aqiLevel" typeId="aqiLevel" />
<channel id="aqiDescription" typeId="aqiDescription" />
<channel id="pm25" typeId="pm25" />
<channel id="pm10" typeId="pm10" />
<channel id="o3" typeId="o3" />
<channel id="no2" typeId="no2" />
<channel id="co" typeId="co" />
<channel id="locationName" typeId="locationName" />
<channel id="stationLocation" typeId="stationLocation" />
<channel id="stationId" typeId="stationId" />
<channel id="observationTime" typeId="observationTime" />
<channel id="temperature" typeId="temperature" />
<channel id="pressure" typeId="pressure" />
<channel id="humidity" typeId="humidity" />
</channels>

<config-description>
<parameter name="apikey" type="text" required="true">
<context>password</context>
<label>API Key</label>
<description>Data-platform token to access the AQIcn.org service</description>
</parameter>
<parameter name="location" type="text" required="false"
pattern="^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?)[,]\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$">
<label>Location</label>
<description>Your geo coordinates separated with comma (e.g. "37.8,-122.4").</description>
</parameter>
<parameter name="stationId" type="integer" required="false">
<label>Station ID</label>
<description>Fill only in case you want to receive data from the specific station</description>
</parameter>
<parameter name="refresh" type="integer" min="30" required="false">
<label>Refresh interval</label>
<description>Specifies the refresh interval in minutes.</description>
<default>60</default>
</parameter>
</config-description>
</thing-type>

<channel-type id="aqiLevel">
<item-type>Number</item-type>
<label>Air Quality Index</label>
<description></description>
<category>Air Quality Index</category>
<state readOnly="true" pattern="%d"></state>
</channel-type>

<channel-type id="aqiDescription">
<item-type>String</item-type>
<label>AQI Description</label>
<description></description>
<category>AQI Description</category>
<state readOnly="true" pattern="%s"></state>
</channel-type>

<channel-type id="pm25">
<item-type>Number</item-type>
<label>PM2.5</label>
<description>Fine particles pollution level</description>
<category>PM2.5</category>
<state readOnly="true" pattern="%d μg/m&#179;"></state>
</channel-type>

<channel-type id="pm10">
<item-type>Number</item-type>
<label>PM10</label>
<description>Coarse dust particles pollution level</description>
<category>PM10</category>
<state readOnly="true" pattern="%d μg/m&#179;"></state>
</channel-type>

<channel-type id="o3">
<item-type>Number</item-type>
<label>O3</label>
<description>Ozone level</description>
<category>O3</category>
<state readOnly="true" pattern="%.1f μg/m&#179;"></state>
</channel-type>

<channel-type id="no2">
<item-type>Number</item-type>
<label>NO2</label>
<description>Nitrogen dioxide level</description>
<category>NO2</category>
<state readOnly="true" pattern="%.1f μg/m&#179;"></state>
</channel-type>

<channel-type id="co">
<item-type>Number</item-type>
<label>CO</label>
<description>Carbon monoxide level</description>
<category>CO</category>
<state readOnly="true" pattern="%.1f μg/m&#179;"></state>
</channel-type>

<channel-type id="locationName" advanced="true">
<item-type>String</item-type>
<label>Location</label>
<description>Nearest measuring station location</description>
<category>Location</category>
<state readOnly="true" pattern="%s"></state>
</channel-type>

<channel-type id="stationLocation" advanced="true">
<item-type>Location</item-type>
<label>Station Location</label>
<description>Latitude/Longitude of the measuring station</description>
<category>Station Location</category>
<state readOnly="true" pattern="%s"></state>
</channel-type>

<channel-type id="stationId" advanced="true">
<item-type>Number</item-type>
<label>Station ID</label>
<description>Unique measuring station ID</description>
<category>Station ID</category>
<state readOnly="true" pattern="%d"></state>
</channel-type>

<channel-type id="observationTime" advanced="true">
<item-type>DateTime</item-type>
<label>Observation time</label>
<description>Observation date and time</description>
<category>Observation time</category>
<state readOnly="true"></state>
</channel-type>

<channel-type id="temperature" advanced="true">
<item-type>Number</item-type>
<label>Temperature (°C)</label>
<description>Temperature in Celsius degrees</description>
<category>Temperature (°C)</category>
<state readOnly="true" pattern="%.1f °C"></state>
</channel-type>

<channel-type id="pressure" advanced="true">
<item-type>Number</item-type>
<label>Pressure level</label>
<description></description>
<category>Pressure level</category>
<state readOnly="true" pattern="%.1f hPa"></state>
</channel-type>

<channel-type id="humidity" advanced="true">
<item-type>Number</item-type>
<label>Humidity level</label>
<description></description>
<category>Humidity level</category>
<state readOnly="true" min="0" max="100" pattern="%.2f %%">
</state>
</channel-type>

</thing:thing-descriptions>

27 changes: 27 additions & 0 deletions addons/binding/org.openhab.binding.airquality/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: AirQuality Binding
Bundle-SymbolicName: org.openhab.binding.airquality;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.1.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .
Import-Package:
com.google.common.collect,
com.google.gson,
com.google.gson.annotations,
org.apache.commons.io,
org.apache.commons.lang,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding,
org.eclipse.smarthome.core.thing.binding.builder,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
org.openhab.binding.airquality,
org.openhab.binding.airquality.handler,
org.slf4j
Service-Component: OSGI-INF/*.xml
Export-Package: org.openhab.binding.airquality,
org.openhab.binding.airquality.handler
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="binding.airquality">

<implementation class="org.openhab.binding.airquality.internal.AirQualityHandlerFactory"/>

<service>
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
</service>

</scr:component>

0 comments on commit 5a0c89d

Please sign in to comment.