Efficient way to have AppDaemon wait 10 minutes before executing a callback?

in native yaml, i can use the for: keyword to have any automation only trigger when the state of something has been constant for 10 minutes. how do i do this efficiently in appdaemon? i can of course think of ways to track state and invoke sleep calls to do it, but this would cause me to have many idling threads etc. is there a proper way to do this?

nevermind, found it!

  • duration ( int , optional ) –If duration is supplied as a parameter, the callback will not fire unless the state listened for is maintained for that number of seconds. This requires that a specific attribute is specified (or the default of state is used), and should be used in conjunction with the old or new parameters, or both. When the callback is called, it is supplied with the values of entity , attr , old , and new that were current at the time the actual event occurred, since the assumption is that none of them have changed in the intervening period.If you use duration when listening for an entire device type rather than a specific entity, or for all state changes, you may get unpredictable results, so it is recommended that this parameter is only used in conjunction with the state of specific entities.
1 Like

Glad you found it yourself :slight_smile: Next time I suggest posting the question directly in the AppDaemon category.

1 Like

heh, searching “appdaemon forum” currently leads to: AppDaemon Forum

It’s under Third Party integrations:

https://community.home-assistant.io/c/third-party/appdaemon