Closed cakefornoreason closed 7 years ago
At the moment it is by design, to keep the behavior simply I choose this method.
One problem is when doing an { "on": false, "bri": 88, "duration": 20000 }
, because we don't want to go to brightness 80% and then fade to off we need to add an timer that updates light color after 20s, then we need to clear this timer if another command is received before the time has passed.
I'm not against the idea, I just need to figure out what level I should support and how
I see what you mean as far as not wanting the brightness to conflict with the power setting. As I'm still fairly new to straight-up code, so I don't fully understand what I'm looking at when I dive in, but my instinct is that it may not be that complex to support.
I actually found this repository after first working with diegopamio's node-red-contrib-lifx project, and under that, if I sent the payload { "on" = false, "hue" = "0", "saturation" = "0", "luminance" = "80", "whiteColor" = "8000", fadeTime = "20000" } to a light that was on, the light would power off immediately, ignoring the fadeTime (aka Duration). Both the luminance (brightness) and whiteColor (kelvin) would still be sent to the light, so when powered back on it would show the newly selected color. Similarly, if I sent the same payload to a light that was already off, the color would be set correctly when it next came on.
I'm not sure if that's due to a part of his code, a natural behavior of the bulb, or part of node-lifx, but it might be worth checking for comparison. One interesting difference is that his code really only allowed for duration to be used during color transitions--I had to hard code what was supposed to be a variable in the actual node-lifx package to set a duration for power on/off changes. Perhaps we just need two variables, one for color change duration and a different one for power toggle duration?
Anyway, all that to say that as one user of your code, (and admittedly not a super savvy one) I'd love the ability to send color changes to lights that are powered off, but I definitely see the challenge.
I don't really see the usefulness of setting the color when the light is off. If I want a specific color when I turn the light on I specify that color when sending the on state, this results in that behind the scene the color is first set and then slowly fade the light on using the duration,
As a first step I'm thinking of allowing setting of the light color when the light is off, I also will enable syncing of the color when the light is off. This means that you can implement this manually by first fading the light and then set the color after the fade is done.
Your line of thought definitely makes sense, and I think my usage is a little specific. My approach has been to treat power toggling and color changing as separate tasks controlled with buttons and writing my flows accordingly. I do think I could implement it in the way you're talking about, I'd just have some editing to do.
And though it'd take some time and effort to build up my code skills, I could always fork the project and make some adjustments for my situation, provided that was okay with you. I'm also hoping to put multizone support for the LIFX Z into my final product, but node-lifx hasn't finished support for that just yet. It sounds like they're on track to finish soon, though.
Thanks again for sharing the project!
I've been testing my setup with this latest update and it's working great for me.
I spent a bit of time reviewing your code, and I like this approach. You're right that most people aren't going to toggle the light off and change the color at the same time. In my case, I wanted to change the color on a bulb while it was off so that I could keep a schedule of scenes going regardless of whether or not a light was on when the scene was sent to the bulb. Being able to change the color without turning on the light is exactly what I needed, and I think something that others might find useful too.
Much appreciated!
Hey! So last night I reworked the code that runs my lights to swap the old LIFX nodes for yours, and in large part it works perfectly. I did discover one possible bug, though.
If the bulb is powered off (still powered on at the wall switch, but in an "on": false state) it appears that no color updates are sent to it. In my setup, I schedule light changes for specific times of day and ideally, I'd want the color to update even if the bulb isn't lit so that the color will be as scheduled when the bulb is turned on later.
Is that a bug or an intentional behavior of the node?