Using run_in() in HA?

Hi guys,

I’m fiddling around making a custom component while learning most of the stuff at the same time. I’ve seen that AppDaemon has a possibility to use run_in() as a feature to call a callback function after a certain time. It should be used instead of time.sleep() according to the documentation. My question is if it is possible to use run_in() or something similar (other than sleep) in regular components outside of AppDaemon?

I tried, and it’s not working, so I have a feeling the answer is no. But are there other alternatives to using time.sleep() or is this the way to go when you need a delay? My stuff is currently working with time.sleep() but I see in my logs there are some warnings which I believe comes from my sleeping.

Example: I want to make a component that ramps up the volume of a mediaplayer smoothly within a given time. Suggestions on what to use in such a case?

Thx.