-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[deconz] Adjust color-temperature handling, Extend bulb support #7900
Conversation
Travis tests were successfulHey @HahnBenjamin, |
1 similar comment
Travis tests were successfulHey @HahnBenjamin, |
private final int CT_MAX; | ||
private final int CT_MIN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make these variable names camelcase.
properties.put(Thing.PROPERTY_VENDOR, light.manufacturername); | ||
properties.put(Thing.PROPERTY_MODEL_ID, light.modelid); | ||
|
||
if (light.ctmax != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard openhab coding format requires that all if statements should have brackets.
.withProperty("id", lightID) | ||
.withProperty(UNIQUE_ID, light.uniqueid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put these in the properties map to begin with? It would make things consistent.
@@ -129,6 +138,9 @@ private void addLight(String lightID, LightMessage light) { | |||
case COLOR_DIMMABLE_LIGHT: | |||
thingTypeUID = THING_TYPE_COLOR_LIGHT; | |||
break; | |||
case COLOR_LIGHT: | |||
thingTypeUID = (light.ctmin != null) ?THING_TYPE_EXTENDED_COLOR_LIGHT :THING_TYPE_COLOR_LIGHT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please apply formatting here
Please do not merge this one. I have no time this morning but this will break functionality for some users. I‘ll comment later today. |
I assume I must make the new properties known to the existing things. Any pointer or reference on how to do this correcly would be much appreciated |
That would be easy. You can check in Unfortunately the situation is more complex. Your implementations is similar to what I originally implemented. I later deleted that code and set fixed limits for the color temperature. But there is either a bug in the deconz software or in some Ikea bulbs, where So you would have to at least check if the reported values for I do not understand the change for the extended color light. It should work withput that. Can you show what is reported by the light (response of REST API call for all lights, you can delete all information that does not belong to the light). |
Travis tests were successfulHey @HahnBenjamin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see my comment regarding the wrong reporting of ctmax
and ctmin
? This needs to be taken care of. My suggestion would be: if the reported values are outside of 153-500, set them to 153 or 500 respectively. This should always be ok, since deconz does not accept values outside of that range.
Another idea: If we scale it properly, we could report the color temperature value in K. The conversion can be found here: https://en.wikipedia.org/wiki/Mired
@J-N-K I was actually looking more deeply into the Ikea CWS light issue and figured out that it actually does not support setting ct value. The ct value is converted into xy-values in deconz as a workaround. I will try to adjust the add-on code accordingly. I will further need to dig a bit deeper into the openhab architecture to find out the internals. I had tested the mired conversion already locally but did not know how to incorporate this. The "custom state description provider" is something i will look for. For my setup there are only correct ct ranges reported, but incorrect reporting should be considered. The adjustments in the extended color light are taking into account the colormode the bulb is currently operating in. During the update the color channel was changing to a value different to what was set. i assume only the state variables of the current colormode are valid for certain bulbs. |
properties.put(Thing.PROPERTY_MODEL_ID, light.modelid); | ||
|
||
if (light.ctmax != null && light.ctmin != null) { | ||
properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define private static final int CT_MAX = 500;
in this class
properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); | |
int ctmax = light.ctmax > 500 ? 500 : light.ctmax; | |
properties.put(PROPERTY_CT_MAX, Integer.toString(ctmax)); |
and the same for min
private int unscaleColorTemperature(double ct) { | ||
return (int) (ct / 100.0 * (500 - 153) + 153); | ||
private int unscaleColorTemperature(final double ct) { | ||
return (int) (ct / 100.0 * (ct_max - ct_min) + ct_min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (int) (ct / 100.0 * (ct_max - ct_min) + ct_min); | |
int ctMired =(int) (100000.0 / ct); | |
if (ctMired > ctmax) { | |
return ctmax; | |
} else if (ctMired < ctmin) { | |
return ctmin; | |
} else { | |
return ctMired; | |
} |
and the conversion in the other direction below. We can add teh dynamic state description later. You haver to adjust the documentation accordingly (color temperature is not 0->100 but xxx K -> xxx K. If you change that today, we can merge it before the 2.5.6 release and it is not a breaking change since 2.5.5 did not contain light support for deconz.
Travis tests were successfulHey @HahnBenjamin, |
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
See ZigBee Cluster Library Specification Page 5-5 - 327 Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Travis tests were successfulHey @HahnBenjamin, |
@J-N-K i tested this version with my local setup and it worked well for various bulbs of different vendors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM. Many thanks for your fast Action.
...enhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java
Show resolved
Hide resolved
...ding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/light-thing-types.xml
Show resolved
Hide resolved
@cpmeister Are your concerns already adressed by the last changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from @J-N-K requested changes, LGTM
Signed-off-by: Benajmin Hahn <[email protected]>
Signed-off-by: Benajmin Hahn <[email protected]>
Many thanks. Do you want to investigate the state description provider or should I do that? |
Can I find information about it in openHAB Developer Guide? |
Basically you need to implement a DynamicStateDescriptionProvider (like https://github.com/openhab/openhab-addons/blob/2.5.x/bundles/org.openhab.binding.onewire/src/main/java/org/openhab/binding/onewire/internal/OwDynamicStateDescriptionProvider.java), add that as reference to the handler factory, pass it to the thing handler and create a Lines 82 to 87 in 020da77
|
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]> Signed-off-by: CSchlipp <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
…hab#7900) * Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn <[email protected]>
Add scaling of upper\lower level for ct values
Add IKEA CWS bulb support
Signed-off-by: Benjamin Hahn [email protected]