InovelliUSA / Hubitat

Location for Inovelli Hubitat Drivers and Apps
Apache License 2.0
104 stars 50 forks source link

Improve color and level changing, and misc improvements. #54

Closed Zarklord closed 2 months ago

Zarklord commented 2 years ago

added level pre-staging option (default off)

works the same as color staging, except for level

added option for instant change for colors when the device is off (default on)

this means that if your lightbulb was previously green, and your sent a command to turn it blue, previously the lightbulb would turn on as green and transition to blue, with this change, the light would now fade in to blue, and wouldn't flicker from the old color.

added option to allow level to persist across mode changes or go back to max level (default off)

the changes I made allows level to properly persist between color mode changes, this setting by default makes level reset to 100 every time colorMode changes

added option for confirming light state, default off, this significantly reduces zwave usage, at the potential of being innaccurate.

This just assumes that the lightbulb will return an exact 1:1 that we put in, in my tests, it results in significantly more responsive lights, especially when rapidly changing colors, and I never saw it going out of sync (a test of the state of the lightbulb can still be triggered via refresh).

setLevel now properly updates the level of the hsl color when in RGB color mode

previously setLevel was kinda useless in rgb mode, instead of updating the color's level, it would instead be a modifier to it, so if the color's level was 40 and setLevel was 100 color's level would be 40, but if setLevel was 10 color's level would be 4, this now makes setLevel update color's level instead of its own(and the setLevel level is locked at 100 in RGB mode)

improved gamma correction

this is using a much more normal algorithm, and from my own eyes the color's seem significantly more accurate.

color pre staging is properly respected when the level is adjusted at the same time as the color

previously, if you sent a level argument with setColorTemperature, color pre-staging was effectively ignored, now it properly doesn't turn on

fixed a bug causing color states to update 5 times every time the color changed changed.

state.colorReceived wasn't ever getting cleared out, causing every new color that got received to get recalculated(and send events), causing 5x the events to get sent out than needed.

function ordering changed to be more logical

I just grouped boilerplate functions at the bottom and moved like functions (zwaveEvent) to one place that way it is easier to read the file

only get color updates for the color channels that actually changed

previously regardless of which color mode was just updated, the driver would request all 5 colors (red, green, blue, warm white, cold white), it would still only do processing on the relevant 2/3 colors though, now it only requests rgb when in RGB mode or warm white and cold white when in CT mode

Zarklord commented 2 years ago

I just found an optimization to reduce the amount of data by 60% when changing color temp, and 40% when changing rgb color, so now changing colors/temps should cause the lightbulb to send significantly less data.