Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
MqttGeneric binding
Browse files Browse the repository at this point in the history
Bind Mqtt topics to things. Broker connections are listed as brigdes. A generic thing
can be added. The thing can host one or multiple channels, each linked to a mqtt state / command
topic and an own optional transformation. A channel is one of the following types:

* TextChannel
* NumberChannel
* PercentageChannel
* OnOffChannel

A channel can be configured with a transformation pattern
for an incoming message from a Mqtt state topic. This allows to extract a value from
JSON/XML/etc, as it seems to get popular on some Mqtt topics to encode multiple values into json.

Homie 3.x MQTT convention also supported (except node instances).

The handlers and all value classes are backed by tests.

Also-By: Simon Kaufmann <simon.kfm@googlemail.com>
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
Signed-off-by: David Graeff <david.graeff@web.de>
Signed-off-by: David Gräff <david.graeff@web.de>
  • Loading branch information
David Gräff committed Jul 9, 2018
1 parent c4187ce commit 7415cbc
Show file tree
Hide file tree
Showing 64 changed files with 5,358 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_includes/documentation-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<li><a href="{{docu}}/features/bindings/fsinternetradio/readme.html">FS Internet Radio</a></li>
<li><a href="{{docu}}/features/bindings/lifx/readme.html">LIFX</a></li>
<li><a href="{{docu}}/features/bindings/lirc/readme.html">LIRC</a></li>
<li><a href="{{docu}}/features/bindings/mqttgeneric/readme.html">MQTT Generic</a></li>
<li><a href="{{docu}}/features/bindings/ntp/readme.html">NTP Time Server</a></li>
<li><a href="{{docu}}/features/bindings/hue/readme.html">Philips Hue</a></li>
<li><a href="{{docu}}/features/bindings/serialbutton/readme.html">Serial Button</a></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.smarthome.io.transport.mqtt"/>
<classpathentry kind="output" path="target/test-classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.binding.mqtt.generic.test</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>
</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
@@ -0,0 +1,31 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MQTT Binding Tests
Bundle-SymbolicName: org.eclipse.smarthome.binding.mqtt.generic.test;singleton:=true
Bundle-Vendor: Eclipse.org/SmartHome
Bundle-Version: 0.10.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Fragment-Host: org.eclipse.smarthome.binding.mqtt.generic
Import-Package: com.jayway.jsonpath,
net.minidev.json,
net.minidev.json.parser,
org.eclipse.smarthome.binding.mqtt.generic,
org.eclipse.smarthome.binding.mqtt.generic.handler,
org.eclipse.smarthome.core.common.registry,
org.eclipse.smarthome.core.events,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding.builder,
org.eclipse.smarthome.core.thing.util,
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.io.mqttembeddedbroker,
org.eclipse.smarthome.test.java,
org.hamcrest;core=split,
org.junit;version="4.0.0",
org.mockito,
org.mockito.invocation,
org.mockito.mock,
org.mockito.stubbing,
org.osgi.framework,
org.osgi.service.cm;version="1.5.0",
org.osgi.service.device,
org.slf4j
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This content is produced and maintained by the Eclipse SmartHome project.

* Project home: https://eclipse.org/smarthome/

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/eclipse/smarthome

== Copyright Holders

See the NOTICE file distributed with the source code at
https://github.com/eclipse/smarthome/blob/master/NOTICE
for detailed information regarding copyright ownership.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/test/java/
output.. = target/test-classes
bin.includes = META-INF/,\
.,\
NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="false"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/>
<booleanAttribute key="default_auto_start" value="true"/>
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.smarthome.binding.mqtt.generic.test/src/test/java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="2"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.smarthome.binding.mqtt.generic.test/src\/test\/java"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.smarthome.binding.mqtt.generic.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.equinox.p2.director.app.product"/>
<booleanAttribute key="run_in_ui_thread" value="false"/>
<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,ch.qos.logback.slf4j@default:false,com.google.gson*2.7.0.v20170129-0911@default:default,com.google.guava@default:default,com.ibm.icu.base@default:default,com.ibm.icu@default:default,com.jayway.jsonpath.json-path@default:default,javax.activation@default:default,javax.annotation@default:default,javax.inject@default:default,javax.measure.unit-api@default:default,javax.transaction@default:false,javax.xml.bind@default:default,javax.xml.stream@default:default,javax.xml@default:default,net.bytebuddy.byte-buddy-agent@default:default,net.bytebuddy.byte-buddy@default:default,net.minidev.json-smart@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util@default:default,org.apache.commons.collections@default:default,org.apache.commons.io@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.lang@default:default,org.apache.commons.net@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.felix.scr@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions.supplier@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.region@default:false,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.supplement@default:default,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.util@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.help@default:default,org.eclipse.jetty.osgi.alpn.fragment@default:false,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi.util@default:default,org.eclipse.osgi@-1:true,org.eclipse.paho.client.mqttv3@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.ui.trace@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.hamcrest.core@default:default,org.hamcrest.integration@default:default,org.hamcrest.library@default:default,org.hamcrest.text@default:default,org.hamcrest@default:default,org.junit@default:default,org.mockito.mockito-core@default:default,org.objenesis@default:default,org.slf4j.api@default:default,org.w3c.css.sac@default:default,tec.uom.lib.uom-lib-common@default:default,tec.uom.se@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.eclipse.smarthome.binding.mqtt.generic.test@default:false,org.eclipse.smarthome.binding.mqtt.generic@default:default,org.eclipse.smarthome.binding.mqtt@default:default,org.eclipse.smarthome.config.core@default:default,org.eclipse.smarthome.config.discovery@default:default,org.eclipse.smarthome.config.xml@default:default,org.eclipse.smarthome.core.autoupdate@default:default,org.eclipse.smarthome.core.test@default:false,org.eclipse.smarthome.core.thing@default:default,org.eclipse.smarthome.core.transform@default:default,org.eclipse.smarthome.core@default:default,org.eclipse.smarthome.io.console@default:default,org.eclipse.smarthome.io.mqttembeddedbroker@default:true,org.eclipse.smarthome.io.transport.mqtt@default:default,org.eclipse.smarthome.test@default:default"/>
<booleanAttribute key="show_selected_only" value="true"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="false"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.smarthome.binding</groupId>
<artifactId>pom</artifactId>
<version>0.10.0-SNAPSHOT</version>
</parent>

<artifactId>org.eclipse.smarthome.binding.mqtt.generic.test</artifactId>
<name>MQTT Thing Binding Tests</name>
<packaging>eclipse-test-plugin</packaging>


<build>
<plugins>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<dependency-resolution>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>0.0.0</version>
<scope>provided</scope>
</dependency>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.jetty.osgi.boot</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.equinox.cm</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.equinox.ds</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.equinox.event</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.smarthome.config.xml</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.smarthome.core.binding.xml</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.smarthome.core.thing.xml</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.jetty.server</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.jetty.servlet</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.equinox.http.servlet</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.jetty.osgi.httpservice</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<bundleStartLevel>
<bundle>
<id>org.eclipse.jetty.osgi.boot</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.ds</id>
<level>1</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.event</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.core</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.core.thing</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.config.core</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.config.xml</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.core.thing.xml</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.smarthome.core.binding.xml</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.jetty.server</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.jetty.servlet</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.http.servlet</id>
<level>3</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.jetty.osgi.httpservice</id>
<level>3</level>
<autoStart>true</autoStart>
</bundle>
</bundleStartLevel>
<argLine>-Djetty.home.bundle=org.eclipse.jetty.osgi.boot -Djetty.port=9090</argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 7415cbc

Please sign in to comment.