Light.toggle preempting

Hi. Is there a way to preempt the state that the light.toggle will toggle to?
I want to set the transition time based on the intensity that the light will turn on to.
If the light will turn on to 1%, there is no need for transition, but if it will toggle to 100%, then a 1s transition should be applied.
How can I get the intensity the light will be once its on before it gets toggled?
Thanks in advance

That would depend on what you’re toggling. HA won’t know how your target device works (does it switch to the last value? Does it switch to full? Was the dimmer adjusted outside of HA before?

Hi. Thanks for the reply.
The device is a light running esphome.light. And the only way to control it is over HA. It will always toggle to the last value.
I know I could store the value in a sensor and just use it when needed, but I was wondering if there is a better way.

This sounds like something you should program into the ESPHome, since it will know what value it will turn on with.