Skip to content

EasySmartHouse/jrelay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jrelay Build Status##

This library allows you to use your relay connected to computer directly from Java. It's designed to abstract commonly used relay's drivers and has very simple API.

Rationale

Today we have a huge amount of various relay on the market with cardinal differences in hardware and driver's part, that often used as a switch for the home devices. This way we may use relay to control almost every device in our home and jrelay API was created to remove the burden of situations where you have to rewrite your code because of relay replacing, but instead you can simply switch the driver class to different one.

Features

  • Simple, thread-safe and non-blocking API,
  • No additional software required,
  • Supports multiple platforms (Windows, Linux, Mac OS, etc) and various architectures,
  • It is available as Maven dependency or standalone ZIP binary (with all dependencies included),
  • Multiple relay drivers are supported.

Supported devices

RS232 relay RS232 relay USB relay USB relay USB relay

Maven

The latest stable version is available in EasySmartHouse github repo:

Add repository:

<repository>
	<id>jrelay-mvn-repo</id>
    <url>https://raw.github.com/EasySmartHouse/jrelay/mvn-repo/</url>
    <snapshots>
       <enabled>true</enabled>
       <updatePolicy>always</updatePolicy>
    </snapshots>
</repository>

Add core dependency:

<dependency>
	<groupId>com.github.jrelay</groupId>
	<artifactId>jrelay-core</artifactId>
	<version>0.1-SNAPSHOT</version>
</dependency>

Add desired driver:

<dependency>
	<groupId>com.github.jrelay</groupId>
	<artifactId>driver-usbhid</artifactId>
	<version>0.1-SNAPSHOT</version>
</dependency>

<dependency>
	<groupId>com.github.jrelay</groupId>
	<artifactId>driver-jssc</artifactId>
	<version>0.1-SNAPSHOT</version>
</dependency>

Download

Click on to download it:

jrelay-0.1-repo.zip

Hello World

Code below will just open and then close a relay after 1 second:

public class HelloWorld {

    static {
        // set all available drivers
        Relay.setDrivers(UsbHidRelayDriver.class, JsscRelayDriver.class);
    }

    public static void main(String[] args) throws Exception{
        //get all available relays
        Relay relay = Relay.getDefault();
        //open relay
        relay.open();
        //wait 1 second
        Thread.sleep(1000l);
        //relay close
        relay.close();
    }
}

This example is available here

About

Non-blocking library for working with all types of relay on Java

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages