@GTunney I have a potential idea here—and the gist of it is that nonsmooth fades are generally caused by the fader script having to take too large of a jump between its brightness, levels. For instance, if the fader were to have to apply brightness levels of 1%, 20%, 40%, 80%, and then 100%, that would almost definitely not be terribly smooth.
I’ll get to the specifics of the idea in just a moment, but before I do, I’ll briefly go over the two main things that can cause fades to have large brightness jumps in their sequence:
-
Any given light takes a certain amount of time to process each set-brightness command. For instance, if a given light were to hypothetically take 500 ms to process a given light command, and if the fade were to be requested for 5 seconds, then that would only allow for about 10 set-brightness commands between the start of the fade (0 seconds) and the finish (5 seconds).
- So if it might turn out that your light isn’t be able to process set-brightness commands very quickly, then that may be one factor.
-
A related factor is that even if a given light might be able to process set-brightness commands rather quickly, you still can’t exceed what the math might allow.
- So for example, let’s suppose that a given lamp might be able to process set-brightness commands super quickly—perhaps it might be able to process 10 per second (which would work out to 100 ms per set-brightness command). In that scenario, if supposing that you were to try to fade that light from 0% to 100% over a span of 1 second, that probably wouldn’t work go very smoothly since you could only fit in about 10 set-brightness commands within that 1 second.
Of those two factors, the first one—the inherent delay within the lamp—is outside of your control. While the second one—the fade’s duration or the fade’s brightness span—is something that you might have some control over.
Anyhow, so there are two ways that you can potentially lessen the second factor, depending on how exacting you might want to be:
The quicker version:
Since large brightness jumps within a fade are typically caused by large brightness jumps over short periods of time, you can oftentimes make a fade feel smoother by either reducing the fade’s overall brightness span or by increasing the fade’s overall duration. And as that goes, you had mentioned that you’re having some trouble getting the fade to look smooth over 3 to 4 seconds.
-
First—as a baseline—you might see whether you can get that same fade to look smooth if you were to set its duration to, say, 25 seconds.
-
Then from there, you might try checking whether that same fade looks smooth over, say, 20 seconds. And if it does, you might try 15 seconds, and then try 10 seconds, and so on.
-
And eventually you’ll get to a point where the fade no longer looks smooth. And then if you go back to the previous fade duration in your testing sequence, that’ll represent approximately the minimum duration that that particular lamp can fade over that brightness span while still fading smoothly.
The more exacting version:
This approach follows the same idea as the previous one, but it may offer more precision:
-
First, if you haven’t yet installed the Home Assistant Log Viewer add-on, install that. (This should add a “Log Viewer” item to your sidebar within Home Assistant.)
-
Then open the Log Viewer in one of your browser tabs. And then in a second browser tab, open the automation where you have that 4-to-5-second fade.
-
Then within the automation with the 4-to-5-second fade, enable Debug Mode within the options for Ashley’s Light Fader.
-
From there, run that 4-to-5-second fade as is—without any modifications yet—and while the fade is running, switch over to the browser tab where you’ve got the Log Viewer open.
-
You should see some debugger output within the Log Viewer that looks something like this:
(I’ve sliiightly reformatted the below log bits just for clarity.)
2024-04-30 15:02:25.660 WARNING (MainThread) [homeassistant.components.system_log.external]
easeInOutSine easing type with 686 ms delay. remainingTimeInMilliseconds = 44923, and absoluteBrightnessSpan = 50
2024-04-30 15:02:25.661 WARNING (MainThread) [homeassistant.components.system_log.external]
startBrightness = 25, endBrightness = 75, and processingDelayInMilliseconds = 62
2024-04-30 15:02:28.548 WARNING (MainThread) [homeassistant.components.system_log.external]
Set Living Room Lamps to 26 brightness. (Linear brightness would have been 28.)
Delay is 686 ms. Elapsed time is 2.97 seconds. (endBrightness is 75.)
2024-04-30 15:02:30.750 WARNING (MainThread) [homeassistant.components.system_log.external]
Set Living Room Lamps to 27 brightness. (Linear brightness would have been 31.)
Delay is 686 ms. Elapsed time is 5.17 seconds. (endBrightness is 75.)
2024-04-30 15:02:32.237 WARNING (MainThread) [homeassistant.components.system_log.external]
Set Living Room Lamps to 28 brightness. (Linear brightness would have been 32.)
Delay is 686 ms. Elapsed time is 6.66 seconds. (endBrightness is 75.)
- At this point, you’ll probably notice within your logs that there are some pretty big jumps in the brightness level between each step.
-
In an ideal world, you might want there to be only a brightness jump of 1 between each step.
-
Buuuut the good news is that the human eye usually isn’t that precise so as to require a brightness jump of only 1 between each step. So if you can get that brightness jump down to maybe 2 or 3 per step—or maybe even as much as 5 per step—that may be enough to get the fade to look smooth to the human eye.
-
So from here—as a baseline—you might see whether you can get that same fade to look smooth if you were to set its duration to, say, 25 seconds.
-
If the fade does look smooth at 25 seconds, then try a lower number. And if that next run looks smooth, then try an even lower number. And so on. (And since you’re able to look at the logs during each test run, that may also offer some insight as to how much of a duration reduction you might be able to spare from one test run to the next.)
-
Eventually you’ll get to a point where the fade no longer looks smooth. And then if you go back to the duration from your previous test run, that’ll represent approximately the minimum duration that that particular lamp can fade over that brightness span while still fading smoothly.
A few closing tidbits:
-
I know that all of this is probably a lot to take in, so if you might get stuck anywhere along the way, feel free to reply here, and I’ll be happy to chime in.
-
If you might be unsure of how to interpret any of the debugging statements that you come across in your log, feel free to share them here, and I’ll do my best to help you out.