Calling AppDaemon.run_in faster than once per second

I’m actually trying to write a app that will do color transitions for light platforms that do not support the “transition” attribute for light.turn_on(). The problem is that the AppDaemon.run_in function does not support fractional time so the transitions look pretty stroboscopic :-).
As well the AppDaemon API documentation is strongly advising not to use time.sleep() or similar as that will block the worker thread.
So is there any other way how a AppDeamon app could do rapid changes over potentially long period of time without blocking the worker ?

1 Like

I would love to see this

At this point no, but it is something that may be interesting for the future.

Blocking 1 thread for a few seconds while you do a light effect should be fine though, as long as you don;t keep it busy forever.

actually it is currently pretty lame, but feel free to have a look:

https://github.com/pezinek/Home-AssistantConfig/blob/master/appdaemon/apps/smooth_light.py

OK, I’ll try to block a single thread during transitions then and will see how it will perform.
Chances are that a rapid changes like these will clog the homeassistant’s event queue and fast transitions will not be acceptably smooth anyway :slight_smile: (running it on the very first version of rabsperry pi model B :wink:

But thanks anyway !

Edit:
After going synchronous with time.sleep() my HW was able to do 1.6 color changes per second (instead of the original 1) :slight_smile: so if you are considering the possibility to make appdaemon.run_in able to handle fractions of seconds, then just FIY, I don’t need it anymore :wink:

2 Likes