ESPHome Fan - On/off state vs speed

I would like to know if it is possible to hook into the on/off behaviour of the fan component?

I currently have a fan with a custom output. This works fine but I do get some behaviour when working with on/off that I would like to modify.

The problem for me is when I change the speed to 0%, the fan turns off but it resets the speed to the previous value. I can see the advantage of that, but I prefer the speed to be 0% when it is off. Then when I turn the fan on I want it to go to level 1 (50%) or when I change the speed to another level that turns on the fan and keep at that level.

Has anybody had the same ‘problem’? And (how) did you fix it?