Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
86e9bf5
tweak default minimum dimming level
andrewfg Jun 26, 2026
5d6fbc6
fix for signe lamps
andrewfg Jun 26, 2026
d4aebc0
tweak precision
andrewfg Jun 26, 2026
698dc1a
add min dim level config param
andrewfg Jun 26, 2026
2daf740
self documenting minimum value
andrewfg Jun 26, 2026
7947690
add support for manual mirek schema
andrewfg Jun 26, 2026
9e39ca8
refine manual mirek stuff
andrewfg Jun 26, 2026
2664a45
shorten variable names
andrewfg Jun 26, 2026
660c091
fix log level
andrewfg Jun 26, 2026
b9a115e
oops
andrewfg Jun 26, 2026
a8a88d9
doc
andrewfg Jun 26, 2026
f0c24af
various
andrewfg Jun 28, 2026
ba8a444
fix build
andrewfg Jun 28, 2026
f7fbce4
refine 'setters' helpers
andrewfg Jun 29, 2026
9b4b7d2
various
andrewfg Jun 30, 2026
da15d4a
bug fixes
andrewfg Jun 30, 2026
3169984
tweaks
andrewfg Jun 30, 2026
634e0bc
various
andrewfg Jul 1, 2026
962d2b7
cosmetic
andrewfg Jul 1, 2026
1e208e7
various
andrewfg Jul 1, 2026
2987514
refactor
andrewfg Jul 2, 2026
86c02de
reduce deltas
andrewfg Jul 3, 2026
5a8723b
adopt some copilot suggestions
andrewfg Jul 3, 2026
12c81e2
extend lk wiser fix to tradfri bulbs too
andrewfg Jul 4, 2026
f2f1be5
javadoc fixes
andrewfg Jul 5, 2026
2a71439
various
andrewfg Jul 5, 2026
f230521
apply work around to bridge home
andrewfg Jul 5, 2026
556623c
Merge remote-tracking branch 'upstream/main' into hue-min-dim-level
andrewfg Jul 5, 2026
b968318
spotless on pom
andrewfg Jul 5, 2026
c208472
unfix pom
andrewfg Jul 5, 2026
583cf13
tweak java doc and variable name
andrewfg Jul 5, 2026
586232b
work-around check children recursively
andrewfg Jul 6, 2026
060efbf
javadoc
andrewfg Jul 6, 2026
0029adf
remove duplicate code
andrewfg Jul 6, 2026
58c0580
adopt copilot suggestions
andrewfg Jul 6, 2026
d31aebe
revert mess caused by copilot wrong suggestion
andrewfg Jul 6, 2026
ec566b1
Merge branch 'openhab:main' into hue-min-dim-level
andrewfg Jul 6, 2026
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
Expand Up @@ -18,6 +18,7 @@
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.hue.internal.api.dto.clip2.enums.ResourceType;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.type.ChannelTypeUID;

Expand Down Expand Up @@ -223,4 +224,6 @@ public class HueBindingConstants {

public static final String CHANNEL_GROUP_AUTOMATION = "automation";
public static final ChannelTypeUID CHANNEL_TYPE_AUTOMATION = new ChannelTypeUID(BINDING_ID, "automation-enable");

public static final Set<ResourceType> LIGHT_TYPES = Set.of(ResourceType.LIGHT, ResourceType.GROUPED_LIGHT);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.exceptions.DTOPresentButEmptyException;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.Units;

Expand All @@ -36,14 +35,13 @@ public class ColorTemperature {
* Get the color temperature as a QuantityType value.
*
* @return a QuantityType value
* @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
*/
public @Nullable QuantityType<?> getAbsolute() throws DTOPresentButEmptyException {
public @Nullable QuantityType<?> getAbsolute() {
Long mirek = this.mirek;
if (Objects.nonNull(mirek)) {
return QuantityType.valueOf(mirek, Units.MIRED).toInvertibleUnit(Units.KELVIN);
}
throw new DTOPresentButEmptyException("'color_temperature' DTO is present but empty");
return null;
}

public @Nullable Long getMirek() {
Expand All @@ -54,28 +52,8 @@ public class ColorTemperature {
return mirekSchema;
}

/**
* Get the color temperature as a percentage based on the MirekSchema. Note: this method is only to be used on
* cached state DTOs which already have a defined mirek schema.
*
* @return the percentage of the mirekSchema range.
* @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
*/
public @Nullable Double getPercent() throws DTOPresentButEmptyException {
Long mirek = this.mirek;
if (Objects.nonNull(mirek)) {
MirekSchema mirekSchema = this.mirekSchema;
mirekSchema = Objects.nonNull(mirekSchema) ? mirekSchema : MirekSchema.DEFAULT_SCHEMA;
double min = mirekSchema.getMirekMinimum();
double max = mirekSchema.getMirekMaximum();
double percent = 100f * (mirek.doubleValue() - min) / (max - min);
return Math.max(0, Math.min(100, percent));
}
throw new DTOPresentButEmptyException("'mirek_schema' DTO is present but empty");
}

public ColorTemperature setMirek(double mirek) {
this.mirek = Math.round(mirek);
public ColorTemperature setMirek(@Nullable Long mirek) {
this.mirek = mirek;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2010-2026 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.hue.internal.api.dto.clip2;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.api.dto.clip2.enums.ActionDeltaType;
import org.openhab.core.library.types.IncreaseDecreaseType;

import com.google.gson.annotations.SerializedName;

/**
* DTO for color temperature delta of a light.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public class ColorTemperatureDelta {
private @Nullable String action;
private @SerializedName("mirek_delta") int mirekDelta;

public @Nullable String getAction() {
return action;
}

public int getMirekDelta() {
return mirekDelta;
}

public ColorTemperatureDelta setAction(IncreaseDecreaseType action) {
this.action = ActionDeltaType.of(action).name().toLowerCase();
return this;
}

public ColorTemperatureDelta setDelta(int mirekDelta) {
this.mirekDelta = mirekDelta;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.exceptions.DTOPresentButEmptyException;
import org.openhab.core.util.ColorUtil.Gamut;

/**
Expand All @@ -38,15 +37,8 @@ public class ColorXy {
return this.gamut;
}

/**
* @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
*/
public double[] getXY() throws DTOPresentButEmptyException {
PairXy pairXy = this.xy;
if (Objects.nonNull(pairXy)) {
return pairXy.getXY();
}
throw new DTOPresentButEmptyException("'color' DTO is present but empty");
public @Nullable PairXy getXY() {
return xy;
}

public ColorXy setGamut(@Nullable Gamut gamut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.exceptions.DTOPresentButEmptyException;

import com.google.gson.annotations.SerializedName;

Expand All @@ -30,17 +29,10 @@ public class Dimming {
private @Nullable Double brightness;
private @Nullable @SerializedName("min_dim_level") Double minimumDimmingLevel;

public static final double DEFAULT_MINIMUM_DIMMIMG_LEVEL = 0.5f;
public static final double DEFAULT_MINIMUM_DIMMING_LEVEL = 100.0 / 255.0;

/**
* @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
*/
public double getBrightness() throws DTOPresentButEmptyException {
Double brightness = this.brightness;
if (Objects.nonNull(brightness)) {
return brightness;
}
throw new DTOPresentButEmptyException("'dimming' DTO is present but empty");
public @Nullable Double getBrightness() {
return brightness;
}

public @Nullable Double getMinimumDimmingLevel() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2010-2026 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.hue.internal.api.dto.clip2;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.api.dto.clip2.enums.ActionDeltaType;
import org.openhab.core.library.types.IncreaseDecreaseType;

import com.google.gson.annotations.SerializedName;

/**
* DTO for dimming delta of a light.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public class DimmingDelta {
private @Nullable String action;
private @Nullable @SerializedName("brightness_delta") Double brightnessDelta;

public @Nullable String getAction() {
return action;
}

public @Nullable Double getBrightnessDelta() {
return brightnessDelta;
}

public DimmingDelta setAction(IncreaseDecreaseType action) {
this.action = ActionDeltaType.of(action).name().toLowerCase();
return this;
}

public DimmingDelta setDelta(Double delta) {
this.brightnessDelta = delta;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
*/
@NonNullByDefault
public class MirekSchema {
private static final int MIN = 153;
private static final int MAX = 500;
private static final int MIN = 153; // ~6500K
private static final int MAX = 500; // ~2000K

private static final int MIN_ALLOWED = 140; // ~7000K
private static final int MAX_ALLOWED = 555; // ~1800K

public static final MirekSchema DEFAULT_SCHEMA = new MirekSchema();

Expand All @@ -49,6 +52,16 @@ private String toKelvin(int mirek) {
}

public String toPropertyValue() {
return String.format("%s .. %s", toKelvin(mirekMinimum), toKelvin(mirekMaximum));
return invalid() //
? "%dMk .. %dMk (INVALID)".formatted(mirekMinimum, mirekMaximum)
: "%s .. %s".formatted(toKelvin(mirekMinimum), toKelvin(mirekMaximum));
}

public static int toMirek(double kelvinValue) {
return (int) Math.round(1000000.0 / kelvinValue);
}

public boolean invalid() {
return mirekMinimum < MIN_ALLOWED || mirekMaximum > MAX_ALLOWED || mirekMinimum >= mirekMaximum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
*/
package org.openhab.binding.hue.internal.api.dto.clip2;

import java.util.Objects;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.exceptions.DTOPresentButEmptyException;

/**
* DTO for 'on' state of a light.
Expand All @@ -27,15 +24,8 @@
public class OnState {
private @Nullable Boolean on;

/**
* @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
*/
public boolean isOn() throws DTOPresentButEmptyException {
Boolean on = this.on;
if (Objects.nonNull(on)) {
return on;
}
throw new DTOPresentButEmptyException("'on' DTO is present but empty");
public @Nullable Boolean getOn() {
return on;
}

public OnState setOn(boolean on) {
Expand Down
Loading
Loading