Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.debounce.Debouncer Class Reference
Inheritance diagram for homeassistant.helpers.debounce.Debouncer:
[legend]
Collaboration diagram for homeassistant.helpers.debounce.Debouncer:
[legend]

Public Member Functions

None __init__ (self, HomeAssistant hass, Logger logger, *float cooldown, bool immediate, Callable[[], _R_co]|None function=None, bool background=False)
 
None async_call (self)
 
None async_cancel (self)
 
None async_schedule_call (self)
 
None async_shutdown (self)
 
Callable[[], _R_co]|None function (self)
 
None function (self, Callable[[], _R_co] function)
 

Public Attributes

 cooldown
 
 hass
 
 immediate
 
 logger
 

Private Member Functions

bool _async_schedule_or_call_now (self)
 
None _handle_timer_finish (self)
 
None _on_debounce (self)
 
None _schedule_timer (self)
 

Private Attributes

 _background
 
 _execute_at_end_of_timer
 
 _execute_lock
 
 _function
 
 _job
 
 _shutdown_requested
 
 _timer_task
 

Detailed Description

Class to rate limit calls to a specific command.

Definition at line 12 of file debounce.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.debounce.Debouncer.__init__ (   self,
HomeAssistant  hass,
Logger  logger,
*float  cooldown,
bool  immediate,
Callable[[], _R_co] | None   function = None,
bool   background = False 
)
Initialize debounce.

immediate: indicate if the function needs to be called right away and
           wait <cooldown> until executing next invocation.
function: optional and can be instantiated later.

Definition at line 15 of file debounce.py.

Member Function Documentation

◆ _async_schedule_or_call_now()

bool homeassistant.helpers.debounce.Debouncer._async_schedule_or_call_now (   self)
private
Check if a call should be scheduled.

Returns True if the function should be called immediately.

Returns False if there is nothing to do.

Definition at line 71 of file debounce.py.

◆ _handle_timer_finish()

None homeassistant.helpers.debounce.Debouncer._handle_timer_finish (   self)
private
Handle a finished timer.

Definition at line 118 of file debounce.py.

◆ _on_debounce()

None homeassistant.helpers.debounce.Debouncer._on_debounce (   self)
private
Create job task, but only if pending.

Definition at line 160 of file debounce.py.

◆ _schedule_timer()

None homeassistant.helpers.debounce.Debouncer._schedule_timer (   self)
private
Schedule a timer.

Definition at line 177 of file debounce.py.

◆ async_call()

None homeassistant.helpers.debounce.Debouncer.async_call (   self)
Call the function.

Reimplemented in homeassistant.components.rabbitair.coordinator.RabbitAirDebouncer.

Definition at line 99 of file debounce.py.

◆ async_cancel()

None homeassistant.helpers.debounce.Debouncer.async_cancel (   self)
Cancel any scheduled call.

Definition at line 151 of file debounce.py.

◆ async_schedule_call()

None homeassistant.helpers.debounce.Debouncer.async_schedule_call (   self)
Schedule a call to the function.

Definition at line 65 of file debounce.py.

◆ async_shutdown()

None homeassistant.helpers.debounce.Debouncer.async_shutdown (   self)
Cancel any scheduled call, and prevent new runs.

Definition at line 145 of file debounce.py.

◆ function() [1/2]

Callable[[], _R_co] | None homeassistant.helpers.debounce.Debouncer.function (   self)
Return the function being wrapped by the Debouncer.

Definition at line 50 of file debounce.py.

◆ function() [2/2]

None homeassistant.helpers.debounce.Debouncer.function (   self,
Callable[[], _R_co]  function 
)
Update the function being wrapped by the Debouncer.

Definition at line 55 of file debounce.py.

Member Data Documentation

◆ _background

homeassistant.helpers.debounce.Debouncer._background
private

Definition at line 39 of file debounce.py.

◆ _execute_at_end_of_timer

homeassistant.helpers.debounce.Debouncer._execute_at_end_of_timer
private

Definition at line 68 of file debounce.py.

◆ _execute_lock

homeassistant.helpers.debounce.Debouncer._execute_lock
private

Definition at line 38 of file debounce.py.

◆ _function

homeassistant.helpers.debounce.Debouncer._function
private

Definition at line 33 of file debounce.py.

◆ _job

homeassistant.helpers.debounce.Debouncer._job
private

Definition at line 59 of file debounce.py.

◆ _shutdown_requested

homeassistant.helpers.debounce.Debouncer._shutdown_requested
private

Definition at line 47 of file debounce.py.

◆ _timer_task

homeassistant.helpers.debounce.Debouncer._timer_task
private

Definition at line 155 of file debounce.py.

◆ cooldown

homeassistant.helpers.debounce.Debouncer.cooldown

Definition at line 34 of file debounce.py.

◆ hass

homeassistant.helpers.debounce.Debouncer.hass

Definition at line 31 of file debounce.py.

◆ immediate

homeassistant.helpers.debounce.Debouncer.immediate

Definition at line 35 of file debounce.py.

◆ logger

homeassistant.helpers.debounce.Debouncer.logger

Definition at line 32 of file debounce.py.


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