[homekit] allow configuring min/max light level (#14034)
since the default is weirdly 0.0001, yet my sensors can report a straight 0. Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
462dca8040
commit
a079603aab
|
@ -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 |
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue