tonesto7 / homebridge-hubitat-tonesto7

Hubitat Homebridge Plugin
107 stars 34 forks source link

Adapative lighting - setcolor commands being sent to lights that are off. #126

Closed arlogilbert closed 2 years ago

arlogilbert commented 2 years ago

Verify the following before opening an trouble issue

Go over all the following points, and put an x in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!


About Your Setup

Expected Behavior

Adaptive lighting should not send any commands to a light if that light is off.

Current Behavior

Adaptive lighting sends setColorTemperature commands, even if the device is off. Causing the light to turn on.

Steps to Reproduce (for bugs)

  1. Install any brand of smart bulb
  2. Enable adaptive lighting for that bulb
  3. Turn off the bulb (in Homekit or Hubitat, it doesn't matter where)
  4. Wait a few minutes and your light will turn itself back on.

Please include a copy of any relevant log output to assist in tracking down the bug

[13/12/2021, 09:13:05] [Hubitat-v2] Sending Device Command: off | Name: (Office Lamp) | DeviceID: (79) | UsingCloud: (false)
[13/12/2021, 09:13:06] [Hubitat-v2] [Device Event]: (Office Lamp) [SWITCH] is off
[13/12/2021, 09:13:58] [Hubitat-v2] Sending Device Command: setColorTemperature | Value: {"value1":2747} | Name: (Office Lamp) | DeviceID: (79) | UsingCloud: (false)
[13/12/2021, 09:13:59] [Hubitat-v2] [Device Event]: (Office Lamp) [SWITCH] is on

This is identical to #101 which was closed for inactivity.

apwelsh commented 2 years ago

I could be wrong here, but aren't you supposed to be able to send color based events to lights without them turning on? On Hue and a lot of Hubitat devices, this is known as color staging. So is the ask here that each light that currently supports color staging no longer be able to support that feature, or that this tool remember the stages colors until a request to turn the device on is initiated, or the device sends a state change event that would undo the color staging cache?

arlogilbert commented 2 years ago

@apwelsh actually you are correct, if the hubitat user sets the bulb to allow color prestaging then the code behaves correctly. The problem is that the color prestaging setting is not turned on by default on smart bulbs. Perhaps the right approach is to check whether color prestaging is enabled for the bulb, if so then let the setColorTemperature command execute, otherwise check whether the switch is on to prevent the setColorTemperature from turning the light on.

tonesto7 commented 2 years ago

Is the pre staging status an attribute or state that can be queried?

arlogilbert commented 2 years ago

I'm using Sengled bulbs (no Hue's to test with) but I'm not seeing any capabilities I can evaluate yet. The Sengled driver stores it as a preference.

app:612021-12-13 11:03:05.798 am info Homebridge (v2.5.12) | Commands: [configure, off, on, refresh, setColor, setColorTemperature, setHue, setLevel, setSaturation, startLevelChange, stopLevelChange, updateFirmware]
app:612021-12-13 11:03:05.791 am info Homebridge (v2.5.12) | Capabilities: [Configuration, Actuator, ColorTemperature, ColorMode, ColorControl, ChangeLevel, SwitchLevel, Light, Switch]
app:612021-12-13 11:03:05.788 am info Homebridge (v2.5.12) | Attributes: [RGB, switch, colorName, colorName, colorTemperature, switch, colorMode, color, level, saturation, hue]
arlogilbert commented 2 years ago

Confirmed it is not available to the app, we can updateSetting but there is no method to retrieve preference settings (and no standardized naming for color pre-staging).

So i guess the question is whether it is better to ignore color staging entirely (as my pull request does) or whether we should just update the readme to include some "If your adaptive lights keep turning on by themselves then enable color prestaging"

I lean towards the former because I assume (perhaps incorrectly) that some RGBW bulbs do not in fact support prestaging which would mean that some consumers of this plugin would always be unable to use adaptive lighting.

Or option 3 (which I do not have the time to do a PR for) would be to make this a user configurable setting on the Hubitat plugin config page and then evaluate that setting when deciding whether to send color setColorTemperature commands to devices that are not on.

kfraleigh commented 2 years ago

I have been using the change arlogilbert submitted in his pull request because it made it possible to use the Advanced Zigbee RGBW drivers which don’t support color prestaging. The reason for the driver change was that the lights’ responsiveness is more reliable (for me at least) when multiple commands are being sent back to back like when following another dimmers level. I believe Mike Maxwell said that the Advanced drivers have the lowest overhead of the Zigbee drivers, which may be the reason they handle this better. This also seems to be what the Hue bridge is doing. Color prestaging doesn’t make sense with adaptive lighting because the CT is dependent on the dimmer level and time of day, so it’s going to change after turning the light back on anyway, unless the dimmer level is never changed. I am not seeing any negative consequences in the behavior of adaptive lighting after implementing this change.

tonesto7 commented 2 years ago

@kfraleigh Thanks for the update... I will review this and get it merged in the next few days (work and family is killing me lately)

tonesto7 commented 2 years ago

I've merged these changes into the public code