Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
esphome::home_io_control::StatusPollPolicy Class Reference

Per-hub poll scheduling and failure-backoff policy. More...

#include <status_poll_policy.h>

Collaboration diagram for esphome::home_io_control::StatusPollPolicy:

Public Member Functions

void set_interval (const std::string &device_id, uint32_t interval_ms)
 Set the configured follow-up poll interval (ms; 0 = legacy one-shot settle only).
uint32_t get_interval (const std::string &device_id) const
 Return the configured interval (0 when not set or unconfigured).
void begin_tracking (const std::string &device_id, uint32_t initial_delay_ms, uint32_t now)
 Begin bounded follow-up polling after a command or remote activity.
void clear (const std::string &device_id)
 Stop all polling for a device and reset failure counts. Preserves interval_ms.
void set_next_update (const std::string &device_id, uint32_t abs_time)
 Schedule the next poll at an absolute millis() timestamp.
uint32_t get_next_update (const std::string &device_id) const
uint32_t on_exchange_failed (const std::string &device_id, bool auth_like, uint32_t now)
 Record a failed background poll; apply backoff or clear tracking if the window expired.
void clear_failure_streaks (const std::string &device_id)
 Reset failure streaks after a successful exchange response.
uint8_t get_status_poll_failures (const std::string &device_id) const
uint8_t get_auth_poll_failures (const std::string &device_id) const
uint32_t get_poll_deadline (const std::string &device_id) const
bool is_tracking_active (const std::string &device_id, uint32_t now) const
 True when the device has an active bounded polling window (deadline set and not expired).
std::optional< std::string > pop_due_device (uint32_t now)
 Return and consume the first device whose next_update is overdue.

Detailed Description

Per-hub poll scheduling and failure-backoff policy.

Maintains a PollTracking entry per device; all hub poll bookkeeping lives here and nowhere else. Callers inject 'now' timestamps so the class is fully testable without a hardware clock.

Definition at line 101 of file status_poll_policy.h.

Member Function Documentation

◆ begin_tracking()

void esphome::home_io_control::StatusPollPolicy::begin_tracking ( const std::string & device_id,
uint32_t initial_delay_ms,
uint32_t now )

Begin bounded follow-up polling after a command or remote activity.

Sets a deadline regardless of whether a configured interval exists; interval-0 devices use device-hinted or default settle delays computed at response time.

Definition at line 19 of file status_poll_policy.cpp.

◆ clear()

void esphome::home_io_control::StatusPollPolicy::clear ( const std::string & device_id)

Stop all polling for a device and reset failure counts. Preserves interval_ms.

Definition at line 27 of file status_poll_policy.cpp.

◆ clear_failure_streaks()

void esphome::home_io_control::StatusPollPolicy::clear_failure_streaks ( const std::string & device_id)

Reset failure streaks after a successful exchange response.

Definition at line 89 of file status_poll_policy.cpp.

◆ get_auth_poll_failures()

uint8_t esphome::home_io_control::StatusPollPolicy::get_auth_poll_failures ( const std::string & device_id) const
nodiscard

Definition at line 102 of file status_poll_policy.cpp.

◆ get_interval()

uint32_t esphome::home_io_control::StatusPollPolicy::get_interval ( const std::string & device_id) const
nodiscard

Return the configured interval (0 when not set or unconfigured).

Definition at line 14 of file status_poll_policy.cpp.

◆ get_next_update()

uint32_t esphome::home_io_control::StatusPollPolicy::get_next_update ( const std::string & device_id) const
nodiscard

Definition at line 43 of file status_poll_policy.cpp.

◆ get_poll_deadline()

uint32_t esphome::home_io_control::StatusPollPolicy::get_poll_deadline ( const std::string & device_id) const
nodiscard

Definition at line 48 of file status_poll_policy.cpp.

◆ get_status_poll_failures()

uint8_t esphome::home_io_control::StatusPollPolicy::get_status_poll_failures ( const std::string & device_id) const
nodiscard

Definition at line 97 of file status_poll_policy.cpp.

◆ is_tracking_active()

bool esphome::home_io_control::StatusPollPolicy::is_tracking_active ( const std::string & device_id,
uint32_t now ) const
nodiscard

True when the device has an active bounded polling window (deadline set and not expired).

Definition at line 53 of file status_poll_policy.cpp.

◆ on_exchange_failed()

uint32_t esphome::home_io_control::StatusPollPolicy::on_exchange_failed ( const std::string & device_id,
bool auth_like,
uint32_t now )

Record a failed background poll; apply backoff or clear tracking if the window expired.

Returns the backoff delay applied in ms, or 0 if tracking was cleared.

Definition at line 61 of file status_poll_policy.cpp.

Here is the call graph for this function:

◆ pop_due_device()

std::optional< std::string > esphome::home_io_control::StatusPollPolicy::pop_due_device ( uint32_t now)
nodiscard

Return and consume the first device whose next_update is overdue.

Clears expired tracking entries as a side effect. Returns nullopt if nothing is due.

Definition at line 107 of file status_poll_policy.cpp.

Here is the call graph for this function:

◆ set_interval()

void esphome::home_io_control::StatusPollPolicy::set_interval ( const std::string & device_id,
uint32_t interval_ms )

Set the configured follow-up poll interval (ms; 0 = legacy one-shot settle only).

Definition at line 10 of file status_poll_policy.cpp.

◆ set_next_update()

void esphome::home_io_control::StatusPollPolicy::set_next_update ( const std::string & device_id,
uint32_t abs_time )

Schedule the next poll at an absolute millis() timestamp.

Definition at line 39 of file status_poll_policy.cpp.


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