Skip to content

magx2/jSuplaApi

Repository files navigation

jSuplaApi


jSuplaApi
IoT with Java and Supla

This library is client for Supla Cloud.

Swagger documentation can be found here:

Example Usage

import pl.grzeslowski.jsupla.api.Api;

class Main {
    public static void main(String[] args) {
        final String token = "MzFhYTNiZTAwODg5M2E0NDE3OGUwNWE5ZjYzZWQ2YzllZGFiYWRmNDQwNDBlNmZhZGEzN2I3NTJiOWM2ZWEyZg" +
                             ".aHR0cDovL2xvY2FsaG9zdDo5MDkw"; // This part is base64 encoded server URL
        Api api = Api.getInstance(token);

        // Get API version
        final String apiVersion = api.getVersion();
        System.out.println("Current API version: " + apiUsageStatistics);

        // Find all Channels
        api.getChannelApi()
            .findChannels()
            .forEach(System.out::println);

        // Find all devices
        api.getDeviceApi()
            .findDevices()
            .forEach(System.out::println);
        
        // How to check API usage statistics
        final String apiUsageStatistics = api.getApiUsageStatistics()
        			.map(it -> it.toString())
        			.orElse("<none>");
        System.out.println("Your API usage statistics: " + apiUsageStatistics);
    }
}

Installation

Maven Users

Add this dependency to your project's POM:

<dependency>
  <groupId>pl.grzeslowski.jsupla.api</groupId>
  <artifactId>jsupla-api</artifactId>
  <version>${jSuplaApi.version}</version>
  <type>compile</type>
</dependency>

Gradle Users

Add this dependency to your project's build file:

implementation 'pl.grzeslowski.jsupla.api:jsupla-api:$jSuplaApiVersion'

Fat Jar Artifact

From version 3.8.x you can use jsupla-api-fat artifact to import jSuplaApi jar with all its dependencies.

Plain Jar

At first generate the JAR by executing:

gradlew clean build

Then manually install the following JARs:

  • build/libs/jsupla-api-<version>.jar

Releases

Auto generated release Notes.

This software is proudly released with Shipkit.

Recommendation

It's recommended to create an instance of Api per thread in a multithreaded environment to avoid any potential issues.

Related Projects

  1. jSupla - Javas implementation of Supla protocol
  2. OpenHAB binding - Binding for OpenHAB
  3. jSuplaServerMock - Mock implementation of Supla Cloud
  4. jSuplaGui - GUI for Supla Cloud

Author(s)

Martin Grześlowski (github/magx2)