mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Fix NullPointerException (#16356)
Resolves #16180 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
ad34e64437
commit
3ca7777422
@ -26,6 +26,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.hue.internal.api.dto.clip1.Capabilities;
|
import org.openhab.binding.hue.internal.api.dto.clip1.Capabilities;
|
||||||
import org.openhab.binding.hue.internal.api.dto.clip1.ColorTemperature;
|
import org.openhab.binding.hue.internal.api.dto.clip1.ColorTemperature;
|
||||||
|
import org.openhab.binding.hue.internal.api.dto.clip1.Control;
|
||||||
import org.openhab.binding.hue.internal.api.dto.clip1.FullLight;
|
import org.openhab.binding.hue.internal.api.dto.clip1.FullLight;
|
||||||
import org.openhab.binding.hue.internal.api.dto.clip1.State;
|
import org.openhab.binding.hue.internal.api.dto.clip1.State;
|
||||||
import org.openhab.binding.hue.internal.api.dto.clip1.StateUpdate;
|
import org.openhab.binding.hue.internal.api.dto.clip1.StateUpdate;
|
||||||
@ -191,26 +192,34 @@ public class HueLightHandler extends BaseThingHandler implements HueLightActions
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeCapabilities(@Nullable FullLight fullLight) {
|
private void initializeCapabilities(@Nullable FullLight fullLight) {
|
||||||
if (!capabilitiesInitializedSuccessfully && fullLight != null) {
|
if (capabilitiesInitializedSuccessfully || fullLight == null) {
|
||||||
Capabilities capabilities = fullLight.capabilities;
|
return;
|
||||||
if (capabilities != null) {
|
|
||||||
ColorTemperature ct = capabilities.control.ct;
|
|
||||||
if (ct != null) {
|
|
||||||
colorTemperatureCapabilties = ct;
|
|
||||||
|
|
||||||
// minimum and maximum are inverted due to mired/Kelvin conversion!
|
|
||||||
StateDescriptionFragment stateDescriptionFragment = StateDescriptionFragmentBuilder.create()
|
|
||||||
.withMinimum(new BigDecimal(LightStateConverter.miredToKelvin(ct.max))) //
|
|
||||||
.withMaximum(new BigDecimal(LightStateConverter.miredToKelvin(ct.min))) //
|
|
||||||
.withStep(new BigDecimal(100)) //
|
|
||||||
.withPattern("%.0f K") //
|
|
||||||
.build();
|
|
||||||
stateDescriptionProvider.setStateDescriptionFragment(
|
|
||||||
new ChannelUID(thing.getUID(), CHANNEL_COLORTEMPERATURE_ABS), stateDescriptionFragment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
capabilitiesInitializedSuccessfully = true;
|
|
||||||
}
|
}
|
||||||
|
Capabilities capabilities = fullLight.capabilities;
|
||||||
|
if (capabilities == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Control control = capabilities.control;
|
||||||
|
if (control == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ColorTemperature ct = control.ct;
|
||||||
|
if (ct == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
colorTemperatureCapabilties = ct;
|
||||||
|
|
||||||
|
// minimum and maximum are inverted due to mired/Kelvin conversion!
|
||||||
|
StateDescriptionFragment stateDescriptionFragment = StateDescriptionFragmentBuilder.create()
|
||||||
|
.withMinimum(new BigDecimal(LightStateConverter.miredToKelvin(ct.max))) //
|
||||||
|
.withMaximum(new BigDecimal(LightStateConverter.miredToKelvin(ct.min))) //
|
||||||
|
.withStep(new BigDecimal(100)) //
|
||||||
|
.withPattern("%.0f K") //
|
||||||
|
.build();
|
||||||
|
stateDescriptionProvider.setStateDescriptionFragment(
|
||||||
|
new ChannelUID(thing.getUID(), CHANNEL_COLORTEMPERATURE_ABS), stateDescriptionFragment);
|
||||||
|
|
||||||
|
capabilitiesInitializedSuccessfully = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user