Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Adaptive Lighting #30

Closed
itavero opened this issue Dec 15, 2020 · 38 comments
Closed

[Feature] Adaptive Lighting #30

itavero opened this issue Dec 15, 2020 · 38 comments
Assignees
Labels
enhancement New feature or request

Comments

@itavero
Copy link
Owner

itavero commented Dec 15, 2020

After #18 is finished, support for Adaptive Lighting can probably be added for lights that exposes a color temperature property.

As a reference, the implementation for homebridge-hue can be looked into (see ebaauw/homebridge-hue#766).

@itavero itavero added the enhancement New feature or request label Dec 15, 2020
@itavero
Copy link
Owner Author

itavero commented Jan 26, 2021

Initially I thought of using the transition property to make a smooth transition and reduce the needed Zigbee traffic.
After asking about the maximum value of this property, it appears that it is very device dependent (some support many minutes, others support < 30 seconds).

I guess I'll have to see how often the values change and if the transition really adds anything.
Otherwise, I can always add an option to have the end user configure the transition time (and have a default of 0).

@thomaspleasance
Copy link

I'm looking at adding this via a pr what is the best way to call versiongreaterorequal ? https://developers.homebridge.io/homebridge/interfaces/api.html#versiongreaterorequal

@itavero
Copy link
Owner Author

itavero commented Feb 9, 2021

@thomaspleasance That would be awesome. I reckon you'd need this in the Light service handler, right?
I think we should add it to the BasicAccessory interface in that case.

@itavero
Copy link
Owner Author

itavero commented Feb 9, 2021

@thomaspleasance I wasn't aware of this function yet, but I think it's introduced in the version that's currently in beta.
Any particular reason you need it?

@thomaspleasance
Copy link

@itavero thats correct that’s why I want to check if it’s available to use. So I don’t break currently functionality

@itavero
Copy link
Owner Author

itavero commented Feb 10, 2021

@thomaspleasance Not sure if we are talking about the same thing. What I meant to say was that versionGreaterOrEqual will be in the next release of Homebridge (I don't believe it's in the current stable version already).

There are already a couple of plugins that have added support for Adaptive Lighting, so I don't believe we'll need anything specific from Homebridge that's currently in beta. Of course, please correct me if I'm wrong.

@thomaspleasance
Copy link

Yes you are correct versionGreaterOrEqual is only available in 1.3.0. I was planning on using https://developers.homebridge.io/HAP-NodeJS/classes/adaptivelightingcontroller.html what is now in 1.3 to do the Adaptive Lighting

@itavero
Copy link
Owner Author

itavero commented Feb 10, 2021

I wasn't aware that this is also added in 1.3.0. That would make life a lot easier.

I'll see if I can make a function for this in the BasicAccessory later today, that simply returns false if the function is versionGreaterOrEqual is not available on the API. This is also pretty much what is done in the BaseAccessory of homebridge-tuya to check if adaptive lighting is supported by the installed version of Homebridge.

PS: Thanks for making me aware of this. Just updated to the beta in my home setup and now I can also use adaptive lighting with some other plugin I'm using. 💡

@itavero
Copy link
Owner Author

itavero commented Feb 10, 2021

@thomaspleasance By the way, since this controller you've mentioned should make integration a piece of cake, I can probably also do it myself in the coming days, if you don't mind.

@itavero
Copy link
Owner Author

itavero commented Feb 10, 2021

Just wrote the code for the Homebridge server version requirement check during my lunch break and put it in a PR already so the GitHub Actions can do some verification.

My lunch break is over now, so no time to also integrate the Adaptive Lighting Controller, but I think I'll find some time later today or tomorrow.

@itavero
Copy link
Owner Author

itavero commented Feb 10, 2021

Basic integration is done, I guess, but there's still several things I want/need to verify (see PR for specifics).

@itavero itavero self-assigned this Feb 10, 2021
@thomaspleasance
Copy link

Will give it a test later and let you know if I find anything

@itavero
Copy link
Owner Author

itavero commented Feb 13, 2021

@thomaspleasance As mentioned in the PR, I still have some things to figure out to make it work better. I think in the end I should probably implement it using the manual mode, instead of the automatic mode, to make the transitions work better.

@itavero
Copy link
Owner Author

itavero commented Feb 13, 2021

Added some tests as well. Although I still see room for improvement, I think I'll just release the integration I have right now and have it run at home for a while.
I can always improve it later on if needed.

@jwilling
Copy link

This is awesome to see!

One thing I dislike about Hue's native adaptive lighting is that it's leans significantly on the colder side than I'd prefer. Unfortunately there's no way to modify this.

I'd definitely consider bringing my Hue bulbs into my Z2M ecosystem if it meant I could customize the upper and lower bounds of color temperatures. Is that something that the Homebridge adaptive lighting controller could allow? From a quick glance at the API it seems doubtful.

[moved comment from PR]

@itavero
Copy link
Owner Author

itavero commented Feb 15, 2021

@jwilling I think the homebridge-hue plugin has an adjustment factor for this. If I remember correctly, it actually uses a given percentage of the actual brightness to determine the color temperature. A lower brightness means a warmer color, so that would allow for some tuning/calibration.

I think I'll try to look into this, because for this to work, I definitely cannot use the automatic mode of the Adaptive Lighting controller built into Homebridge (which was already feeling a bit "less than ideal" for this plugin).

@itavero
Copy link
Owner Author

itavero commented Feb 20, 2021

No updates this week unfortunately. Been a bit busy at work, as well as doing some research for another project of mine.

@itavero
Copy link
Owner Author

itavero commented Mar 18, 2021

Been a bit short on time. I still intend to continue with this implementation, but to be honest, I don't know when I'll be able to do so.

The "automatic" version is sort of ready to go, I believe, but as mentioned before, it's not the ideal implementation.
However, due to my "lack" of time, I'm thinking of releasing it anyway.
At least it will help us gather feedback on how well it works "in real life". Based on that it might be possible to have a better understanding on what the "requirements" are for the manual implementation (what kind of configuration options would we need, what kind of "problems" do we need to try and prevent, etc.)

@itavero
Copy link
Owner Author

itavero commented Mar 21, 2021

Spent some time today preparing to release this. Added an option to set a minimum delta in color temperature before an MQTT message is published, as well as an optional transition value.
Both still based on the Automatic Mode of the Adaptive Lighting Controller.

Unfortunately I did notice that it's difficult to disable the adaptive lighting automatically when a different value is sent to Zigbee2MQTT by another MQTT client (or i.e. by a remote connected directly to a lightbulb).
At this point in time I do not yet have a good solution for this.

@RaffoNin
Copy link

Hi is there a way to try out the adaptive lighting feature? I do not use another MQTT broker to send commands nor do I use a remote. Would love to provide feedback.

@itavero
Copy link
Owner Author

itavero commented Aug 11, 2021

is there a way to try out the adaptive lighting feature?

I haven't worked on it recently, but the code I did make for this feature can be found in #60.
That branch is lagging a bit behind on the master branch, but I guess you could check it out and give it a spin.

@nikbyte
Copy link

nikbyte commented Sep 21, 2021

Any chance to include it to main branch?

@itavero
Copy link
Owner Author

itavero commented Sep 24, 2021

@nikbyte Unfortunately last time I worked on it, it was not ready to go into a release yet. master has changed in the mean time, so I will have to rebase the changes and still figure out the "loose ends". I don't expect that to happen in the near future (unfortunately I'm also struggling with some health issues).

@montanaishome
Copy link

Any chance of including this feature in a future release?

@philippebezoteaux
Copy link

philippebezoteaux commented Jan 17, 2022

Would love to see this integrated and be able to get rid of Hue’s bridge for starter !
Probably the main feature Z2M is missing…

@lcsjandrey
Copy link

please add support for adaptive lightning! <3

@itavero
Copy link
Owner Author

itavero commented Feb 20, 2022

I hoped to have time for this last month, but I didn't and I'm not sure when I will have time to do this.

I'm very busy at my work, doing new and exciting things. Not to mention the things going on in my personal life (all positive, luckily, but time consuming).

My earlier work on this, is pushed to the repository as well. If someone else has time to rebase it on master and put the changes behind a "experimental feature" flag (as is done with support for groups), I'd be happy to review it and give it a try.

@macfr76
Copy link

macfr76 commented Feb 20, 2022

That would be really great to get this feature. Unfortunately, I can't help for the code, but would be pleased to test and debug.

@chigy110
Copy link

I'd love to see this feature, as it is the Main-Reason, why I'm not migrating my hue-bulbs to z2m.

@zegl
Copy link
Contributor

zegl commented Jul 25, 2022

Hey. I just wanted to say that I've rebased #60 on top of the latest master (v1.9.0), and have published it to my fork and npm.

I'm currently testing with three different Hue lights to make sure that everything works as expected over a longer period of time (with Homebridge v1.5.0).

After two hours of testing, it's looking promising! (see screenshot)

Screenshot 2022-07-25 at 15 20 50

I'll send an updated PR once I'm sure that the adaptive lightning works perfectly, and have made the adaptive lightning feature opt-in as suggested by @itavero above.

@lcsjandrey
Copy link

lcsjandrey commented Jul 25, 2022 via email

@zegl zegl mentioned this issue Jul 25, 2022
4 tasks
@robsussman
Copy link

I'm interested in using adaptive lighting with homebridge-z2m and just came across this feature request which looks just like what I'm looking for! Any news on a PR to bring this over? Or, maybe I should just try out @zegl's fork? Thanks for any update...

@itavero
Copy link
Owner Author

itavero commented Sep 9, 2022

There's still some open points on the PR if I remember correctly. If I would have time, I might look into resolving them myself, but I don't have that (yet).

My wife and I are about the become parents in the very, very near future, so I'm not sure yet how that will affect my spare time. 😅

@robsussman
Copy link

Thanks for the update. Exciting to be entering parenthood, congrats! Yes, I don't think spare time will be a thing for quite some time. :)

@dotWee
Copy link

dotWee commented Oct 22, 2022

I'm really looking forward to this feature too! I have a lot of lights from different vendors in my network - if there's something we can test, make sure to give us an update!

@itavero
Copy link
Owner Author

itavero commented Dec 12, 2022

I think I'll be able to make a prerelease in the coming days that will include #488. You will have to enable adaptive lighting manually by setting an option in the light converter config, for example:

{
  "platform":"zigbee2mqtt",
  "defaults":{
    "converters":{
      "light":{
        "adaptive_lighting":true
      }
    }
  },
  "experimental":[
    "COLOR_MODE"
  ]
}

Things that still need more testing:

  • Disabling Adaptive Lighting when the state of the light is modified externally (which should of course not get triggered by changes from the Adaptive Lighting algorithm it self).
  • Does it work correctly if the COLOR_MODE experimental feature is not turned on? The docs on the AdaptiveLightingController mention that something like that is mandatory and it might still require more work.
  • How well does it function with multiple lights?

In general, it seems to work, but I'd love to get feedback on how well it works (as mentioned before).

Be aware that it is NOT released yet. Just wanted to give you guys a heads up 😉

@itavero
Copy link
Owner Author

itavero commented Dec 12, 2022

Just published v1.11.0-beta.0, which can be installed using npm i homebridge-z2m@next (or via the "Install Alternate Version" option in the Homebridge Config UI X web interface).

If you gave it a try, please let me know about your experiences and if there's any improvements you'd like to see.

@itavero
Copy link
Owner Author

itavero commented Dec 12, 2022

I've opened up a new discussion to gather feedback on this feature.

Please add your feedback to #590.

@itavero itavero closed this as completed Dec 12, 2022
Repository owner locked as resolved and limited conversation to collaborators Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests