Home Assistant Unofficial Reference 2024.12.1
homeassistant.util.Throttle Class Reference

Public Member Functions

Callable __call__ (self, Callable method)
 
None __init__ (self, timedelta min_time, timedelta|None limit_no_throttle=None)
 

Public Attributes

 limit_no_throttle
 
 min_time
 

Detailed Description

A class for throttling the execution of tasks.

This method decorator adds a cooldown to a method to prevent it from being
called more than 1 time within the timedelta interval `min_time` after it
returned its result.

Calling a method a second time during the interval will return None.

Pass keyword argument `no_throttle=True` to the wrapped method to make
the call not throttled.

Decorator takes in an optional second timedelta interval to throttle the
'no_throttle' calls.

Adds a datetime attribute `last_call` to the method.

Definition at line 100 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.util.Throttle.__init__ (   self,
timedelta  min_time,
timedelta | None   limit_no_throttle = None 
)
Initialize the throttle.

Definition at line 118 of file __init__.py.

Member Function Documentation

◆ __call__()

Callable homeassistant.util.Throttle.__call__ (   self,
Callable  method 
)
Caller for the throttle.

Definition at line 125 of file __init__.py.

Member Data Documentation

◆ limit_no_throttle

homeassistant.util.Throttle.limit_no_throttle

Definition at line 123 of file __init__.py.

◆ min_time

homeassistant.util.Throttle.min_time

Definition at line 122 of file __init__.py.


The documentation for this class was generated from the following file: