Ashley’s Light Fader 2.0✨: fade lights and/or color temperature with your choice of easing (curves), including ease-in, ease-out, and ease-in-out

Hi Ashley, thank you for the guidance. Here is the log after clicking Run twice. The first click didn’t turn the lights up but it did trigger a log. The second click finally turned on the light but it still is dim.

Edit: Looks my WyzeAPI error creeped in there as I took down the log :smiley:

2024-02-01 22:44:14.645 WARNING (MainThread) [homeassistant.components.system_log.external] easeOutCubic easing type with 100 ms delay. remainingTimeInMilliseconds = 4873, and absoluteBrightnessSpan = 50
2024-02-01 22:44:14.645 WARNING (MainThread) [homeassistant.components.system_log.external] startBrightness = 0, endBrightness = 50, and processingDelayInMilliseconds = 125
2024-02-01 22:44:14.787 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 4 brightness. (Linear brightness would have been 1.) Delay is 100 ms. Elapsed time is 0.27 seconds. (endBrightness is 50.)
2024-02-01 22:44:14.890 WARNING (MainThread) [homeassistant.components.system_log.external] Stopped Ashley’s Light Fader because Kitchen Light was turned off during the fade.
2024-02-01 22:44:21.803 ERROR (MainThread) [homeassistant.util.logging] Exception in handle_camera_update when dispatching 'wyzeapi.camera_updated-GW_GC1_D03F2773143A': (<Device: DeviceTypes.CAMERA, GW_GC1_D03F2773143A>,)
Traceback (most recent call last):
  File "/config/custom_components/wyzeapi/switch.py", line 455, in handle_camera_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1557, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/wyzeapi/switch.py", line 444, in is_on
    return self._device.motion
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Camera' object has no attribute 'motion'
2024-02-01 22:44:22.041 WARNING (MainThread) [homeassistant.components.system_log.external] easeInOutSine easing type with 100 ms delay. remainingTimeInMilliseconds = 4878, and absoluteBrightnessSpan = 46
2024-02-01 22:44:22.041 WARNING (MainThread) [homeassistant.components.system_log.external] startBrightness = 4, endBrightness = 50, and processingDelayInMilliseconds = 120
2024-02-01 22:44:22.486 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 5 brightness. (Linear brightness would have been 8.) Delay is 100 ms. Elapsed time is 0.57 seconds. (endBrightness is 50.)
2024-02-01 22:44:22.722 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 6 brightness. (Linear brightness would have been 10.) Delay is 100 ms. Elapsed time is 0.8 seconds. (endBrightness is 50.)
2024-02-01 22:44:22.951 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 8 brightness. (Linear brightness would have been 12.) Delay is 100 ms. Elapsed time is 1.03 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.180 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 10 brightness. (Linear brightness would have been 14.) Delay is 100 ms. Elapsed time is 1.26 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.459 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 12 brightness. (Linear brightness would have been 17.) Delay is 100 ms. Elapsed time is 1.54 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.694 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 15 brightness. (Linear brightness would have been 19.) Delay is 100 ms. Elapsed time is 1.78 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.960 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 18 brightness. (Linear brightness would have been 21.) Delay is 100 ms. Elapsed time is 2.04 seconds. (endBrightness is 50.)
2024-02-01 22:44:24.196 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 22 brightness. (Linear brightness would have been 24.) Delay is 100 ms. Elapsed time is 2.28 seconds. (endBrightness is 50.)
2024-02-01 22:44:24.298 WARNING (MainThread) [homeassistant.components.system_log.external] Stopped Ashley’s Light Fader because Kitchen Light was found to be at 12%, a difference of 10 percentage points from the expected brightness of 22%, which is higher than the auto-cancel threshold of 10 percentage points.

Hi Ashley, so I decided to disable the Brightness-change threshold that auto-cancels the fade and the Cancel the fade if the lamp is turned off during the fade? options and now the light goes all the way too 100, but it’s extremely jumpy with a very quick flashing off and then back on to 100% at the very end. I changed the minimum delay step to 200ms. Should I go higher?

Here is the log -

024-02-01 22:59:01.877 WARNING (MainThread) [homeassistant.components.system_log.external] easeInOutSine easing type with 200 ms delay. remainingTimeInMilliseconds = 4876, and absoluteBrightnessSpan = 100
2024-02-01 22:59:01.878 WARNING (MainThread) [homeassistant.components.system_log.external] startBrightness = 0, endBrightness = 100, and processingDelayInMilliseconds = 123
2024-02-01 22:59:02.222 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 1 brightness. (Linear brightness would have been 7.) Delay is 200 ms. Elapsed time is 0.47 seconds. (endBrightness is 100.)
2024-02-01 22:59:02.658 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 4 brightness. (Linear brightness would have been 13.) Delay is 200 ms. Elapsed time is 0.91 seconds. (endBrightness is 100.)
2024-02-01 22:59:02.999 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 12 brightness. (Linear brightness would have been 22.) Delay is 200 ms. Elapsed time is 1.25 seconds. (endBrightness is 100.)
2024-02-01 22:59:03.335 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 19 brightness. (Linear brightness would have been 29.) Delay is 200 ms. Elapsed time is 1.58 seconds. (endBrightness is 100.)
2024-02-01 22:59:03.755 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 28 brightness. (Linear brightness would have been 36.) Delay is 200 ms. Elapsed time is 2.0 seconds. (endBrightness is 100.)
2024-02-01 22:59:04.082 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 41 brightness. (Linear brightness would have been 44.) Delay is 200 ms. Elapsed time is 2.33 seconds. (endBrightness is 100.)
2024-02-01 22:59:04.492 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 51 brightness. (Linear brightness would have been 51.) Delay is 200 ms. Elapsed time is 2.74 seconds. (endBrightness is 100.)
2024-02-01 22:59:04.891 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 64 brightness. (Linear brightness would have been 59.) Delay is 200 ms. Elapsed time is 3.14 seconds. (endBrightness is 100.)
2024-02-01 22:59:05.222 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 75 brightness. (Linear brightness would have been 67.) Delay is 200 ms. Elapsed time is 3.47 seconds. (endBrightness is 100.)
2024-02-01 22:59:05.548 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 84 brightness. (Linear brightness would have been 73.) Delay is 200 ms. Elapsed time is 3.8 seconds. (endBrightness is 100.)
2024-02-01 22:59:05.872 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 90 brightness. (Linear brightness would have been 80.) Delay is 200 ms. Elapsed time is 4.12 seconds. (endBrightness is 100.)
2024-02-01 22:59:06.202 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 96 brightness. (Linear brightness would have been 86.) Delay is 200 ms. Elapsed time is 4.45 seconds. (endBrightness is 100.)
2024-02-01 22:59:06.524 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 99 brightness. (Linear brightness would have been 93.) Delay is 200 ms. Elapsed time is 4.77 seconds. (endBrightness is 100.)
2024-02-01 22:59:06.853 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 100 brightness. (Linear brightness would have been 99.) Delay is 200 ms. Elapsed time is 5.1 seconds. (endBrightness is 100.)
2024-02-01 22:59:07.186 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 100 brightness. Elapsed time is 5.43 seconds.

@aquariuz23 I think that you made some good choices by disabling the options for Brightness-change threshold that auto-cancels the fade and Cancel the fade if the lamp is turned off during the fade?—those are exactly the same first steps that I would’ve taken too!

What I think may be part of what’s causing your issues is that some light brands are somewhat slow in reporting their updated brightness values back to Home Assistant—and in those cases, the script might send several “set brightness to X” commands to the lamp, but when the script then says to the lamp “What’s your current brightness?”, the lamp replies with a brightness value that doesn’t yet reflect the most recent “set brightness to X” command that had been sent to it.

For instance, in the second half of your log file, it looks like the script is sending “set brightness to X” commands of 5, 6, 8, 10, 12, 15, 18, and 22 over a span of 2.28 seconds:

2024-02-01 22:44:22.486 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 5 brightness. (Linear brightness would have been 8.) Delay is 100 ms. Elapsed time is 0.57 seconds. (endBrightness is 50.)
2024-02-01 22:44:22.722 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 6 brightness. (Linear brightness would have been 10.) Delay is 100 ms. Elapsed time is 0.8 seconds. (endBrightness is 50.)
2024-02-01 22:44:22.951 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 8 brightness. (Linear brightness would have been 12.) Delay is 100 ms. Elapsed time is 1.03 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.180 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 10 brightness. (Linear brightness would have been 14.) Delay is 100 ms. Elapsed time is 1.26 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.459 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 12 brightness. (Linear brightness would have been 17.) Delay is 100 ms. Elapsed time is 1.54 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.694 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 15 brightness. (Linear brightness would have been 19.) Delay is 100 ms. Elapsed time is 1.78 seconds. (endBrightness is 50.)
2024-02-01 22:44:23.960 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 18 brightness. (Linear brightness would have been 21.) Delay is 100 ms. Elapsed time is 2.04 seconds. (endBrightness is 50.)
2024-02-01 22:44:24.196 WARNING (MainThread) [homeassistant.components.system_log.external] Set Kitchen Light to 22 brightness. (Linear brightness would have been 24.) Delay is 100 ms. Elapsed time is 2.28 seconds. (endBrightness is 50.)

…But from there, when the script then asks the lamp “What’s your current brightness?”, the lamp seems to be replying with 12, which looks to be about 0.74-ish seconds (or around 740-ish ms) behind from the brightness value that it should be confirming with.

(I calculated that 0.74-ish second lag by taking the “set to 22 brightness” command’s timestamp of 2.28 seconds and then subtracting the “set to 12 brightness” command’s timestamp of 1.54 seconds.)

Changing the minimum delay step to 200ms is probably a good first step.

As a next step, you could potentially try going even higher. Or as an alternate approach—and what may be more involved but what may be more fruitfulI—I might be inclined to try these steps:

  1. Try setting up a separate test automation that you can mess about with—and with the logging enabled—then try applying a fade of, say, 1 minute.
  2. If that fade works as expected, try running that test automation with a somewhat quicker fade—say, 30 seconds.
  3. Then if that fade works as expected, try running that test automation with a somewhat quicker fade—say, 15 seconds.
  4. And then if that fade works as expected, try running that test automation with a somewhat quicker fade—say, 10 seconds.

And then continue those steps with shorter and shorter fades until you get to a point where the fade breaks.

Then re-run the most recent fade that had worked properly, and take another look at your logs to check on what the calculated delay was for that fade. (The calculated delay for a given fade is shown in the logs under the easing type with Y ms delay line.)

Once you reach that point, that Y ms delay probably represents a ballpark starting point that you might try when setting the script’s minimum delay per step option.

PS As always, if any of this might not quite make sense or if you might have any other questions, feel free to reply here and I’ll do my best to help!

Thanks for the quick reply!

The log shows:

Stopped Ashley’s Light Fader because a color fade was requested for LED Streifen Schlafzimmer, but its current color temperature doesn’t seem to be defined using Kelvin units. (You can look into this by going into Developer Tools and checking that LED Streifen Schlafzimmer has a defined “color_temp_kelvin” attribute.)

Those are the attributes:

max_color_temp_kelvin: 4000
min_mireds: 250
max_mireds: 454
effect_list: blink, breathe, okay, channel_change, finish_effect, stop_effect
supported_color_modes: color_temp, xy
color_mode: color_temp
brightness: 1
color_temp_kelvin: 2242
color_temp: 446
hs_color: 29.65, 82.775
rgb_color: 255, 148, 43
xy_color: 0.575, 0.389
effect: null
friendly_name: LED Streifen Schlafzimmer
supported_features: 44 

Thus the lamp seems to support the functionality, but it somehow isn’t detected correctly.

@RaBoom So, uh, it didn’t take long for me to figure out why this lamp is being a bit wonky—but the how to fix it part isn’t quite so clear. I’ll explain:

When a color-temperature fade is requested, the script relies upon the lamp having defined attribute values for min_color_temp_kelvin and max_color_temp_kelvin—in part as safety measures so that if the user were to select a color temperature that’s outside of that range, the script could automagically nudge that color-temperature value to be within the bounds of what the lamp expects.

And in the case of your lamp, it’s reporting max_color_temp_kelvin: 4000, but there seems to be no corresponding attribute for its min_color_temp_kelvin value?

(For instance, the script’s UI lets users set a color temperature up to 6500°—but with this lamp, because it has max_color_temp_kelvin: 4000, the script can automagically make sure that it doesn’t try to set a color temperature value that’s any higher than 4000°K.)

I almost feel bad to ask, but by any chance have you perhaps tried connecting your Ormanäs LED light strip through ZHA? (I’m just curious as to whether ZHA might properly report min_color_temp_kelvin and max_color_temp_kelvin attributes for the lamp?)

PS Whether or not you might end up trying to connect the lamp through ZHA, there’s also a chance that I miiight be able to adjust the script to infer min_color_temp_kelvin and max_color_temp_kelvin values based on the values of a lamp’s min_mireds and max_mireds attributes. (That might take a bit of fiddling to code and get working, but that might not be out of the question if there might be no other options here.)

I am very sorry for the confusion, I made an error in copy pasting, it reports

min_color_temp_kelvin: 2202

@RaBoom Just to check, is that min_color_temp_kelvin: 2202 attribute in addition to the max_color_temp_kelvin: 4000 that you had mentioned previously—or is that instead of the max_color_temp_kelvin value?

(In other words, does the lamp list both min_color_temp_kelvin and max_color_temp_kelvin? Or does it list only a min_color_temp_kelvin value?)

It’s in addition, it lists both.

Here’s the full list, just for reference:

min_color_temp_kelvin: 2202
max_color_temp_kelvin: 4000
min_mireds: 250
max_mireds: 454
effect_list: blink, breathe, okay, channel_change, finish_effect, stop_effect
supported_color_modes: color_temp, xy
color_mode: null
brightness: null
color_temp_kelvin: null
color_temp: null
hs_color: null
rgb_color: null
xy_color: null
effect: null
friendly_name: LED Streifen Schlafzimmer
supported_features: 44

@RaBoom Ohh—I miiight have an idea here?

I wonder whether the script might be exiting early because the lamp’s color_temp_kelvin attribute (which represents the lamp’s current color temperature, in Kelvin) is set to color_temp_kelvin: null ?

Just out of curiosity, when you grabbed those attribute values for the lamp, was the lamp off at the time? (That could potentially explain why color_temp_kelvin was set to null .)

Granted, the script is supposed to be able to account for a lamp being off—so even if your lamp was indeed off at the start of the fade, that theoretically shouldn’t matter? But just in case it might narrow anything down, if you were to try running the script when the lamp is already on, does that make any difference?

1 Like

Switched to a Home Assistant Green with latest HA. Random error happened today:

Logger: homeassistant.components.script.ashley_fade_light
Source: helpers/script.py:476
Integration: Script (documentation, issues)
First occurred: 9:10:46 AM (4 occurrences)
Last logged: 9:10:46 AM

Ashley’s Light Fader: Repeat at step 7: If at step 2: If at step 1: Error executing script. Unexpected error for call_service at pos 1:
Ashley’s Light Fader: Repeat at step 7: If at step 2: Error executing script. Unexpected error for if at pos 1:
Ashley’s Light Fader: Repeat at step 7: Error executing script. Unexpected error for if at pos 2:
Ashley’s Light Fader: Error executing script. Unexpected error for repeat at pos 7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pylutron_caseta/smartbridge.py", line 254, in _request
    response = await self._leap.request(communique_type, url, body)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pylutron_caseta/leap.py", line 71, in request
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 624, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/lutron_caseta/light.py", line 75, in async_turn_on
    await self._set_brightness(brightness, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lutron_caseta/light.py", line 67, in _set_brightness
    await self._smartbridge.set_value(
  File "/usr/local/lib/python3.11/site-packages/pylutron_caseta/smartbridge.py", line 343, in set_value
    await self._request(
  File "/usr/local/lib/python3.11/site-packages/pylutron_caseta/smartbridge.py", line 253, in _request
    async with asyncio_timeout(REQUEST_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The yaml:

- id: 'da1fd15c-351c-11ee-be56-0242ac120002'
  alias: Kitchen lights on with lots of cloud cover at 9am if on
  trigger:
    platform: time
    at: 09:10:05
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.lightlevel_kitchen
      below: 451
    - condition: state
      entity_id: group.kitchen
      state: 'on'
    - condition: state
      entity_id: cover.velux_left
      state: open
    - condition: state
      entity_id: cover.velux_right_2
      state: open
  action:
  - parallel:
    - service: script.ashley_fade_light
      data:
        lampBrightnessScale: zeroToOneHundred
        easingTypeInput: auto
        endBrightnessPercent: 50
        autoCancelThreshold: 10
        endBrightnessEntityScale: zeroToOneHundred
        minimumStepDelayInMilliseconds: 100
        isDebugMode: false
        light: light.kitchen_main_lights
        transitionTime:
          hours: 0
          minutes: 1
          seconds: 30
    - service: script.ashley_fade_light
      data:
        lampBrightnessScale: zeroToOneHundred
        easingTypeInput: auto
        endBrightnessPercent: 70
        autoCancelThreshold: 10
        endBrightnessEntityScale: zeroToOneHundred
        minimumStepDelayInMilliseconds: 100
        isDebugMode: false
        light: light.kitchen_under_cabinet
        transitionTime:
          hours: 0
          minutes: 1
          seconds: 30
    - service: script.ashley_fade_light
      data:
        lampBrightnessScale: zeroToOneHundred
        easingTypeInput: auto
        endBrightnessPercent: 50
        autoCancelThreshold: 10
        endBrightnessEntityScale: zeroToOneHundred
        minimumStepDelayInMilliseconds: 100
        isDebugMode: false
        light: light.kitchen_sink_light
        transitionTime:
          hours: 0
          minutes: 1
          seconds: 0

Pretty sure this has worked fine in the past and has been in use for several months.

Any ideas?

@derekcentrico Hmm. I don’t have any particular ideas as to what might be going on here. (Just to check, I take it that you’re on Home Assistant 2024.1.6?)

Out of curiosity, if you go to Developer Tools → Services, and if you manually call Light: Turn On with a particular specific brightness level for that same light, does that work?

Also, does anything peculiar show up in the Home Assistant logs if you enable the script’s debugging mode?

Hi Ashley, apologies for the late reply, haven’t had the chance to play and test around more with the script.

Interestingly, I decided to test on a smart wall dimmer switch that is the same brand as the first one I tested with but in a different part of the house, and this one didn’t experience any weird flashing and jumping after it reached to intended brightness. I do however notice that if I uncheck Minimum Delay per Step and get an error stating that I need to define Minimum Delay per Step, and I go ahead and put one in afterwards, something seems to break and the light will pop and flash randomly as it fades on. Not sure why and can’t seem to reliably replicate the issue.

So while on the topic of “Minimum Delay per step”, is there any way to try and go below 50ms? I’m curious to see how fast or smooth it can receive instructions under 50ms. I actually notice that the fading on or off is smoother at 50ms than at a higher value (which I’m sure is expected). Going above 200ms for me ends up being pretty choppy and the fade is pretty jarring. While I’m sure going under 50ms might result in some missed instructions and random jumping, I think if the fade time is big enough, the affect might not be as bad.

Secondly, thank you very much for the breakdown and detailed explanation of what is going on. However, I didn’t have a chance to follow your calculation guide :joy:and in the small amount of window I had to play with this, I just decided to try and run things again. Here is my latest result based on these settings. It is so far the most pleasant transition for me, but please let me know if there’s ways to improve it.

2024-02-06 13:30:56.477 WARNING (MainThread) [homeassistant.components.system_log.external] easeInSine easing type with 50 ms delay. remainingTimeInMilliseconds = 9876, and absoluteBrightnessSpan = 127
2024-02-06 13:30:56.477 WARNING (MainThread) [homeassistant.components.system_log.external] startBrightness = 0, endBrightness = 127, and processingDelayInMilliseconds = 123
2024-02-06 13:30:57.088 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 1 brightness. (Linear brightness would have been 8.) Delay is 50 ms. Elapsed time is 0.74 seconds. (endBrightness is 127.)
2024-02-06 13:30:57.265 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 1 brightness. (Linear brightness would have been 10.) Delay is 50 ms. Elapsed time is 0.91 seconds. (endBrightness is 127.)
2024-02-06 13:30:57.440 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 1 brightness. (Linear brightness would have been 12.) Delay is 50 ms. Elapsed time is 1.09 seconds. (endBrightness is 127.)
2024-02-06 13:30:57.619 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 2 brightness. (Linear brightness would have been 14.) Delay is 50 ms. Elapsed time is 1.27 seconds. (endBrightness is 127.)
2024-02-06 13:30:57.949 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 3 brightness. (Linear brightness would have been 17.) Delay is 50 ms. Elapsed time is 1.6 seconds. (endBrightness is 127.)
2024-02-06 13:30:58.127 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 4 brightness. (Linear brightness would have been 21.) Delay is 50 ms. Elapsed time is 1.77 seconds. (endBrightness is 127.)
2024-02-06 13:30:58.304 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 5 brightness. (Linear brightness would have been 23.) Delay is 50 ms. Elapsed time is 1.95 seconds. (endBrightness is 127.)
2024-02-06 13:30:58.481 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 6 brightness. (Linear brightness would have been 25.) Delay is 50 ms. Elapsed time is 2.13 seconds. (endBrightness is 127.)
2024-02-06 13:30:58.656 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 7 brightness. (Linear brightness would have been 28.) Delay is 50 ms. Elapsed time is 2.3 seconds. (endBrightness is 127.)
2024-02-06 13:30:58.848 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 9 brightness. (Linear brightness would have been 30.) Delay is 50 ms. Elapsed time is 2.5 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.022 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 10 brightness. (Linear brightness would have been 32.) Delay is 50 ms. Elapsed time is 2.67 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.196 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 11 brightness. (Linear brightness would have been 35.) Delay is 50 ms. Elapsed time is 2.84 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.370 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 13 brightness. (Linear brightness would have been 37.) Delay is 50 ms. Elapsed time is 3.02 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.567 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 14 brightness. (Linear brightness would have been 39.) Delay is 50 ms. Elapsed time is 3.21 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.753 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 16 brightness. (Linear brightness would have been 42.) Delay is 50 ms. Elapsed time is 3.4 seconds. (endBrightness is 127.)
2024-02-06 13:30:59.939 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 18 brightness. (Linear brightness would have been 44.) Delay is 50 ms. Elapsed time is 3.59 seconds. (endBrightness is 127.)
2024-02-06 13:31:00.121 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 20 brightness. (Linear brightness would have been 46.) Delay is 50 ms. Elapsed time is 3.77 seconds. (endBrightness is 127.)
2024-02-06 13:31:00.294 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 22 brightness. (Linear brightness would have been 49.) Delay is 50 ms. Elapsed time is 3.94 seconds. (endBrightness is 127.)
2024-02-06 13:31:00.477 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 24 brightness. (Linear brightness would have been 51.) Delay is 50 ms. Elapsed time is 4.13 seconds. (endBrightness is 127.)
2024-02-06 13:31:00.652 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 26 brightness. (Linear brightness would have been 53.) Delay is 50 ms. Elapsed time is 4.3 seconds. (endBrightness is 127.)
2024-02-06 13:31:00.828 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 29 brightness. (Linear brightness would have been 55.) Delay is 50 ms. Elapsed time is 4.48 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.003 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 31 brightness. (Linear brightness would have been 58.) Delay is 50 ms. Elapsed time is 4.65 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.189 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 33 brightness. (Linear brightness would have been 60.) Delay is 50 ms. Elapsed time is 4.84 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.378 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 36 brightness. (Linear brightness would have been 62.) Delay is 50 ms. Elapsed time is 5.03 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.564 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 38 brightness. (Linear brightness would have been 65.) Delay is 50 ms. Elapsed time is 5.21 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.739 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 41 brightness. (Linear brightness would have been 67.) Delay is 50 ms. Elapsed time is 5.39 seconds. (endBrightness is 127.)
2024-02-06 13:31:01.916 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 44 brightness. (Linear brightness would have been 69.) Delay is 50 ms. Elapsed time is 5.56 seconds. (endBrightness is 127.)
2024-02-06 13:31:02.132 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 46 brightness. (Linear brightness would have been 71.) Delay is 50 ms. Elapsed time is 5.78 seconds. (endBrightness is 127.)
2024-02-06 13:31:02.313 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 50 brightness. (Linear brightness would have been 74.) Delay is 50 ms. Elapsed time is 5.96 seconds. (endBrightness is 127.)
2024-02-06 13:31:02.491 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 53 brightness. (Linear brightness would have been 76.) Delay is 50 ms. Elapsed time is 6.14 seconds. (endBrightness is 127.)
2024-02-06 13:31:02.672 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 55 brightness. (Linear brightness would have been 79.) Delay is 50 ms. Elapsed time is 6.32 seconds. (endBrightness is 127.)
2024-02-06 13:31:02.893 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 58 brightness. (Linear brightness would have been 81.) Delay is 50 ms. Elapsed time is 6.54 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.075 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 62 brightness. (Linear brightness would have been 84.) Delay is 50 ms. Elapsed time is 6.72 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.249 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 65 brightness. (Linear brightness would have been 86.) Delay is 50 ms. Elapsed time is 6.9 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.433 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 68 brightness. (Linear brightness would have been 88.) Delay is 50 ms. Elapsed time is 7.08 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.625 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 72 brightness. (Linear brightness would have been 91.) Delay is 50 ms. Elapsed time is 7.27 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.797 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 75 brightness. (Linear brightness would have been 93.) Delay is 50 ms. Elapsed time is 7.44 seconds. (endBrightness is 127.)
2024-02-06 13:31:03.976 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 78 brightness. (Linear brightness would have been 95.) Delay is 50 ms. Elapsed time is 7.62 seconds. (endBrightness is 127.)
2024-02-06 13:31:04.160 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 82 brightness. (Linear brightness would have been 97.) Delay is 50 ms. Elapsed time is 7.81 seconds. (endBrightness is 127.)
2024-02-06 13:31:04.391 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 85 brightness. (Linear brightness would have been 100.) Delay is 50 ms. Elapsed time is 8.04 seconds. (endBrightness is 127.)
2024-02-06 13:31:04.572 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 89 brightness. (Linear brightness would have been 103.) Delay is 50 ms. Elapsed time is 8.22 seconds. (endBrightness is 127.)
2024-02-06 13:31:04.749 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 93 brightness. (Linear brightness would have been 105.) Delay is 50 ms. Elapsed time is 8.4 seconds. (endBrightness is 127.)
2024-02-06 13:31:05.010 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 96 brightness. (Linear brightness would have been 107.) Delay is 50 ms. Elapsed time is 8.66 seconds. (endBrightness is 127.)
2024-02-06 13:31:05.209 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 101 brightness. (Linear brightness would have been 111.) Delay is 50 ms. Elapsed time is 8.86 seconds. (endBrightness is 127.)
2024-02-06 13:31:05.704 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 105 brightness. (Linear brightness would have been 113.) Delay is 50 ms. Elapsed time is 9.35 seconds. (endBrightness is 127.)
2024-02-06 13:31:05.879 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 115 brightness. (Linear brightness would have been 119.) Delay is 50 ms. Elapsed time is 9.53 seconds. (endBrightness is 127.)
2024-02-06 13:31:06.078 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 119 brightness. (Linear brightness would have been 122.) Delay is 50 ms. Elapsed time is 9.73 seconds. (endBrightness is 127.)
2024-02-06 13:31:06.263 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 123 brightness. (Linear brightness would have been 124.) Delay is 50 ms. Elapsed time is 9.91 seconds. (endBrightness is 127.)
2024-02-06 13:31:06.459 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 126 brightness. (Linear brightness would have been 127.) Delay is 50 ms. Elapsed time is 10.11 seconds. (endBrightness is 127.)
2024-02-06 13:31:06.635 WARNING (MainThread) [homeassistant.components.system_log.external] Set Sean’s office Light to 127 brightness. Elapsed time is 10.28 seconds.

@aquariuz23 That sounds like a good sign so far! And in light of that, I’m wondering whether your ZigBee or Z-Wave network in that other part of the house might be a little bit weak?

I don’t have any Z-Wave devices, so I’m not quite sure how to check on a Z-Wave device’s signal strength, but if the dimmer switch were to be connected through ZHA, you can check on its signal strength through Settings → Devices & Services → Devices → [any ZigBee device] → “…” → View network.

Without a way to reproduce this, I’m not quite sure what’s happening here.

Before I get to answering that part, I’d like to just paste in a snippet from your logs that I’ll be referring to in a moment—

(I’ve applied some light formatting above just to make the log a bit easier to read.)

If you’ll excuse a brief tangent: Part of the way that the script works is that it first goes through a “test run” of sorts where it sends a single command to the lamp before the script goes through the whole fade sequence. And part of what the script does during this test run is that it times how long it takes between when the script sends that command to the lamp and when the lamp has processed that request.

Anyhow, getting back to the logs, the portion of your log that I had wanted to call out was the processingDelayInMilliseconds = 125 ms. That processingDelayInMilliseconds number represents the time that it took for your lamp to process that initial single command during the script’s test run.

While there’s no means for me to test every lamp’s response time, of the lamps that I’ve interacted with so far, I haven’t personally come across any that fall below 100 ms (and your lamp appears to be no different). So all in all, I don’t have plans to add support for lower minimum-delay times since I don’t think that would play well with the types of lamps that exist in the real world.

Let’s suppose—hypothetically—that you were an Olympic runner and that one day your knee started hurting during your 100-meter sprints. And let’s suppose that you then went to see a physical therapist, and after she examined your knee, she suggested certain exercises to help rehabilitate your knee.

From there, how do you think your physical therapist might feel if you then went to see her again a week later and you said, “I didn’t have a chance to follow your exercises :joy: and in the window that I had to work on my knee, I just decided to try and run sprints again”?

Look, man—I wrote this script for free, and I’m happy to help people out for free. But when you’re like, “I just decided to try and run things again, lol”, that’s not real helpful. Can you see where I’m coming from?

1 Like

When the lamp is on, the script works.

Here’s whats reported with the lamp on:

min_color_temp_kelvin: 2202
max_color_temp_kelvin: 4000
min_mireds: 250
max_mireds: 454
effect_list:
  - blink
  - breathe
  - okay
  - channel_change
  - finish_effect
  - stop_effect
supported_color_modes:
  - color_temp
  - xy
color_mode: color_temp
brightness: 204
color_temp_kelvin: 3205
color_temp: 312
hs_color:
  - 27.518
  - 51.595
rgb_color:
  - 255
  - 183
  - 123
xy_color:
  - 0.478
  - 0.379
effect: null
friendly_name: LED Streifen Schlafzimmer
supported_features: 44

Thanks for looking into it!

1 Like

@RaBoom Ah, right on—I’m glad to hear that!

And for whatever it’s worth, the script is supposed to be able to handle fades even if the light starts in its off state, so I may also try to see whether I can make that portion of the code a bit more resilient in an upcoming update.

First of all I want to thank you for this great script!
Maybe a stupid question but is this only to turn on a light?

I would also like to turn off lights with this kind of fades if possible.

1 Like

You can fade to zero brightness. In HA, setting a light to zero brightness is the same as turning it off.

1 Like

Thanks bunches for your kind words, @kvanluijtelaar!

It so happens that @parautenbach beat me to it, but yes—you can fade a lamp to 0 to turn it off.

1 Like

Hi Ashely,

I also tried to fade out as opposed to fade in, meaning fade back from e.g. 50percent to 0percent (in them morning) but setting it to final state 0 percent doesn’t work as it always tries to increase the percent.

Is this something planned as well?

Thanks a lot for your great work!

Julian

Hi, @julianrehm87! Could you perhaps elaborate on what you mean by “it always tries to increase the percent”?

Are you saying that when you enter “0” in the “End brightness level” field, the script changes that zero to a higher number?