openwebnet/rx-openwebnet


OpenWebNet Java client

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.openwebnet:rx-openwebnet:2.1.1'
	}
	dependencies {
		implementation("com.github.openwebnet:rx-openwebnet:2.1.1")
	}
	<dependency>
	    <groupId>com.github.openwebnet</groupId>
	    <artifactId>rx-openwebnet</artifactId>
	    <version>2.1.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.openwebnet" % "rx-openwebnet" % "2.1.1"
        
        

                            
    :dependencies [[com.github.openwebnet/rx-openwebnet "2.1.1"]]
        
        

Readme


rx-openwebnet

Build Status Download

OpenWebNet Java client with RxJava, see also the documentation

Supported frames

  • WHO=1 Lighting Javadoc
  • WHO=2 Automation Javadoc
  • WHO=4 Heating Javadoc
  • WHO=16 SoundSystem Javadoc
  • WHO=17 Scenario Javadoc
  • WHO=18 EnergyManagement Javadoc
  • a single generic frame/message
  • a list of generic frames/messages

Setup

Add the dependency to build.gradle

repositories {
    jcenter()
}
dependencies {
    compile 'com.github.openwebnet:rx-openwebnet:2.1.1'
}

Examples


// connects to the default gateway
OpenWebNet simpleClient = OpenWebNet.newClient(OpenWebNet.defaultGateway("192.168.1.41"));

// requests status light 21
simpleClient
    .send(Lighting.requestStatus("21"))
    .map(Lighting.handleStatus(() -> System.out.println("ON"), () -> System.out.println("OFF")))
    .subscribe(System.out::println);

// connects to the gateway with domain and password
OpenWebNet client = OpenWebNet.newClient(OpenWebNet.gateway("vpn.home.it", 20000, "12345"));

// turns light 21 on    
client
    .send(Lighting.requestTurnOn("21"))
    .map(Lighting.handleResponse(() -> System.out.println("success"), () -> System.out.println("fail")))
    .subscribe(System.out::println);
    

// sends a list of generic frames/messages with a custom thread pool
ExecutorService executor = Executors.newSingleThreadExecutor();
OpenWebNet
    .newClient(OpenWebNet.gateway("192.168.1.41", 20000))
    .send(Arrays.asList(() -> "*#1*21##", () -> "*#1*22##"))
    .subscribeOn(Schedulers.from(executor))
    .doOnError(throwable -> System.out.println("ERROR " + throwable))
    .doAfterTerminate(() -> executor.shutdown())
    .subscribe(System.out::println, throwable -> {});

// turns light 21 on with a custom scheduler on Android
OpenWebNet
    .newClient(OpenWebNet.gateway("10.0.2.2", 20000))
    .send(Lighting.requestTurnOff("21"))
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .map(Lighting.handleResponse(() -> System.out.println("success"), () -> System.out.println("fail")))
    .subscribe(System.out::println, throwable -> {});
    

Development

export JAVA_HOME='/usr/lib/jvm/java-8-oracle'

./gradlew clean build

# verbose tests
./gradlew :lib:test --debug

# run example
./gradlew runOpenWebNetExample

# update javadocs
./gradlew copyJavaDoc

# publish javadoc
git subtree push --prefix javadoc origin gh-pages

# publish on bintray
./gradlew bintrayUpload

# list tasks
./gradlew tasks

# upgrade gradle version
./gradlew wrapper --gradle-version=4.6

# verify jar content
unzip lib/build/libs/lib-2.1.1.jar -d /tmp/openwebnet-jar

Command Line Interface

# build uber jar
./gradlew shadowJar

# show usage
java -jar lib/build/libs/openwebnet-2.1.1.jar

# example simple
java -jar lib/build/libs/openwebnet-2.1.1.jar \
  -h 192.168.1.41 \
  -f *#1*21##

# example complete
java -jar lib/build/libs/openwebnet-2.1.1.jar \
  --host "192.168.1.41" \
  --port 8080 \
  --password "12345" \
  --frame "*#1*21##"
<!-- TODO * [publish bintray + travis-ci](http://docs.travis-ci.com/user/deployment/bintray/) * missing tests * test coverage * unsubscribe and close socket -->