Skip to content

Commit ee4fb0c

Browse files
author
Eugen Freiter
committed
add air purifier and air quality
Signed-off-by: Eugen Freiter <freiter@gmx.de>
1 parent 8aa99f1 commit ee4fb0c

24 files changed

+980
-49
lines changed

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,53 @@ After that, read the [Javadoc](http://beowulfe.github.io/HAP-Java/apidocs/) and
2222
Supported HomeKit Accessories
2323
=========
2424

25-
Current implementation is based on HAP specification Release R2 (published 2019-07-26)
26-
fully supports 29 out of 48 HomeKit accessories defined there.
25+
Current implementation is based on HAP specification Release R2 (published 2019-07-26) and
26+
fully supports 31 out of 48 HomeKit accessories defined there.
2727

2828
| HomeKit Accessory | Supported by Java-HAP |
2929
|--------------------|--------------------|
30-
| Accessory Information | :white_check_mark: yes |
31-
| Air Purifier | :x: no |
32-
| Air Quality Sensor | :x: no |
33-
| Audio Stream Management | :x: no |
34-
| Battery Service | :white_check_mark: yes |
35-
| Camera RTP Stream Management | :x: no |
36-
| Carbon Dioxide Sensor | :white_check_mark: yes |
37-
| Carbon Monoxide Sensor | :white_check_mark: yes |
38-
| Contact Sensor | :white_check_mark: yes |
39-
| Data Stream Transport Management | :x: no |
40-
| Door | :white_check_mark: yes |
41-
| Doorbell | :white_check_mark: yes |
42-
| Fan | :white_check_mark: yes |
43-
| Faucet | :x: no |
44-
| Filter Maintenance | :x: no |
45-
| Garage Door Opener | :white_check_mark: yes |
46-
| HAP Protocol Information | :x: no |
47-
| Heater Cooler | :x: no |
48-
| Humidifier Dehumidifier | :x: no |
49-
| Humidity Sensor | :white_check_mark: yes |
50-
| Irrigation System | :x: no |
51-
| Leak Sensor | :white_check_mark: yes |
52-
| Light Bulb | :white_check_mark: yes |
53-
| Light Sensor | :white_check_mark: yes |
54-
| Lock Management | :x: no |
55-
| Lock Mechanism | :white_check_mark: yes |
56-
| Microphone | :white_check_mark: yes |
57-
| Motion Sensor | :white_check_mark: yes |
58-
| Occupancy Sensor | :white_check_mark: yes |
59-
| Outlet | :white_check_mark: yes |
60-
| Security System | :white_check_mark: yes |
61-
| Service Label | :x: no |
62-
| Siri | :x: no |
63-
| Slat | :white_check_mark: yes |
64-
| Smoke Sensor | :white_check_mark: yes |
65-
| Speaker | :white_check_mark: yes |
66-
| Stateless Programmable Switch | :white_check_mark: yes |
67-
| Switch | :white_check_mark: yes |
68-
| Target Control | :x: no |
69-
| Target Control Management | :x: no |
70-
| Temperature Sensor | :white_check_mark: yes |
71-
| Thermostat | :white_check_mark: yes |
72-
| Valve | :white_check_mark: yes |
73-
| Window | :white_check_mark: yes |
74-
| Window Covering | :white_check_mark: yes |
30+
| Accessory Information | :white_check_mark: |
31+
| Air Purifier | :white_check_mark: |
32+
| Air Quality Sensor | :white_check_mark: |
33+
| Audio Stream Management | :x: |
34+
| Battery Service | :white_check_mark: |
35+
| Camera RTP Stream Management | :x: |
36+
| Carbon Dioxide Sensor | :white_check_mark: |
37+
| Carbon Monoxide Sensor | :white_check_mark: |
38+
| Contact Sensor | :white_check_mark: |
39+
| Data Stream Transport Management | :x: |
40+
| Door | :white_check_mark: |
41+
| Doorbell | :white_check_mark: |
42+
| Fan | :white_check_mark: |
43+
| Faucet | :x: |
44+
| Filter Maintenance | :x: |
45+
| Garage Door Opener | :white_check_mark: |
46+
| HAP Protocol Information | :x: |
47+
| Heater Cooler | :x: |
48+
| Humidifier Dehumidifier | :x: |
49+
| Humidity Sensor | :white_check_mark: |
50+
| Irrigation System | :x: |
51+
| Leak Sensor | :white_check_mark: |
52+
| Light Bulb | :white_check_mark: |
53+
| Light Sensor | :white_check_mark: |
54+
| Lock Management | :x: |
55+
| Lock Mechanism | :white_check_mark: |
56+
| Microphone | :white_check_mark: |
57+
| Motion Sensor | :white_check_mark: |
58+
| Occupancy Sensor | :white_check_mark: |
59+
| Outlet | :white_check_mark: |
60+
| Security System | :white_check_mark: |
61+
| Service Label | :x: |
62+
| Siri | :x: |
63+
| Slat | :white_check_mark: |
64+
| Smoke Sensor | :white_check_mark: |
65+
| Speaker | :white_check_mark: |
66+
| Stateless Programmable Switch | :white_check_mark: |
67+
| Switch | :white_check_mark: |
68+
| Target Control | :x: |
69+
| Target Control Management | :x: |
70+
| Temperature Sensor | :white_check_mark: |
71+
| Thermostat | :white_check_mark: |
72+
| Valve | :white_check_mark: |
73+
| Window | :white_check_mark: |
74+
| Window Covering | :white_check_mark: |
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airpurifier.CurrentAirPurifierStateEnum;
5+
import io.github.hapjava.characteristics.impl.airpurifier.TargetAirPurifierStateEnum;
6+
import io.github.hapjava.services.Service;
7+
import io.github.hapjava.services.impl.AirPurifierService;
8+
import java.util.Collection;
9+
import java.util.Collections;
10+
import java.util.concurrent.CompletableFuture;
11+
12+
/**
13+
* An air purifier.
14+
*
15+
* @author Eugen Freiter
16+
*/
17+
public interface AirPurifierAccessory extends HomekitAccessory {
18+
/**
19+
* Mandatory: Retrieves the current active state of the fan'.
20+
*
21+
* @return a future that will contain the binary state
22+
*/
23+
CompletableFuture<Boolean> isActive();
24+
25+
/**
26+
* Sets the active state of the fan
27+
*
28+
* @param state the binary state to set
29+
* @return a future that completes when the change is made
30+
* @throws Exception when the change cannot be made
31+
*/
32+
CompletableFuture<Void> setActive(boolean state) throws Exception;
33+
34+
/**
35+
* Subscribes to changes in the active state of the fan.
36+
*
37+
* @param callback the function to call when the direction changes.
38+
*/
39+
void subscribeActive(HomekitCharacteristicChangeCallback callback);
40+
41+
/** Unsubscribes from changes in the active state of the fan. */
42+
void unsubscribeActive();
43+
44+
/**
45+
* Retrieves the current state of the air purifier
46+
*
47+
* @return a future that will contain the state
48+
*/
49+
CompletableFuture<CurrentAirPurifierStateEnum> getCurrentState();
50+
51+
/**
52+
* Subscribes to changes in the state of the air purifier.
53+
*
54+
* @param callback the function to call when the state changes.
55+
*/
56+
void subscribeCurrentState(HomekitCharacteristicChangeCallback callback);
57+
58+
/** Unsubscribes from changes in the state of the air purifier. */
59+
void unsubscribeCurrentState();
60+
61+
/**
62+
* Retrieves the air purifier target state.
63+
*
64+
* @return a future that will contain the air purifier target state .
65+
*/
66+
CompletableFuture<TargetAirPurifierStateEnum> getTargetState();
67+
68+
/**
69+
* set target state the air purifier target state.
70+
*
71+
* @param state air purifier target state
72+
* @return a future that completes when the change is made
73+
*/
74+
CompletableFuture<Void> setTargetState(TargetAirPurifierStateEnum state);
75+
76+
/**
77+
* Subscribes to changes in the target state of the air purifier.
78+
*
79+
* @param callback the function to call when the target state changes.
80+
*/
81+
void subscribeTargetState(HomekitCharacteristicChangeCallback callback);
82+
83+
/** Unsubscribes from changes in the target state of the air purifier. */
84+
void unsubscribeTargetState();
85+
86+
@Override
87+
default Collection<Service> getServices() {
88+
return Collections.singleton(new AirPurifierService(this));
89+
}
90+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airquality.AirQualityEnum;
5+
import io.github.hapjava.services.Service;
6+
import io.github.hapjava.services.impl.AirQualityService;
7+
import java.util.Collection;
8+
import java.util.Collections;
9+
import java.util.concurrent.CompletableFuture;
10+
11+
/**
12+
* An air quality accessory which can include several sensors.
13+
*
14+
* @author Eugen Freiter
15+
*/
16+
public interface AirQualityAccessory extends HomekitAccessory {
17+
18+
/**
19+
* Retrieves the state of the air quality
20+
*
21+
* @return a future that will contain the state
22+
*/
23+
CompletableFuture<AirQualityEnum> getAirQuality();
24+
25+
/**
26+
* Subscribes to changes in the air quality
27+
*
28+
* @param callback the function to call when the air quality changes.
29+
*/
30+
void subscribeAirQuality(HomekitCharacteristicChangeCallback callback);
31+
32+
/** Unsubscribes from changes in the air quality. */
33+
void unsubscribeAirQuality();
34+
35+
@Override
36+
default Collection<Service> getServices() {
37+
return Collections.singleton(new AirQualityService(this));
38+
}
39+
}

src/main/java/io/github/hapjava/accessories/LockMechanismAccessory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public interface LockMechanismAccessory extends HomekitAccessory {
2424
CompletableFuture<LockCurrentStateEnum> getLockCurrentState();
2525

2626
/**
27-
* Retrieves the lock trget state.
27+
* Retrieves the lock target state.
2828
*
2929
* @return a future that will contain the lock target state .
3030
*/
3131
CompletableFuture<LockTargetStateEnum> getLockTargetState();
3232

3333
/**
34-
* set lock target state the lock trget state.
34+
* set lock target state the lock target state.
3535
*
3636
* @param state lock target state
3737
* @return a future that completes when the change is made
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import java.util.concurrent.CompletableFuture;
5+
6+
/**
7+
* Accessory with nitrogen dioxide density characteristic.
8+
*
9+
* @author Eugen Freiter
10+
*/
11+
public interface AccessoryWithNitrogenDioxideDensity {
12+
13+
/**
14+
* Retrieves the nitrogen dioxide density.
15+
*
16+
* @return a future with the nitrogen dioxide density
17+
*/
18+
CompletableFuture<Double> getNitrogenDioxideDensity();
19+
20+
/**
21+
* Subscribes to changes in nitrogen dioxide density.
22+
*
23+
* @param callback the function when nitrogen dioxide density changes
24+
*/
25+
void subscribeNitrogenDioxideDensity(HomekitCharacteristicChangeCallback callback);
26+
27+
/** Unsubscribes from changes */
28+
void unsubscribeNitrogenDioxideDensity();
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import java.util.concurrent.CompletableFuture;
5+
6+
/**
7+
* Accessory with Ozone Density characteristic.
8+
*
9+
* @author Eugen Freiter
10+
*/
11+
public interface AccessoryWithOzoneDensity {
12+
13+
/**
14+
* Retrieves the ozone density.
15+
*
16+
* @return a future with the ozone density
17+
*/
18+
CompletableFuture<Double> getOzoneDensity();
19+
20+
/**
21+
* Subscribes to changes in ozone density.
22+
*
23+
* @param callback the function when ozone density changes
24+
*/
25+
void subscribeOzoneDensity(HomekitCharacteristicChangeCallback callback);
26+
27+
/** Unsubscribes from changes */
28+
void unsubscribeOzoneDensity();
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import java.util.concurrent.CompletableFuture;
5+
6+
/**
7+
* Accessory with PM10 Density characteristic.
8+
*
9+
* @author Eugen Freiter
10+
*/
11+
public interface AccessoryWithPM10Density {
12+
13+
/**
14+
* Retrieves the PM10 density.
15+
*
16+
* @return a future with the PM10 density
17+
*/
18+
CompletableFuture<Double> getPM10Density();
19+
20+
/**
21+
* Subscribes to changes in PM10 density.
22+
*
23+
* @param callback the function when PM10 density changes
24+
*/
25+
void subscribePM10Density(HomekitCharacteristicChangeCallback callback);
26+
27+
/** Unsubscribes from changes */
28+
void unsubscribePM10Density();
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import java.util.concurrent.CompletableFuture;
5+
6+
/**
7+
* Accessory with PM25 Density characteristic.
8+
*
9+
* @author Eugen Freiter
10+
*/
11+
public interface AccessoryWithPM25Density {
12+
13+
/**
14+
* Retrieves the PM25 density.
15+
*
16+
* @return a future with the PM25 density
17+
*/
18+
CompletableFuture<Double> getPM25Density();
19+
20+
/**
21+
* Subscribes to changes in PM25 density.
22+
*
23+
* @param callback the function when PM25 density changes
24+
*/
25+
void subscribePM25Density(HomekitCharacteristicChangeCallback callback);
26+
27+
/** Unsubscribes from changes */
28+
void unsubscribePM25Density();
29+
}

0 commit comments

Comments
 (0)