Skip to content

Commit eefe56a

Browse files
authored
Merge pull request #136 from yfre/further_min_max_values
extend support for custom min/max/step to further characteristics
2 parents dd97a77 + c9e61c7 commit eefe56a

32 files changed

+646
-40
lines changed

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

+31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.lightsensor.CurrentAmbientLightLevelCharacteristic;
45
import io.github.hapjava.services.Service;
56
import io.github.hapjava.services.impl.LightSensorService;
67
import java.util.Collection;
@@ -31,6 +32,36 @@ public interface LightSensorAccessory extends HomekitAccessory {
3132
/** Unsubscribes from changes in the current ambient light level. */
3233
void unsubscribeCurrentAmbientLightLevel();
3334

35+
/**
36+
* return the min value for current ambient light level. overwrite if you want to change the
37+
* default value.
38+
*
39+
* @return min current ambient light level
40+
*/
41+
default double getMinCurrentAmbientLightLevel() {
42+
return CurrentAmbientLightLevelCharacteristic.DEFAULT_MIN_VALUE;
43+
}
44+
45+
/**
46+
* return the max value for current ambient light level. overwrite if you want to change the
47+
* default value.
48+
*
49+
* @return max current ambient light level
50+
*/
51+
default double getMaxCurrentAmbientLightLevel() {
52+
return CurrentAmbientLightLevelCharacteristic.DEFAULT_MAX_VALUE;
53+
}
54+
55+
/**
56+
* return the min step value for current ambient light level. overwrite if you want to change the
57+
* default value.
58+
*
59+
* @return min step current ambient light level
60+
*/
61+
default double getMinStepCurrentAmbientLightLevel() {
62+
return CurrentAmbientLightLevelCharacteristic.DEFAULT_STEP;
63+
}
64+
3465
@Override
3566
default Collection<Service> getServices() {
3667
return Collections.singleton(new LightSensorService(this));

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCarbonDioxideLevel.java

+62
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.carbondioxidesensor.CarbonDioxideLevelCharacteristic;
5+
import io.github.hapjava.characteristics.impl.carbondioxidesensor.CarbonDioxidePeakLevelCharacteristic;
46
import java.util.concurrent.CompletableFuture;
57

68
/** Accessory with carbon dioxide level and peak level characteristic. */
@@ -20,6 +22,66 @@ public interface AccessoryWithCarbonDioxideLevel {
2022
*/
2123
CompletableFuture<Double> getCarbonDioxideLevel();
2224

25+
/**
26+
* return the min value for carbon dioxide level. overwrite if you want to change the default
27+
* value.
28+
*
29+
* @return min carbon dioxide level
30+
*/
31+
default double getMinCarbonDioxideLevel() {
32+
return CarbonDioxideLevelCharacteristic.DEFAULT_MIN_VALUE;
33+
}
34+
35+
/**
36+
* return the max value for carbon dioxide level. overwrite if you want to change the default
37+
* value.
38+
*
39+
* @return max carbon dioxide level
40+
*/
41+
default double getMaxCarbonDioxideLevel() {
42+
return CarbonDioxideLevelCharacteristic.DEFAULT_MAX_VALUE;
43+
}
44+
45+
/**
46+
* return the min step value for carbon dioxide level. overwrite if you want to change the default
47+
* value.
48+
*
49+
* @return min step carbon dioxide level
50+
*/
51+
default double getMinStepCarbonDioxideLevel() {
52+
return CarbonDioxideLevelCharacteristic.DEFAULT_STEP;
53+
}
54+
55+
/**
56+
* return the min value for carbon dioxide peak level. overwrite if you want to change the default
57+
* value.
58+
*
59+
* @return min carbon dioxide peak level
60+
*/
61+
default double getMinCarbonDioxidePeakLevel() {
62+
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_MIN_VALUE;
63+
}
64+
65+
/**
66+
* return the max value for carbon dioxide peak level. overwrite if you want to change the default
67+
* value.
68+
*
69+
* @return max carbon dioxide peak level
70+
*/
71+
default double getMaxCarbonDioxidePeakLevel() {
72+
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_MAX_VALUE;
73+
}
74+
75+
/**
76+
* return the min step value for carbon dioxide peak level. overwrite if you want to change the
77+
* default value.
78+
*
79+
* @return min step carbon dioxide peak level
80+
*/
81+
default double getMinStepCarbonDioxidePeakLevel() {
82+
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_STEP;
83+
}
84+
2385
/**
2486
* Subscribes to changes in the carbon dioxide level.
2587
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithCarbonMonoxideLevel.java

+63-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.carbonmonoxidesensor.CarbonMonoxideLevelCharacteristic;
5+
import io.github.hapjava.characteristics.impl.carbonmonoxidesensor.CarbonMonoxidePeakLevelCharacteristic;
46
import java.util.concurrent.CompletableFuture;
57

6-
/** Accessory with carbon dioxide level and peak level characteristic. */
8+
/** Accessory with carbon monoxide level and peak level characteristic. */
79
public interface AccessoryWithCarbonMonoxideLevel {
810

911
/**
@@ -20,6 +22,66 @@ public interface AccessoryWithCarbonMonoxideLevel {
2022
*/
2123
CompletableFuture<Double> getCarbonMonoxideLevel();
2224

25+
/**
26+
* return the min value for carbon monoxide level. overwrite if you want to change the default
27+
* value.
28+
*
29+
* @return min carbon monoxide level
30+
*/
31+
default double getMinCarbonMonoxideLevel() {
32+
return CarbonMonoxideLevelCharacteristic.DEFAULT_MIN_VALUE;
33+
}
34+
35+
/**
36+
* return the max value for carbon monoxide level. overwrite if you want to change the default
37+
* value.
38+
*
39+
* @return max carbon monoxide level
40+
*/
41+
default double getMaxCarbonMonoxideLevel() {
42+
return CarbonMonoxideLevelCharacteristic.DEFAULT_MAX_VALUE;
43+
}
44+
45+
/**
46+
* return the min step value for carbon monoxide level. overwrite if you want to change the
47+
* default value.
48+
*
49+
* @return min step carbon monoxide level
50+
*/
51+
default double getMinStepCarbonMonoxideLevel() {
52+
return CarbonMonoxideLevelCharacteristic.DEFAULT_STEP;
53+
}
54+
55+
/**
56+
* return the min value for carbon monoxide peak level. overwrite if you want to change the
57+
* default value.
58+
*
59+
* @return min carbon monoxide peak level
60+
*/
61+
default double getMinCarbonMonoxidePeakLevel() {
62+
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_MIN_VALUE;
63+
}
64+
65+
/**
66+
* return the max value for carbon monoxide peak level. overwrite if you want to change the
67+
* default value.
68+
*
69+
* @return max carbon monoxide peak level
70+
*/
71+
default double getMaxCarbonMonoxidePeakLevel() {
72+
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_MAX_VALUE;
73+
}
74+
75+
/**
76+
* return the min step value for carbon monoxide peak level. overwrite if you want to change the
77+
* default value.
78+
*
79+
* @return min step carbon monoxide peak level
80+
*/
81+
default double getMinStepCarbonMonoxidePeakLevel() {
82+
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_STEP;
83+
}
84+
2385
/**
2486
* Subscribes to changes in the carbon monoxide level.
2587
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithColorTemperature.java

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.lightbulb.ColorTemperatureCharacteristic;
45
import java.util.concurrent.CompletableFuture;
56

67
/** Accessory with color temperature. */
@@ -22,6 +23,24 @@ public interface AccessoryWithColorTemperature {
2223
*/
2324
CompletableFuture<Void> setColorTemperature(Integer value) throws Exception;
2425

26+
/**
27+
* return the min value for color temperature. overwrite if you want to change the default value.
28+
*
29+
* @return min color temperature
30+
*/
31+
default int getMinColorTemperature() {
32+
return ColorTemperatureCharacteristic.DEFAULT_MIN_VALUE;
33+
}
34+
35+
/**
36+
* return the max value for color temperature. overwrite if you want to change the default value.
37+
*
38+
* @return max color temperature
39+
*/
40+
default int getMaxColorTemperature() {
41+
return ColorTemperatureCharacteristic.DEFAULT_MAX_VALUE;
42+
}
43+
2544
/**
2645
* Subscribes to changes in color temperature.
2746
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithDuration.java

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.valve.SetDurationCharacteristic;
45
import java.util.concurrent.CompletableFuture;
56

67
/** Accessory with duration characteristic. */
@@ -13,6 +14,24 @@ public interface AccessoryWithDuration {
1314
*/
1415
CompletableFuture<Integer> getSetDuration();
1516

17+
/**
18+
* return the min value for duration. overwrite if you want to change the default value.
19+
*
20+
* @return min remaining duration
21+
*/
22+
default int getMinDuration() {
23+
return SetDurationCharacteristic.DEFAULT_MIN_VALUE;
24+
}
25+
26+
/**
27+
* return the max value for duration. overwrite if you want to change the default value.
28+
*
29+
* @return max duration
30+
*/
31+
default int getMaxDuration() {
32+
return SetDurationCharacteristic.DEFAULT_MAX_VALUE;
33+
}
34+
1635
/**
1736
* Sets the duration for which the service should run.
1837
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithNitrogenDioxideDensity.java

+31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airquality.NitrogenDioxideDensityCharacteristic;
45
import java.util.concurrent.CompletableFuture;
56

67
/** Accessory with nitrogen dioxide density characteristic. */
@@ -13,6 +14,36 @@ public interface AccessoryWithNitrogenDioxideDensity {
1314
*/
1415
CompletableFuture<Double> getNitrogenDioxideDensity();
1516

17+
/**
18+
* return the min value for nitrogen dioxide density. overwrite if you want to change the default
19+
* value.
20+
*
21+
* @return min nitrogen dioxide density
22+
*/
23+
default double getMinNitrogenDioxideDensity() {
24+
return NitrogenDioxideDensityCharacteristic.DEFAULT_MIN_VALUE;
25+
}
26+
27+
/**
28+
* return the max value for nitrogen dioxide density. overwrite if you want to change the default
29+
* value.
30+
*
31+
* @return max nitrogen dioxide density
32+
*/
33+
default double getMaxNitrogenDioxideDensity() {
34+
return NitrogenDioxideDensityCharacteristic.DEFAULT_MAX_VALUE;
35+
}
36+
37+
/**
38+
* return the min step value for nitrogen dioxide density. overwrite if you want to change the
39+
* default value.
40+
*
41+
* @return min step nitrogen dioxide density
42+
*/
43+
default double getMinStepNitrogenDioxideDensity() {
44+
return NitrogenDioxideDensityCharacteristic.DEFAULT_STEP;
45+
}
46+
1647
/**
1748
* Subscribes to changes in nitrogen dioxide density.
1849
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithOzoneDensity.java

+28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airquality.OzoneDensityCharacteristic;
45
import java.util.concurrent.CompletableFuture;
56

67
/** Accessory with Ozone Density characteristic. */
@@ -13,6 +14,33 @@ public interface AccessoryWithOzoneDensity {
1314
*/
1415
CompletableFuture<Double> getOzoneDensity();
1516

17+
/**
18+
* return the min value for ozone density. overwrite if you want to change the default value.
19+
*
20+
* @return min ozone density
21+
*/
22+
default double getMinOzoneDensity() {
23+
return OzoneDensityCharacteristic.DEFAULT_MIN_VALUE;
24+
}
25+
26+
/**
27+
* return the max value for ozone density. overwrite if you want to change the default value.
28+
*
29+
* @return max ozone density
30+
*/
31+
default double getMaxOzoneDensity() {
32+
return OzoneDensityCharacteristic.DEFAULT_MAX_VALUE;
33+
}
34+
35+
/**
36+
* return the min step value for ozone density. overwrite if you want to change the default value.
37+
*
38+
* @return min step ozone density
39+
*/
40+
default double getMinStepOzoneDensity() {
41+
return OzoneDensityCharacteristic.DEFAULT_STEP;
42+
}
43+
1644
/**
1745
* Subscribes to changes in ozone density.
1846
*

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithPM10Density.java

+28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.hapjava.accessories.optionalcharacteristic;
22

33
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.airquality.PM10DensityCharacteristic;
45
import java.util.concurrent.CompletableFuture;
56

67
/** Accessory with PM10 Density characteristic. */
@@ -13,6 +14,33 @@ public interface AccessoryWithPM10Density {
1314
*/
1415
CompletableFuture<Double> getPM10Density();
1516

17+
/**
18+
* return the min value for PM10 density. overwrite if you want to change the default value.
19+
*
20+
* @return min PM10 density
21+
*/
22+
default double getMinPM10Density() {
23+
return PM10DensityCharacteristic.DEFAULT_MIN_VALUE;
24+
}
25+
26+
/**
27+
* return the max value for PM10 density. overwrite if you want to change the default value.
28+
*
29+
* @return max PM10 density
30+
*/
31+
default double getMaxPM10Density() {
32+
return PM10DensityCharacteristic.DEFAULT_MAX_VALUE;
33+
}
34+
35+
/**
36+
* return the min step value for PM10 density. overwrite if you want to change the default value.
37+
*
38+
* @return min step PM10 density
39+
*/
40+
default double getMinStepPM10Density() {
41+
return PM10DensityCharacteristic.DEFAULT_STEP;
42+
}
43+
1644
/**
1745
* Subscribes to changes in PM10 density.
1846
*

0 commit comments

Comments
 (0)