GithubHelp home page GithubHelp logo

fredck / lightener Goto Github PK

View Code? Open in Web Editor NEW
96.0 2.0 2.0 1.09 MB

Magically control the state and brightness of lights in Home Assistant.

License: MIT License

Python 99.00% Shell 1.00%
hacs-integration home-assistant light brightness

lightener's People

Contributors

ctso avatar dependabot[bot] avatar eifinger avatar eseglem avatar fredck avatar github-actions[bot] avatar iantrich avatar jcgoette avatar ludeeus avatar matthewflamm avatar mattrayner avatar misa1515 avatar mjmeli avatar oncleben31 avatar raman325 avatar rodpayne avatar rroller avatar swartjean avatar tetienne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

klatka misa1515

lightener's Issues

Error converting ulid lightener_context to bytes: ULID must be a 26 character string: lightener_context

First of all, thanks for the great work!

Home Assistant 2023.4.6
Supervisor 2023.04.1
Operating System 10.1

Hundreds of errors like the following are logged:

2023-05-02 20:21:17.542 ERROR (Recorder) [homeassistant.components.recorder.models.context] Error converting ulid lightener_context to bytes: ULID must be a 26 character string: lightener_context
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/models/context.py", line 19, in ulid_to_bytes_or_none
return ulid_to_bytes(ulid)
File "src/ulid_transform/_ulid_impl.pyx", line 23, in ulid_transform._ulid_impl._ulid_to_bytes
ValueError: ULID must be a 26 character string: lightener_context

Controll switches instead?

Hello

I tried your integration which seemed a really cool idea for me. Well done.
But, unfortunately for my scenario I think I can't use it.

My setup is a follows. My living room has ~6 lights which lighten the area. All of them are switches. The idea was to incrementally turn on the switches when I need more light in the room. Right now I do it manually. Based on my needs I turn on and off switches to achieve the level of light I want. I thought it would be a great idea to use something like your plugin (which to be honest didn't think about this kind of solution until I saw it).

When I tried to integrate it, my switches weren't available; only my (irrelevant) dimmable lights. Is this something you will think of implementing in the future? Or am I doing something wrong?

Thanks for the wonderful idea anyway :)

Error if a light reports brightness as float

Some light report their light levels as floats (e.g "54.9"). This causes Lightener to fail handling them with the following error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 287, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 607, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/group/light.py", line 160, in async_state_changed_listener
    self.async_defer_or_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/components/group/__init__.py", line 499, in async_defer_or_update_ha_state
    self.async_update_group_state()
  File "/config/custom_components/lightener/light.py", line 200, in async_update_group_state
    levels.append(entity.translate_brightness_back(entity_brightness))
  File "/config/custom_components/lightener/light.py", line 290, in translate_brightness_back
    return self.to_lightener_levels[brightness]
TypeError: list indices must be integers or slices, not float

"Task exception was never retrieved" errors at HA startup

The following warnings and errors are raised by the integration when Home Assistant starts. While the warnings are understandable if the referenced entities are not available yet (because the related integration hasn't started yet), the "Task exception was never retrieved" errors look like an anomaly that could be fixed (or catched and turned into other warnings? - just guessing here).

Thanks and keep up the great work!

Home Assistant 2023.5.0
Supervisor 2023.04.1
Operating System 10.1
Frontend 20230503.1 - latest

WARNINGS:
2023-05-04 07:45:40.453 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.led_tv or it is/they are currently not available
2023-05-04 07:45:40.480 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.piantana_salone or it is/they are currently not available
2023-05-04 07:45:40.482 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.applique_tavolo or it is/they are currently not available
2023-05-04 07:45:40.485 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.applique_tv or it is/they are currently not available
2023-05-04 07:45:40.487 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.faretti or it is/they are currently not available
2023-05-04 07:45:40.489 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.lampada_ingresso or it is/they are currently not available
2023-05-04 07:45:40.491 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.luce_ingresso or it is/they are currently not available
2023-05-04 07:45:40.494 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.piantana_camera or it is/they are currently not available
2023-05-04 07:45:40.496 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.luce_camera_sotto or it is/they are currently not available
2023-05-04 07:45:40.499 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.abat_jour_pepo or it is/they are currently not available
2023-05-04 07:45:40.501 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.abat_jour_pepa or it is/they are currently not available
2023-05-04 07:45:40.503 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.luce_camera_sopra or it is/they are currently not available
2023-05-04 07:45:40.505 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.luce_scrivania or it is/they are currently not available
2023-05-04 07:45:40.508 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities light.luce_palestra or it is/they are currently not available

ERRORS:
2023-05-04 07:45:45.336 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:45.832 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:46.279 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:46.468 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:46.471 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:46.501 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'
2023-05-04 07:45:46.502 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/lightener/light.py", line 198, in _async_child_state_change
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 198, in
if any(entity.state == STATE_ON for entity in self._entities):
File "/config/custom_components/lightener/light.py", line 267, in state
return self._hass.states.get(self._entity_id).state
AttributeError: 'NoneType' object has no attribute 'state'

Brightness is off by 1 percent on a defined setting

I have a setting that defines 30:50 (and 30:75 for the other light). As seen in the image when the brightness is set to 30%, the percentages of the lights are 49% and 74%.
While that is understandable with calculated values, I think this shouldn't happen at defined settings.

Is this happening to others?

image

Wrong brightness when turning on

Hi,

I am experiencing unexpected behavior, when turning on my lightener lights:

My lightener group consists of two dimmable lights. The first one has a default mapping. The second one should turn on when the virtual light is at 50%.

Everything is working as expected, when I use the brightness slider of my virtual light. But when I only toggle it on, without setting a brightness value, I get unexpected behavior.

Lets say, the last brightness of my virtual light was 30%, before I turned it off. Light 1 was also 30% , light 2 was off. When I switch the virtual light back on, it recovers its last brightness value (30%). The light with default mapping is then turned on correctly with 30%. And here the unexpected thing: light 2 is also turned on, even though it should stay off.

Edit:
Mapping for light 2:
50:0
100:100

Allow color temperature control through lightener light

Could this be updated to allow control of child-lights color-temperature through the parent light?

Currently you cannot use both adaptive-lighting (Or circadian lighting) as it'll fight to update the brightness of the children lights. You can disable the children in adaptive-lighting but then you lose the color temperature updates. If this plugin would allow passthrough color temperature, you could remove children lights from adaptive lighting and just allow control of the parent light

Quick brightness state flashing sometimes

There are some situations where the brightness slider may very quickly flash to previous states when using it. Some incorrect states may also happen when turning the Lightener on and off.

After some investigation, this all happen because of a single important difference between Lightener and Light Groups. In Light Groups, all controlled lights are changed at once, in a single service call to "turn_on", while in Lightener we do individual calls for each light since each has to be set to different brightness levels. This difference makes Lightener run its calculations while the lights are still not in a configuration that is compatible to any of the Lightener levels and this confuses the state in ha.

Anyway, it's hard to explain but this is figured so now a solution is coming.

Add integration error

I added and integrated it to show User input malformed: extra keys not allowed @ data['filter'] How can I improve it?
Thanks

Conditional lights / tempating to allow difference between night and day

Hi,

First of all I want to say that I really like this integration, because it makes is so much easier to easily operate the lights in one room.
I started to play with the integration this week, and I was wondering what would be the best solution for the following.
Some rooms have different settings during daytime and nighttime in my setup. For example, during the normal scene in my home, one light is 100% during the day, and 50% during the night. Another light never turns on during the day and is 100% during the night.

I have more scenes that I can fit into the setup of the integration by assigning a percentage of the Lighener entity to each scene I currently have, but difference between day and night does not seem to be possible.
Is it possible to do this with templating? ( I am not very good at tempating, so I lack the knowledge to know the possibilities)
Or is there another easy way to do this? The easiest way seems to be to make two Lighteners per room, and show the correct one on the lovelace dashboard by using templates to determine day/night, but I would like to have this in one lighener if possible.

With kind regards,
Patrick

Ghost in the lights

I have 16 WiZ bulbs set up in one lightener device. All of which have 4 mapping lines, allowing me to gradually turn them on one by one, and then gradually increase brightness slowly.

When it works it's great, but after setting this up, the lights change brightness on their own every few minutes, always down, until they eventually turn off. The mapping config also slowly drifts "off", so that 100% on the lightener device seems to only go to about 30% on the config.

The automation that connects the wireless rotary dimmer to the light is not being triggered when the dimming happens, and there is nothing in the logs. I've turned on debug logging for the integration, but nothing their either.

Any ideas?

When color temperature is set all lights turn on

As the title suggests if you set the color temperature or RGB color of a lightener light it turns all of the lights in the group on regardless of the brightness level. This breaks the functionality when using a lightener light in automatons if color is set or other integrations like adaptive lighting.

Control covers?

Hi @fredck ,

I have four smart blinds in my basement that all share a top position, but one of the four is shorter than the other three. (It sounds a little odd but actually makes sense in the room.)

I found myself wishing I could control them more naturally as a group. I currently have them grouped in HA, but when setting them to a position other than fully open or fully closed, it's a little unfortunate that they don't visually line up. As a current lightener user, I immediately wondered whether lightener could create a cover group that allowed me more sophisticated control of the cover ranges (so that the oddball shade would line up with the others at arbitrary percentages).

I see that you mentioned this in #26 as originally part of the scope of the integration but eventually set aside. I was curious if your thinking remains the same there? Assuming you want lightener to remain light-specific, do you have any thoughts on what would be involved in hacking up a version that works for shades, before I dive into it?

Thanks!

Optimistic state preference

The Lightener instance seems to try to reflect the real state of associated lights. This on it's own isn't wrong behavior per se, but can severely affect control in the case of physical dimmer control, especially if the instance is comprised of different light types.

Events from a knob on the wall fire at much higher rate than when clicking around in the HA UI as per example GIF in the readme. When that rate collides with Lightener updating it's real state, the brightness slider will eventually start jumping all over the place.

Example:
I can be dimming a group of lights from 50% to 10% and during that attempt the brightness can go all the way up to 100%, all they way down to 0 or anywhere in between.

How to replicate:
In my case, I use the old Ikea Sonos Volume Control zigbee knob via ControllerX with repeat delay set to 100ms โ€” that means when I turn the knob, change to brightness is triggered 10 times in 1 second. While it's default of 500ms would probably solve the issue, the experience is far from "dimmer-like".

Alternatively, clicking violently on the brightness slider (up and down) yields similar results.

Ideally, having an "optimistic" bool attribute or delay number attribute (time after which the real state of lights is updated, say, 1 second after last change), would most certainly help my case.

Lights that support `color_temp` can't be controlled properly

Lightener is not able (sometimes) to calculate its own brightness properly if any of the controlled lights has support for color_temp. When the issue happens:

  • The Lightener level is set to None.
  • The controlled light level also keeps set to None, although physically the light shows the proper brightness.

I was able to more easily confirm this with Zigbee2MQTT group lights but this doesn't happen always.

Allow settings value to not affect a light below 0

hi, great addon.

My use case is that I have 6 lights from Zigbee2MQTT, sending individual commands to each lightbulb is network expensive, so I additionally have these 6 in a group so there's only 1x command being sent.

The bulbs don't get very dim, so I want to turn these on one-by-one between brightness levels 1-6, after that, I want to start using the group as normal.

image

Group is 0 up till brightness level 7, after which it scales to 100.
image

Individual light 1 turns on at 1% brightness, should stay at 1% until lightner goes past 6%
image

Individual light 2 turns on at 2% brightness, should stay on at 1% until lightner goes past 6%
image

... etc

Up to individual light 6
image

What actually ends up happening between levels 1-6 is that the individual lights are correctly controlled, they are set to 1% brightness in sequence. But the group is also controlled, setting the group brightness down to 0 (turning them all off).

Suggestion is, to add some additional value to the settings (maybe 1:null) which would mean that the light does not get controlled at all during these levels. For my use case, I would set the group to be 6:null, 7:1 so below 7 % the light is not controlled at all (thus not switching off the group).

Configuring via UI is hard.

First off, thanks so much for this integration, an absolute game-changer for our home!

I have a 16-bulb light, and I use lightener to turn them on one by one before starting to increase brightness after they are all on. I do this because the lowest brightness with all on is too bright most of the time. Each light is configured with 3 - 5 mapping lines.

If I configure this in the UI, I only see one light at a time, out of 16, and have to pay close attention that I'm adding the correct mapping to the correct light, and have to actually lay it out fully in text beforehand, since I have no overview in the UI config. There's also no back button, so if I make a mistake, or have to double check something, I have to start over.

Any chance you can do the light mapping on one screen instead?

State wrong after reboot

Thank you for this integration, its really useful.

The only "problem" I've found is that after a reboot the state is wrong

image

if I set it to 50% and then reboot HA the state always will be 100%.

Disabling color

My lights are dimmers only, is there a way to disable the light color/warmth capabilities?

Unable to turn lights on by light card after latest update

Pretty new to this integration so I'm not sure what's going on yet, but previously I could toggle an "off" lightener group to on using the "on/ off" part of the light card, however that doesn't seem to work now. Turning the lights off works fine. Setting a brightness level whilst off also will turn them off, it is only the direct "Off to On" that isn't working

Since 2.1.x a Lightener group is only dimmable if it contains at least one dimmable light

Before version 2.1.x (e.g. with 2.0.0), a Lightener group of non-dimmable (on/off) lights was created correctly as a dimmable entity, which allowed to incrementally turn on/off different lights in the room depending on the percentage of the Lightener.

Since 2.1.x instead, if the group of lights does not contain any dimmable light, the Lightener is created as an on/off entity, which only allows to turn all lights on or off at once, defeating the purpose of having a Lightener over a conventional group.

Would it be possible to restore the previous behavior and always have Lightener as a dimmable entity regardless of the nature of the lights it contains?

Improvement: have an attribute that shows whether the lights are in sync with Lightener

I would really like an attribute, or seperate entity, that shows whether the lights that are in a lightener group are in sync with the configuration or not. This way it is possible to know if a light has been manually turned up or down and this could block any automations after a manual adjustment. This would greatly improve my automations. Would this be possible?

No config flow

The docs say I should get a configuration flow but I get this instead

IMG_2111

Lightener percentage is not set correctly with non-dimmable lights

When a Lightener group is a mix of dimmable and non-dimmable lights, setting Lightener percentage works well only with dimmable lights. When you are in a percentage range reserved to a non-dimmable lights, instead, changing percentage doesn't work and the Lightener percentage gets stuck to the value at which the light was turned on.

Please refer to the sample video below.

Lightener.mp4

Lightener version: v2.2.1

Lightener configuration in the example is the following:

  • Lamp (dimmable): 50: 100
  • Ceiling Light (non-dimmable): 50: 0

Thank you for the great work! Lightener is super-cool!

Lightener percentage is not set correctly at first turn-on with non-dimmable lights

Lightener version: 2.2.2

Although the situation with v2.2.2 improved a lot compared to what reported in #97 against v2.2.1 (thanks for it!), when a non-dimmable light is involved, the Lightener percentage is still not set correctly at first turn-on. See example in video below.

Lightener configuration in the example is the following:

  • Lamp (dimmable): 50: 100
  • Ceiling Light (non-dimmable): 50: 0

The expected behaviour would be for Lightener to keep the percentage set by the user; instead, it falls back automatically to 51%.

Lightener2.2.2.mp4

Many thanks again for the great work with Lightener! It deserves being in HA Core.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.