Skip to content

Refactoring for optional #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b099f56
Merge pull request #3 from hap-java/master
yfre Oct 18, 2019
97d066a
Merge pull request #4 from hap-java/master
yfre Mar 10, 2020
9aa77d5
major refactoring to support optional attributes
yfre Mar 15, 2020
68f09a7
add name, active and fault interfaces
yfre Mar 15, 2020
fc078d1
make service characteristics complete
yfre Mar 16, 2020
428ea3d
update CHANGES.md and README.md
yfre Mar 16, 2020
9c91d82
Apply J-N-K patches for Openhab. update dependencies to be aligned wi…
yfre Mar 17, 2020
ad9ab2c
fix some typos in the characteristics descriptions
yfre Mar 31, 2020
3cfad1d
fix for javadoc bug
Apr 26, 2020
4b8ba89
fix potential NPE. adapt log level
Apr 26, 2020
5f404f8
fix typo and add some logging
Apr 26, 2020
c640cdb
Add Doorbell, Microphone, Slat, Speaker, StatelessProgrammableSwitch …
Apr 29, 2020
8aa99f1
update readme
Apr 29, 2020
ee4fb0c
add air purifier and air quality
Apr 29, 2020
110a359
reduce log leve. align more with OH guidance on logging
May 3, 2020
0db27e8
add service label service and hap protocol version service. fix Mute …
May 5, 2020
f9502d2
fix the Id for TargetHorizontalTiltAngleCharacteristic
May 7, 2020
12e3b45
add Faucet and HeaterCooler
May 12, 2020
8d692a1
add humidifier dehumidifier accessory
May 12, 2020
9e4985b
add irrigation system, clean up javadocs
May 12, 2020
2b7e9d7
remove reference to spec
May 16, 2020
1372385
add support for custom min/max values for temperatures
May 24, 2020
7fcc492
fix typos. add support for custom min/max values for threshold tempe…
May 24, 2020
1720a25
add constants for default min/max values
May 24, 2020
6d13db3
put debugData back
May 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# HAP-Java 2.0.0
* major refactoring to support optional characteristics
* structure and names adapted to HAP spec structure and naming.
* structure is following
* `accessory` package include basis accessory as the listed in HAP spec, plus interfaces for optional characteristics. clients should extend the accessory classes. e.g. `WindowCoveringAccessory` or `AccessoryWithBrightness`
* `characteristics` package consists of all characteristics, optional and mandatory. e.g. `TargetHorizontalTiltAngleCharacteristic`. The naming is done in accordance to HAP spec.
* `services` package consists of services, which grouping characteristics. e.g. `WindowCoveringService` defines mandatory and optional characteristics for a window covering service as it is defined in HAP spec.
* `server` package consists classes to run HomeKit server and handle communication
* the process is following: client, e.g. openHAB bindings, extends accessory classes, e.g. `WindowCoveringAccessory` and implements all required methods. WindowCoveringAccessory is linked already to WindowCoveringService, that in turn is link to single characteristics.

# HAP-Java 1.1.5

## Fixes
Expand Down
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,74 @@
HAP-Java
=========
HAP-Java is a Java implementation of the Homekit Accessory Protocol.
HAP-Java is a Java implementation of the HomeKit Accessory Protocol.

Using this library, you can create your own Homekit Accessory or Homekit Accessory Bridge.

Because the MFi Specification is closed to individual developers, and this implementation was made without access to that specification, it may not be complete. iOS devices do recognize and are able to interact with accessories exposed via this library however.
Using this library, you can create your own HomeKit Accessory or HomeKit Accessory Bridge.

This library would not have been possible without [Tian Zhang](https://github.com/KhaosT) who did a lot of the hard work of figuring out how the protocol works in his NodeJS implementation.

Usage
=========
Include HAP-Java in your project using maven:

```
<dependency>
<groupId>io.github.hap-java</groupId>
<artifactId>hap</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</dependency>
```

After that, read the [Javadoc](http://beowulfe.github.io/HAP-Java/apidocs/) and check out the [Sample](https://github.com/beowulfe/HAP-Java/tree/sample).
After that, check out the [Sample](https://github.com/hap-java/HAP-Java/tree/sample).

Supported HomeKit Accessories
=========

Current implementation fully supports 37 HomeKit accessory/services.

| HomeKit Accessory & Service type | Supported by Java-HAP |
|--------------------|--------------------|
| Accessory Information | :white_check_mark: |
| Air Purifier | :white_check_mark: |
| Air Quality Sensor | :white_check_mark: |
| Audio Stream Management | :x: |
| Battery Service | :white_check_mark: |
| Camera RTP Stream Management | :x: |
| Carbon Dioxide Sensor | :white_check_mark: |
| Carbon Monoxide Sensor | :white_check_mark: |
| Contact Sensor | :white_check_mark: |
| Data Stream Transport Management | :x: |
| Door | :white_check_mark: |
| Doorbell | :white_check_mark: |
| Fan | :white_check_mark: |
| Faucet | :white_check_mark: |
| Filter Maintenance | :x: |
| Garage Door Opener | :white_check_mark: |
| HAP Protocol Information | :white_check_mark: |
| Heater Cooler | :white_check_mark: |
| Humidifier Dehumidifier | :white_check_mark: |
| Humidity Sensor | :white_check_mark: |
| Irrigation System | :white_check_mark: |
| Leak Sensor | :white_check_mark: |
| Light Bulb | :white_check_mark: |
| Light Sensor | :white_check_mark: |
| Lock Management | :x: |
| Lock Mechanism | :white_check_mark: |
| Microphone | :white_check_mark: |
| Motion Sensor | :white_check_mark: |
| Occupancy Sensor | :white_check_mark: |
| Outlet | :white_check_mark: |
| Security System | :white_check_mark: |
| Service Label | :white_check_mark: |
| Siri | :x: |
| Slat | :white_check_mark: |
| Smoke Sensor | :white_check_mark: |
| Speaker | :white_check_mark: |
| Stateless Programmable Switch | :white_check_mark: |
| Switch | :white_check_mark: |
| Target Control | :x: |
| Target Control Management | :x: |
| Temperature Sensor | :white_check_mark: |
| Thermostat | :white_check_mark: |
| Valve | :white_check_mark: |
| Window | :white_check_mark: |
| Window Covering | :white_check_mark: |
61 changes: 47 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<artifactId>hap</artifactId>
<name>hap-java</name>
<description>Homekit Accessory Protocol for Java</description>
<version>1.2.0-snapshot</version>
<version>2.0.0-snapshot</version>
<packaging>jar</packaging>
<url>https://github.com/hap-java/HAP-Java</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<netty.version>4.1.42.Final</netty.version>

</properties>

<licenses>
<license>
Expand Down Expand Up @@ -56,8 +58,44 @@

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.32.Final</version>
<artifactId>netty-common</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -102,12 +140,6 @@
<version>3.4.1</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -163,9 +195,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.0</version>
<configuration>
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
<source>8</source>
</configuration>
<executions>
<execution>
Expand All @@ -178,7 +211,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<configuration>
<descriptors>
<descriptor>deploy/distribution.xml</descriptor>
Expand Down Expand Up @@ -272,7 +305,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
</configuration>
<reportSets>
<reportSet>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package io.github.hapjava.accessories;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.airpurifier.CurrentAirPurifierStateEnum;
import io.github.hapjava.characteristics.impl.airpurifier.TargetAirPurifierStateEnum;
import io.github.hapjava.services.Service;
import io.github.hapjava.services.impl.AirPurifierService;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;

/** An air purifier. */
public interface AirPurifierAccessory extends HomekitAccessory {
/**
* Mandatory: Retrieves the current active state of the fan'.
*
* @return a future that will contain the binary state
*/
CompletableFuture<Boolean> isActive();

/**
* Sets the active state of the fan
*
* @param state the binary state to set
* @return a future that completes when the change is made
* @throws Exception when the change cannot be made
*/
CompletableFuture<Void> setActive(boolean state) throws Exception;

/**
* Subscribes to changes in the active state of the fan.
*
* @param callback the function to call when the direction changes.
*/
void subscribeActive(HomekitCharacteristicChangeCallback callback);

/** Unsubscribes from changes in the active state of the fan. */
void unsubscribeActive();

/**
* Retrieves the current state of the air purifier
*
* @return a future that will contain the state
*/
CompletableFuture<CurrentAirPurifierStateEnum> getCurrentState();

/**
* Subscribes to changes in the state of the air purifier.
*
* @param callback the function to call when the state changes.
*/
void subscribeCurrentState(HomekitCharacteristicChangeCallback callback);

/** Unsubscribes from changes in the state of the air purifier. */
void unsubscribeCurrentState();

/**
* Retrieves the air purifier target state.
*
* @return a future that will contain the air purifier target state .
*/
CompletableFuture<TargetAirPurifierStateEnum> getTargetState();

/**
* set target state the air purifier target state.
*
* @param state air purifier target state
* @return a future that completes when the change is made
*/
CompletableFuture<Void> setTargetState(TargetAirPurifierStateEnum state);

/**
* Subscribes to changes in the target state of the air purifier.
*
* @param callback the function to call when the target state changes.
*/
void subscribeTargetState(HomekitCharacteristicChangeCallback callback);

/** Unsubscribes from changes in the target state of the air purifier. */
void unsubscribeTargetState();

@Override
default Collection<Service> getServices() {
return Collections.singleton(new AirPurifierService(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.hapjava.accessories;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.airquality.AirQualityEnum;
import io.github.hapjava.services.Service;
import io.github.hapjava.services.impl.AirQualityService;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;

/** An air quality accessory which can include several sensors. */
public interface AirQualityAccessory extends HomekitAccessory {

/**
* Retrieves the state of the air quality
*
* @return a future that will contain the state
*/
CompletableFuture<AirQualityEnum> getAirQuality();

/**
* Subscribes to changes in the air quality
*
* @param callback the function to call when the air quality changes.
*/
void subscribeAirQuality(HomekitCharacteristicChangeCallback callback);

/** Unsubscribes from changes in the air quality. */
void unsubscribeAirQuality();

@Override
default Collection<Service> getServices() {
return Collections.singleton(new AirQualityService(this));
}
}
Loading