Adjust the brightness of a group of lights while maintaining the relative brightness between individual lights!
When adjusting the brightness of a group using the built-in light group, all the lights within the group would end up getting the same level no matter their previous level. I took a stab trying to fix that once before, but using a template light made it hard to maintain and it hurt reusability.
Now with the power of a custom component that’s built on top of the core light group, it’s as easy as adding just a few lines to your configuration.yaml file
Then search for Relative brightness light group to find and install it. Set up any lights you wish in your configuration file and restart Home Assistant if necessary.
Manually
Head over to the repository at GitHub, click the Code button and download the files either as a ZIP-file or using git.
From the downloaded files, move the folder that’s inside the custom_components folder into the custom_components folder in your HA config folder.
Restart Home Assistant
Configuration
To use, simply add this to your configuration.yaml file:
Note: Since I changed from using the IKEA Tradfri hub to the Philips Hue bridge, my brightness sliders started showing this “bouncy” behavior where it takes a second before all sliders are in the right place.
However, as far as I can tell this isn’t a problem introduced with my component ('ve seen the same happen with the core light group) so instead there’s something that needs fixing way beyond this component. Fingers crossed that it works better with your setup than in mine
Nice! Actually I have been waiting for this for a very long time. I will test this as soon as possible. Before, I achieved this using scripts and helpers, which was getting annoying to mantain as soon as the number of lights grew.
This is not a card for the dashboard but instead a way to create a new light entity.
Once you’ve gotten the files needed into your Home Assistant (either by downloading them or using HACS as mentioned in the first post), then you can add the code you quoted into your configuration.yaml file.
When that is done you can use any card for your dashboard that supports lights, for example the light card or tile, and then reference a new light.the_office that’s been created for you.
However, if you want the same look and feel as in the card I’ve done above, you’ll first need lovelace-slider-entity-row and then you can add a manual card with this YAML to your dashboard:
Hi Oscar,
I found out, that the manual adding in HACS gives an error, it says: there is a shop entry (or similar) i than searched in HACS and added your system, than the small sample was there, but there was no difference to a groug (still saw this one round slider around a lightbulb). I‘ll just try your suggestion and givea notice, if it worled.
Many thanks
Juergen
which turn on both lights with the main switch and the “rechts” light with the correct one, the long slider without a name is the one for the “links”, the on/off on top makes both lamps on and off, the “links” has no on/off. So it works “somehow”, but not as expected. I have absolutely no idea, where to search. I did install “relativ-brightness-light-geoup” and “slider-entity-row” thru the HACS Shop today so I think it should be the newest version.
The difference from your current setup to mine is that in my card I have included three lights:
The first one, the one with the full width, is the group one, the light.the_office for the whole office
The second and third one, not full width, are the individual lights in my office, the desk lamp (light.office_desk) and spotlights (light.office_spotlights) respectively.
So then when I change the brightness on the the first one the other two on the card will change too but in a way so that their “relative brightness” to each other is somewhat maintained.
So make sure to add your light.gartenlampen to your card as the first one. If no light.gartenlampen shows up that you can control, you might have to restart HA.
HI,
after the last update to 2024.5.2 in HA I get the following error:
2024-05-08 07:39:37.705 ERROR (MainThread) [homeassistant.config] Platform error: cover - No module named 'custom_components.relative_brightness_light_group.cover'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config.py", line 1439, in _async_load_and_validate_platform_integration
platform = await p_integration.integration.async_get_platform(domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1074, in async_get_platform
platforms = await self.async_get_platforms((platform_name,))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1151, in async_get_platforms
import_future.result()
File "/usr/src/homeassistant/homeassistant/loader.py", line 1121, in async_get_platforms
await self.hass.async_add_import_executor_job(
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1064, in _load_platforms
platform_name: self._load_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1238, in _load_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 1270, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 144, in protected_loop_func
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.relative_brightness_light_group.cover'
2024-05-08 07:39:38.142 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
2024-05-08 07:39:39.256 WARNING (ImportExecutor_0) [homeassistant.helpers.typing] HomeAssistantType was used from dwd_weather, this is a deprecated alias which will be removed in HA Core 2025.5. Use homeassistant.core.HomeAssistant instead, please report it to the author of the 'dwd_weather' custom integration
Hi,
I just noticed, that everything seems to work as before. So maybe this error comes from an old configuration I did when testing the system? I see the error, but it works, I do want to remove the error. Any idea, how to debug where it is coming from?
Have you tried using the integration with covers? I only think it will support lights. Or anything else in your configuration.yaml where there might be a conflict with covers and this integration?
Hi,
yes I am very successfully using it with covers It worked all before the last updates. Now this error occurs. But as I am a total newbie, I do not know if this is a configuration error on my side, or “something” has to be changed in the programming of this extension (I would beg for doing the change.) I see the error, but as far as I see it, it still works with the covers, “only” this python error occurs.
I hope/assum it is something that can be easily fixed.
If anyone is struggling, don’t forget to use the entity light.NAME in your automations, where NAME is the name of the room you specified in the configuration.yaml
Thanks for sharing - your code works like a charm!
I noticed that the relative levels seem to get “lost” as soon as the lights are turned off or set to max brightness. After turning on and off again, all brightness levels are set to the same value.
Is there a way to save desired relative brightness levels in a file (for example the configuration.yaml entry?) and then when the entire “relative brightness light group” is turned on recover those values?
Perhaps I have missed something in my configuration …