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 ofstate
is used), and should be used in conjunction with theold
ornew
parameters, or both. When the callback is called, it is supplied with the values ofentity
,attr
,old
, andnew
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 useduration
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 Next time I suggest posting the question directly in the AppDaemon category.
1 Like