Skip to content

Commit

Permalink
first version of the LightControllerAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
IBims1ckoky committed Feb 13, 2022
0 parents commit 7fc0c1f
Show file tree
Hide file tree
Showing 74 changed files with 3,278 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
13 changes: 13 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: 'Features'
labels:
- 'enhancement'
- title: 'Fixes'
labels:
- 'bug'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## Changes
$CHANGES
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter 🪧

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore IntelliJ related stuff
.idea
*.iml
/out
/docs

# Gradle related stuff
.gradle
/build/
*/build/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<a href="https://playlegend.net"><img src="assets/light-api.png" width="100%"></a>

[![LightController](https://jitpack.io/v/IBims1ckoky/LightControllerAPI.svg)](https://jitpack.io/#IBims1ckoky/LightControllerAPI)
[![MissingFeature](https://img.shields.io/badge/Missing%20Feature-Open%20an%20Issue-blueviolet?style=flat-square&logo=appveyor)](https://github.com/IBims1ckoky/LightControllerAPI/issues)

# LightControllerAPI

This is an easy to use **LightControllerAPI** in for Java to control Lights from [PhillipsHue](https://www.philips-hue.com/).


# How to get started

Gradle (Default):
```gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.IBims1ckoky:LightControllerAPI:master-SNAPSHOT'
}
```

Maven:
```maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.IBims1ckoky</groupId>
<artifactId>LightControllerAPI</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
</dependencies>
```

## Visit the Wiki!

### How to get started
* [Hardware Requirements](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Hardware-Requirements)
* [Maven & Gradle](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Maven-&-Gradle)
* [Important Information](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Important-Information)
### BridgeAPI
* [BridgeIP](https://github.com/IBims1ckoky/LightControllerAPI/wiki/BridgeIP)
* [Username & Clientkey](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Username-&-Clientkey)
* [Bridge Informations](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Bridge-Informations)
* [Bridge Scanner](https://github.com/IBims1ckoky/LightControllerAPI/wiki/BridgeScanner-(Credentials))
### LampAPI
* [Get All Lamps](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Get-All-Lamps)
* [Lamp by Name](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Lamp-by-Name)
* [Lamp Brightness](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Lamp-Brightness)
* [Turn Lamps On & Off](https://github.com/IBims1ckoky/LightControllerAPI/wiki/Turn-Lamps-On-&-Off)
* [Other Updates]()
18 changes: 18 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
group = "de.maxizink"
version = "1.0-SNAPSHOT"

description = "LightController-api"

plugins {
`java-library`
}

dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.1")
implementation("io.reactivex.rxjava3:rxjava:3.1.3")
implementation("com.google.code.gson:gson:2.8.9")
implementation("org.apache.httpcomponents:httpclient:4.5.13")

api ("ch.qos.logback:logback-core:1.2.10")
api ("ch.qos.logback:logback-classic:1.2.6")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.maxizink.lightcontroller.body;

public interface HueRequestBody {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.maxizink.lightcontroller.discovery;

public enum ResourceType {

DEVICE,
BRIDGE_HOME,
ROOM,
ZONE,
LIGHT,
BUTTON,
TEMPERATURE,
LIGHT_LEVEL,
MOTION,
ENTERTAINMENT,
GROUPED_LIGHT,
DEVICE_POWER,
ZIGBEE_BRIDGE_CONNECTIVITY,
ZIGBEE_CONNECTIVITY,
ZGP_CONNECTIVITY,
BRIDGE,
HOMEKIT,
SCENE,
ENTERTAINMENT_CONFIGURATION,
PUBLIC_IMAGE,
AUTH_V1,
BEHAVIOR_SCRIPT,
BEHAVIOR_INSTANCE,
GEOFENCE,
GEOFENCE_CLIENT,
GEOLOCATION;

public static ResourceType getResourceType(final String name) {
return ResourceType.valueOf(name.toUpperCase());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.maxizink.lightcontroller.discovery.bridge.api;

import de.maxizink.lightcontroller.discovery.bridge.response.HueBridgeCredentialsResponse;
import de.maxizink.lightcontroller.injection.Service;

import java.util.concurrent.CompletableFuture;

public interface BridgeCredentialsDiscovery extends Service {

HueBridgeCredentialsResponse generateHueBridgeCredentials(final String bridgeIp);

CompletableFuture<HueBridgeCredentialsResponse> generateHueBridgeCredentialsAsync(final String bridgeIp);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.maxizink.lightcontroller.discovery.bridge.api;

import de.maxizink.lightcontroller.discovery.bridge.exception.HueBridgeIpDiscoveryException;
import de.maxizink.lightcontroller.injection.Service;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface BridgeIpDiscovery extends Service {

String discoverBridgeIP() throws HueBridgeIpDiscoveryException;

List<String> discoverAllBridgeIPs() throws HueBridgeIpDiscoveryException;

CompletableFuture<String> discoveryBridgeIPAsync();

CompletableFuture<List<String>> discoverAllBridgeIPsAsync();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.maxizink.lightcontroller.discovery.bridge.api;

import de.maxizink.lightcontroller.discovery.bridge.models.BridgeInfo;
import de.maxizink.lightcontroller.discovery.bridge.models.HueBridgeCredentials;
import de.maxizink.lightcontroller.discovery.lamp.api.HueLamp;
import de.maxizink.lightcontroller.discovery.room.api.HueRoom;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface HueBridge {

//Lamps
List<HueLamp> getLamps();

Optional<HueLamp> getLampById(final UUID uniqueId);

Optional<HueLamp> getLampByName(final String name);

//Rooms
List<HueRoom> getRooms();

Optional<HueRoom> getHueRoomById(final UUID uniqueId);

Optional<HueRoom> getHueRoomByName(final String name);

//Information
BridgeInfo getBridgeInfo();

HueBridgeCredentials getHueBridgeCredentials();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package de.maxizink.lightcontroller.discovery.bridge.api;

import de.maxizink.lightcontroller.discovery.bridge.models.HueBridgeCredentials;
import de.maxizink.lightcontroller.injection.Service;

public interface HueBridgeDiscovery extends Service {

HueBridge discoverHueBridge(final HueBridgeCredentials hueBridgeCredentials);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.maxizink.lightcontroller.discovery.bridge.body;

import de.maxizink.lightcontroller.body.HueRequestBody;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@AllArgsConstructor(staticName = "of")
@NoArgsConstructor
public class GenerateHueBridgeBody implements HueRequestBody {

private String devicetype;
private boolean generateclientkey;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.maxizink.lightcontroller.discovery.bridge.exception;

public class HueBridgeInformationDiscoveryException extends RuntimeException{

public HueBridgeInformationDiscoveryException(final String message) {
super(message);
}

public HueBridgeInformationDiscoveryException(final String message, final Throwable throwable) {
super(message, throwable);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.maxizink.lightcontroller.discovery.bridge.exception;

public class HueBridgeIpDiscoveryException extends RuntimeException {

public HueBridgeIpDiscoveryException(final String message) {
super(message);
}

public HueBridgeIpDiscoveryException(final String message, final Throwable throwable) {
super(message, throwable);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.maxizink.lightcontroller.discovery.bridge.models;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.Nullable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BridgeInfo {

private String name;
private String datastoreversion;
private String swversion;
private String apiversion;
private String mac;
private String bridgeid;
private boolean factorynew;
private @Nullable String replacesbridgeid;
private String modelid;
private String startkitid;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package de.maxizink.lightcontroller.discovery.bridge.models;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class HueBridgeCredentials {

private final String userName;
private final String clientKey;

private String ipAddress;

}
Loading

0 comments on commit 7fc0c1f

Please sign in to comment.