Problem with variables and PWM transition length

Hi there.

I have build some lights with ESP-Home and PWM.
Up till now i have defined the default_transition_length as a fixed value in my source.
It’s all running properly.
Now, i would like to change these fading-time every time i change the PWM value.

For example:
In the night the fading should be 7seconds.
On the day time, when i opened the front door, the lights should be on within 1 second.

So i have create a global variable like:

globals:
  - id: fade_time
    type: std::string
    restore_value: no
    initial_value: "0.5s"

On the “light” section i have used (for example) these:

- platform: monochromatic
    output: pwm_output8
    name: "Licht Nebenraum"
    default_transition_length: 'return id(fade_time);'

None of the syntax i’ve used accepts the compiler :frowning:
Here i get a return like that:

Expected time period with unit, got return id(fade_time);.
  default_transition_length: return id(fade_time);

I have tested a number of syntax options, but none of these are accepted.
So i hope, that anybody of you can help me here…

Greetings!

I suspect you’re going to have to use that transition length variable in a light.turn_on action rather than in the default value.

Hi!

Hmm, yes thats true.
But its not working as espected:

{
    "brightness_pct": 50,
    
    //working:
    "transition":5

    //-> not working:
    //"transition_length": 5s
    //"transition_length": "5s"
    //"transition_length": 5000
}

But why?

Note: My used “brightness_pct” are not in that linked list, too. Strange

push

Does anyone have any idea why the commands are not as described in the manual?