You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From what I understand, the FRITZ!DECT 500 Color LED lightbulb has two separately controllable parameters:
its brightness/color and
whether it is on or off.
Changing either is done using separate commands sent to the AHA HTTP interface.
As of version 3.2.0, the openhab-addons expose both as a single channel and, depending on which command is sent to the channel (on/off vs. a new brightness) either parameter is changed.
This does not mesh very well with the way OpenHAB seems to think (a light that is "off" has zero brightness; a light that has nonzero brightness is "on").
Expected Behavior
From my limited understanding, I can think of two ways to work around this:
expose both parameters (on/off and brightness) as separate channels
control both parameters via single channel, but make sure that OpenHAB assumptions hold:
If somebody switches the physical light "off", report zero brightness so that OpenHAB knows the light is off
If somebody turns up the brightness in OpenHAB, make sure the physical light is also turned "on"
Current Behavior
OpenHAB UIs show lights that have been switched "off" as "on" (because they still have nonzero brightness). Dimming a light to 0% in OpenHAB UIs does not switch the light "off" but only reduces its brightness to zero, confusing other apps controlling the same bulb.
Possible Solution
To illustrate the second option (single channel control of bulb), the following (crude) code seems to achieve this:
diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
index e9942d1224..f78af39cec 100644
--- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
+++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
@@ -157,7 +157,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (deviceModel.isHANFUNBlinds()) {
updateLevelControl(deviceModel.getLevelControlModel());
} else if (deviceModel.isColorLight()) {
- updateColorLight(deviceModel.getColorControlModel(), deviceModel.getLevelControlModel());
+ updateColorLight(deviceModel.getColorControlModel(), deviceModel.getLevelControlModel(),
+ deviceModel.getSimpleOnOffUnit());
} else if (deviceModel.isDimmableLight() && !deviceModel.isHANFUNBlinds()) {
updateDimmableLight(deviceModel.getLevelControlModel());
} else if (deviceModel.isHANFUNUnit() && deviceModel.isHANFUNOnOff()) {
@@ -203,11 +204,24 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
}
private void updateColorLight(@Nullable ColorControlModel colorControlModel,
- @Nullable LevelControlModel levelControlModel) {
+ @Nullable LevelControlModel levelControlModel, @Nullable SimpleOnOffModel simpleOnOffUnit) {
if (colorControlModel != null && levelControlModel != null) {
DecimalType hue = new DecimalType(colorControlModel.hue);
PercentType saturation = ColorControlModel.toPercent(colorControlModel.saturation);
PercentType brightness = new PercentType(levelControlModel.getLevelPercentage());
+
+ if (simpleOnOffUnit.state == false) {
+ if (brightness.toBigDecimal().compareTo(BigDecimal.ZERO) > 0) {
+ logger.debug("device is off, but brightness is nonzero - deliberately misreporting as zero");
+ brightness = new PercentType(0);
+ }
+ } else {
+ if (brightness.toBigDecimal().compareTo(BigDecimal.ZERO) <= 0) {
+ logger.debug("device is on, but brightness is zero - deliberately misreporting as nonzero");
+ brightness = new PercentType(1);
+ }
+ }
+
updateThingChannelState(CHANNEL_COLOR, new HSBType(hue, saturation, brightness));
}
}
@@ -420,6 +476,13 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
}
if (brightness != null) {
fritzBox.setLevelPercentage(ain, brightness);
+ if (brightness.compareTo(BigDecimal.ZERO) > 0) {
+ logger.debug("brightness is nonzero - also setting on");
+ fritzBox.setSwitch(ain, true);
+ } else {
+ logger.debug("brightness is zero - also setting off");
+ fritzBox.setSwitch(ain, false);
+ }
}
break;
case CHANNEL_SETTEMP:
Steps to Reproduce (for Bugs)
Add bulb as avmfritz:HAN_FUN_COLOR_BULB, make sure to use AIN that ends in -1 (the one without seems to be a dummy device, as also evidenced by its functionbitmask=1 (no functions outside of, well, being a HAN-FUN device)
Connect Switch and Dimmer items to its color channel
Switch bulb off. OpenHAB still shows light as "on"
Context
While all of this can be worked around with clever rules, I still think it makes sense to either address the behavior in code or in the documentation
Your Environment
Version used: OpenHAB 3.2.0
The text was updated successfully, but these errors were encountered:
sommer
added
the
bug
An unexpected problem or unintended behavior of an add-on
label
Mar 22, 2022
I did some fix of the on off behavior with this PR #14373. Since this change you can control the the brightness with a percentage value of 0 or via a switch. If the light blub is conctoled via fritz box gui or app its also showed in openhab in a way that it brightness is 0 when its off. I reccomend to cloase this bug.
From what I understand, the FRITZ!DECT 500 Color LED lightbulb has two separately controllable parameters:
Changing either is done using separate commands sent to the AHA HTTP interface.
As of version 3.2.0, the openhab-addons expose both as a single channel and, depending on which command is sent to the channel (on/off vs. a new brightness) either parameter is changed.
This does not mesh very well with the way OpenHAB seems to think (a light that is "off" has zero brightness; a light that has nonzero brightness is "on").
Expected Behavior
From my limited understanding, I can think of two ways to work around this:
Current Behavior
OpenHAB UIs show lights that have been switched "off" as "on" (because they still have nonzero brightness). Dimming a light to 0% in OpenHAB UIs does not switch the light "off" but only reduces its brightness to zero, confusing other apps controlling the same bulb.
Possible Solution
To illustrate the second option (single channel control of bulb), the following (crude) code seems to achieve this:
Steps to Reproduce (for Bugs)
avmfritz:HAN_FUN_COLOR_BULB
, make sure to use AIN that ends in-1
(the one without seems to be a dummy device, as also evidenced by itsfunctionbitmask=1
(no functions outside of, well, being a HAN-FUN device)Switch
andDimmer
items to itscolor
channelContext
Your Environment
The text was updated successfully, but these errors were encountered: