[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:
Cody Cutrer 2022-12-21 16:37:26 -07:00 committed by GitHub
parent 462dca8040
commit a079603aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View 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 |

View 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