HSBType Equality for Phillips Hue

Sort of the same thing as this topic: HSBType comparison

I find that the HSB values of my Hue lights sometimes seem to change to something other than what I set - for example, I’m setting a light to (31, 67, 51), I see it change to that value in the OpenHAB logs, then a few seconds later spontaneously change to (30, 67, 51) (i.e. 1 less on the hue attribute).

I guess it’s some sort of optimisation that the Hue hub is doing for me - does anyone have any insight into why that is? Are there values that it doesn’t like? If I chose (30, 67, 51) as my value, would that always stay the same? Interestingly when I use a Hue switch to set that value, it stays but not when I set it from OpenHAB.

Alternatively, I’m looking for a sensible way to do a comparison that allows a little fuzziness (I guess one point each way in any of the three attributes), without it just being a huge ugly if statement that I copy everywhere. Is there a recommended approach for that sort of thing? Should it be a script?

I guess it depends on what you mean by “copy everywhere.” A lambda might be appropriate. Design Pattern: Separation of Behaviors might be appropriate. Maybe refactoring your Rules so the comparison only occurs in one place.

I am seeing the same thing. When I send a command to change HSB values to a Hue bulb the correct command seems to be sent but the bulb usually backs off a step or two from the hue or saturation value. For example, if I change from “bright” to “nightlight” the value sent is 27,100,1 but it ends up at 26,99,1. However if I change it from the Hue app on my phone the correct value as recorded in events.log is set and holds. Is this a known issue?

### send "nightlight" command from console
openhab> smarthome:send Hue_Office_Candle "27,100,1"
Command has been sent successfully.

### from events.log
2020-06-16 10:12:34.081 [ome.event.ItemCommandEvent] - Item 'Hue_Office_Candle' received command 27,100,1
2020-06-16 10:12:34.091 [nt.ItemStatePredictedEvent] - Hue_Office_Candle predicted to become 27,100,1
2020-06-16 10:12:34.099 [vent.ItemStateChangedEvent] - Hue_Office_Candle changed from 29,63,100 to 27,100,1
2020-06-16 10:12:42.797 [vent.ItemStateChangedEvent] - Hue_Office_Candle changed from 27,100,1 to 26,99,1

### send "bright" command from console
openhab> smarthome:send Hue_Office_Candle "30,64,100"
Command has been sent successfully.

### from events.log
2020-06-16 10:13:22.281 [ome.event.ItemCommandEvent] - Item 'Hue_Office_Candle' received command 30,64,100
2020-06-16 10:13:22.315 [nt.ItemStatePredictedEvent] - Hue_Office_Candle predicted to become 30,64,100
2020-06-16 10:13:22.333 [vent.ItemStateChangedEvent] - Hue_Office_Candle changed from 26,99,1 to 30,64,100
2020-06-16 10:13:23.003 [vent.ItemStateChangedEvent] - Hue_Office_Candle changed from 30,64,100 to 29,63,100

### HSB value set correctly after manually changing to "bright" from Hue app
2020-06-16 10:53:45.637 [vent.ItemStateChangedEvent] - Hue_Office_Candle changed from 29,63,100 to 30,64,100

What version of OH are you using? There have been a lot of changes in the last 1.3 years, and I’m pretty sure there was a PR or two to fix this.

2.5.5 on openHABian. Please let me know if I can provide any other relevant information.