Skip to content

extend support for custom min/max/step to further characteristics #136

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 1 commit into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories;

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

/**
* return the min value for current ambient light level. overwrite if you want to change the
* default value.
*
* @return min current ambient light level
*/
default double getMinCurrentAmbientLightLevel() {
return CurrentAmbientLightLevelCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for current ambient light level. overwrite if you want to change the
* default value.
*
* @return max current ambient light level
*/
default double getMaxCurrentAmbientLightLevel() {
return CurrentAmbientLightLevelCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for current ambient light level. overwrite if you want to change the
* default value.
*
* @return min step current ambient light level
*/
default double getMinStepCurrentAmbientLightLevel() {
return CurrentAmbientLightLevelCharacteristic.DEFAULT_STEP;
}

@Override
default Collection<Service> getServices() {
return Collections.singleton(new LightSensorService(this));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.carbondioxidesensor.CarbonDioxideLevelCharacteristic;
import io.github.hapjava.characteristics.impl.carbondioxidesensor.CarbonDioxidePeakLevelCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for carbon dioxide level. overwrite if you want to change the default
* value.
*
* @return min carbon dioxide level
*/
default double getMinCarbonDioxideLevel() {
return CarbonDioxideLevelCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for carbon dioxide level. overwrite if you want to change the default
* value.
*
* @return max carbon dioxide level
*/
default double getMaxCarbonDioxideLevel() {
return CarbonDioxideLevelCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for carbon dioxide level. overwrite if you want to change the default
* value.
*
* @return min step carbon dioxide level
*/
default double getMinStepCarbonDioxideLevel() {
return CarbonDioxideLevelCharacteristic.DEFAULT_STEP;
}

/**
* return the min value for carbon dioxide peak level. overwrite if you want to change the default
* value.
*
* @return min carbon dioxide peak level
*/
default double getMinCarbonDioxidePeakLevel() {
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for carbon dioxide peak level. overwrite if you want to change the default
* value.
*
* @return max carbon dioxide peak level
*/
default double getMaxCarbonDioxidePeakLevel() {
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for carbon dioxide peak level. overwrite if you want to change the
* default value.
*
* @return min step carbon dioxide peak level
*/
default double getMinStepCarbonDioxidePeakLevel() {
return CarbonDioxidePeakLevelCharacteristic.DEFAULT_STEP;
}

/**
* Subscribes to changes in the carbon dioxide level.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.carbonmonoxidesensor.CarbonMonoxideLevelCharacteristic;
import io.github.hapjava.characteristics.impl.carbonmonoxidesensor.CarbonMonoxidePeakLevelCharacteristic;
import java.util.concurrent.CompletableFuture;

/** Accessory with carbon dioxide level and peak level characteristic. */
/** Accessory with carbon monoxide level and peak level characteristic. */
public interface AccessoryWithCarbonMonoxideLevel {

/**
Expand All @@ -20,6 +22,66 @@ public interface AccessoryWithCarbonMonoxideLevel {
*/
CompletableFuture<Double> getCarbonMonoxideLevel();

/**
* return the min value for carbon monoxide level. overwrite if you want to change the default
* value.
*
* @return min carbon monoxide level
*/
default double getMinCarbonMonoxideLevel() {
return CarbonMonoxideLevelCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for carbon monoxide level. overwrite if you want to change the default
* value.
*
* @return max carbon monoxide level
*/
default double getMaxCarbonMonoxideLevel() {
return CarbonMonoxideLevelCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for carbon monoxide level. overwrite if you want to change the
* default value.
*
* @return min step carbon monoxide level
*/
default double getMinStepCarbonMonoxideLevel() {
return CarbonMonoxideLevelCharacteristic.DEFAULT_STEP;
}

/**
* return the min value for carbon monoxide peak level. overwrite if you want to change the
* default value.
*
* @return min carbon monoxide peak level
*/
default double getMinCarbonMonoxidePeakLevel() {
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for carbon monoxide peak level. overwrite if you want to change the
* default value.
*
* @return max carbon monoxide peak level
*/
default double getMaxCarbonMonoxidePeakLevel() {
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for carbon monoxide peak level. overwrite if you want to change the
* default value.
*
* @return min step carbon monoxide peak level
*/
default double getMinStepCarbonMonoxidePeakLevel() {
return CarbonMonoxidePeakLevelCharacteristic.DEFAULT_STEP;
}

/**
* Subscribes to changes in the carbon monoxide level.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.lightbulb.ColorTemperatureCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for color temperature. overwrite if you want to change the default value.
*
* @return min color temperature
*/
default int getMinColorTemperature() {
return ColorTemperatureCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for color temperature. overwrite if you want to change the default value.
*
* @return max color temperature
*/
default int getMaxColorTemperature() {
return ColorTemperatureCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* Subscribes to changes in color temperature.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.valve.SetDurationCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for duration. overwrite if you want to change the default value.
*
* @return min remaining duration
*/
default int getMinDuration() {
return SetDurationCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for duration. overwrite if you want to change the default value.
*
* @return max duration
*/
default int getMaxDuration() {
return SetDurationCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* Sets the duration for which the service should run.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.airquality.NitrogenDioxideDensityCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for nitrogen dioxide density. overwrite if you want to change the default
* value.
*
* @return min nitrogen dioxide density
*/
default double getMinNitrogenDioxideDensity() {
return NitrogenDioxideDensityCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for nitrogen dioxide density. overwrite if you want to change the default
* value.
*
* @return max nitrogen dioxide density
*/
default double getMaxNitrogenDioxideDensity() {
return NitrogenDioxideDensityCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for nitrogen dioxide density. overwrite if you want to change the
* default value.
*
* @return min step nitrogen dioxide density
*/
default double getMinStepNitrogenDioxideDensity() {
return NitrogenDioxideDensityCharacteristic.DEFAULT_STEP;
}

/**
* Subscribes to changes in nitrogen dioxide density.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.airquality.OzoneDensityCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for ozone density. overwrite if you want to change the default value.
*
* @return min ozone density
*/
default double getMinOzoneDensity() {
return OzoneDensityCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for ozone density. overwrite if you want to change the default value.
*
* @return max ozone density
*/
default double getMaxOzoneDensity() {
return OzoneDensityCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for ozone density. overwrite if you want to change the default value.
*
* @return min step ozone density
*/
default double getMinStepOzoneDensity() {
return OzoneDensityCharacteristic.DEFAULT_STEP;
}

/**
* Subscribes to changes in ozone density.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.hapjava.accessories.optionalcharacteristic;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.airquality.PM10DensityCharacteristic;
import java.util.concurrent.CompletableFuture;

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

/**
* return the min value for PM10 density. overwrite if you want to change the default value.
*
* @return min PM10 density
*/
default double getMinPM10Density() {
return PM10DensityCharacteristic.DEFAULT_MIN_VALUE;
}

/**
* return the max value for PM10 density. overwrite if you want to change the default value.
*
* @return max PM10 density
*/
default double getMaxPM10Density() {
return PM10DensityCharacteristic.DEFAULT_MAX_VALUE;
}

/**
* return the min step value for PM10 density. overwrite if you want to change the default value.
*
* @return min step PM10 density
*/
default double getMinStepPM10Density() {
return PM10DensityCharacteristic.DEFAULT_STEP;
}

/**
* Subscribes to changes in PM10 density.
*
Expand Down
Loading