]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homekit] allow configuring min/max light level (#14034)
authorCody Cutrer <cody@cutrer.us>
Wed, 21 Dec 2022 23:37:26 +0000 (16:37 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Dec 2022 23:37:26 +0000 (00:37 +0100)
since the default is weirdly 0.0001, yet my sensors can report a
straight 0.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
bundles/org.openhab.io.homekit/README.md
bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/accessories/HomekitLightSensorImpl.java

index abcd298d4f137faeea9b0a3ee2d2c7aeb679b6f0..04225645410e57c6e5283a758b84f663210fc4ca 100644 (file)
@@ -655,7 +655,7 @@ Support for this is planned for the future release of openHAB HomeKit binding.
 |                      |                             | TamperedStatus               | Switch, Contact               | Tampered status                                                                                                                                                                                                                                                                                                                                     |
 |                      |                             | BatteryLowStatus             | Switch, Contact, Number       | Battery status                                                                                                                                                                                                                                                                                                                                      |
 | LightSensor          |                             |                              |                               | Light sensor                                                                                                                                                                                                                                                                                                                                        |
-|                      | LightLevel                  |                              | Number                        | Light level in lux                                                                                                                                                                                                                                                                                                                                  |
+|                      | LightLevel                  |                              | Number                        | Light level in lux. supported configuration: minValue, maxValue.                                                                                                                                                                                                                                                                                    |
 |                      |                             | Name                         | String                        | Name of the sensor                                                                                                                                                                                                                                                                                                                                  |
 |                      |                             | ActiveStatus                 | Switch, Contact               | Working status                                                                                                                                                                                                                                                                                                                                      |
 |                      |                             | FaultStatus                  | Switch, Contact               | Fault status                                                                                                                                                                                                                                                                                                                                        |
index f27538aa49ebdd2d5cac548c5a4ceddd45285330..69e171000c072b74948720d05a88679dae7f5c0a 100644 (file)
@@ -47,10 +47,19 @@ public class HomekitLightSensorImpl extends AbstractHomekitAccessoryImpl impleme
     public CompletableFuture<Double> getCurrentAmbientLightLevel() {
         final @Nullable DecimalType state = getStateAs(LIGHT_LEVEL, DecimalType.class);
         return CompletableFuture
-                .completedFuture(state != null ? state.doubleValue()
-                        : getAccessoryConfiguration(HomekitCharacteristicType.LIGHT_LEVEL, HomekitTaggedItem.MIN_VALUE,
-                                BigDecimal.valueOf(CurrentAmbientLightLevelCharacteristic.DEFAULT_MIN_VALUE))
-                                        .doubleValue());
+                .completedFuture(state != null ? state.doubleValue() : getMinCurrentAmbientLightLevel());
+    }
+
+    @Override
+    public double getMinCurrentAmbientLightLevel() {
+        return getAccessoryConfiguration(HomekitCharacteristicType.LIGHT_LEVEL, HomekitTaggedItem.MIN_VALUE,
+                BigDecimal.valueOf(CurrentAmbientLightLevelCharacteristic.DEFAULT_MIN_VALUE)).doubleValue();
+    }
+
+    @Override
+    public double getMaxCurrentAmbientLightLevel() {
+        return getAccessoryConfiguration(HomekitCharacteristicType.LIGHT_LEVEL, HomekitTaggedItem.MAX_VALUE,
+                BigDecimal.valueOf(CurrentAmbientLightLevelCharacteristic.DEFAULT_MAX_VALUE)).doubleValue();
     }
 
     @Override