-
Notifications
You must be signed in to change notification settings - Fork 84
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
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 97d066a
Merge pull request #4 from hap-java/master
yfre 9aa77d5
major refactoring to support optional attributes
yfre 68f09a7
add name, active and fault interfaces
yfre fc078d1
make service characteristics complete
yfre 428ea3d
update CHANGES.md and README.md
yfre 9c91d82
Apply J-N-K patches for Openhab. update dependencies to be aligned wi…
yfre ad9ab2c
fix some typos in the characteristics descriptions
yfre 3cfad1d
fix for javadoc bug
4b8ba89
fix potential NPE. adapt log level
5f404f8
fix typo and add some logging
c640cdb
Add Doorbell, Microphone, Slat, Speaker, StatelessProgrammableSwitch …
8aa99f1
update readme
ee4fb0c
add air purifier and air quality
110a359
reduce log leve. align more with OH guidance on logging
0db27e8
add service label service and hap protocol version service. fix Mute …
f9502d2
fix the Id for TargetHorizontalTiltAngleCharacteristic
12e3b45
add Faucet and HeaterCooler
8d692a1
add humidifier dehumidifier accessory
9e4985b
add irrigation system, clean up javadocs
2b7e9d7
remove reference to spec
1372385
add support for custom min/max values for temperatures
7fcc492
fix typos. add support for custom min/max values for threshold tempe…
1720a25
add constants for default min/max values
6d13db3
put debugData back
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/io/github/hapjava/accessories/AirPurifierAccessory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/hapjava/accessories/AirQualityAccessory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.