basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant
https://basnijholt.github.io/adaptive-lighting/
Apache License 2.0
1.98k stars 141 forks source link

Add an option to update hue scenes based on a keywork #1019

Open BenoitAnastay opened 5 months ago

BenoitAnastay commented 5 months ago

This PR will let you set a keyword to search in your scenes list and update the set brightness and colortemp without changing power state.

It is usefull when you use Hue Bridge and you set your buttons to a scene. It is not working with multiple bridge instance, it will only update the first bridge, this behaviour is easy to fix but I don't have a second bridge make tests

Usage exemple:

  1. Create scenes with names like AL_living room celling light, AL_living room table top light, AL_living room all lights with the lights you want to be turned on.
  2. Add AL_living room as keyword and all living room scenes will be update

Solves #271

BenoitAnastay commented 5 months ago

@th3w1zard1 Hi, please have a look to this PR, you were interested into this implementation

th3w1zard1 commented 5 months ago

Well that was quite a rabbit hole of information I had forgotten about.

I am not familiar with the async code you're using. Usually we use hassio's api as migrating to other async implementations have caused bugs in the past. I know next to nothing about that.

other than that your implementation looks good. You are creating yet another attr, ensuring existing functionality will persist, showing a clear understanding of our process.

BenoitAnastay commented 5 months ago

@th3w1zard1 Thanks for the feedback, I'll now try to cleanup my PR, making tests pass.

I don't know how I can properly document this functionality to make it clear for everyone. I might also replace the keyword by a droplist of scenes light for lights entities, the configuration might take longer but it will help casual user to avoid error such as two overlaping keyword

For the main logic I know its robust, I use it since 2022 with another custom_integration (https://github.com/claytonjn/hass-circadian_lighting/pull/195)

BenoitAnastay commented 5 months ago

Hum there is a bug values aren't updated with daylight, it's probably out of range values of hue bridge, I'll check that

BenoitAnastay commented 2 months ago

I've added a delays of 5 minutes between same keyword update to avoid overloading the bridge. Maybe i'll need to add a delay between each API call as well