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

Per-device periodic limitation-read schedule and miss counter. More...

#include <rain_poll_policy.h>

Collaboration diagram for esphome::home_io_control::RainPollPolicy:

Public Member Functions

void set_interval (const std::string &device_id, uint32_t interval_ms, uint32_t now, uint32_t random)
 Set the poll interval and schedule the first poll at rain_poll_first_delay_ms(random) after now.
uint32_t get_interval (const std::string &device_id) const
 Return the configured interval (0 when the device is not scheduled).
bool has_due (uint32_t now) const
 True when any device's poll is due at now.
std::optional< std::string > pop_due_device (uint32_t now, uint32_t random)
 Return one device whose poll is due and immediately schedule its next poll at rain_poll_jittered_interval_ms() after now, so a poll that is later dropped from the operation queue (pairing flushes background work) is skipped rather than lost forever.
void defer (const std::string &device_id, uint32_t delay_ms, uint32_t now)
 Pull the device's next poll forward to delay_ms after now. Never pushes it later.
bool on_poll_failed (const std::string &device_id)
 Count one unanswered poll (saturating).
void on_poll_succeeded (const std::string &device_id)
 Clear the unanswered-poll count.
bool first_error_reply (const std::string &device_id)
 True the first time it is called for a device that answered the limitation read with an error reply, false afterwards, so the log names that once instead of every poll.
uint8_t get_failures (const std::string &device_id) const
 Consecutive unanswered polls (0 for an unscheduled device).
uint32_t get_next_poll (const std::string &device_id) const
 Absolute millis() time of the device's next poll (0 for an unscheduled device).

Detailed Description

Per-device periodic limitation-read schedule and miss counter.

Definition at line 61 of file rain_poll_policy.h.

Member Function Documentation

◆ defer()

void esphome::home_io_control::RainPollPolicy::defer ( const std::string & device_id,
uint32_t delay_ms,
uint32_t now )

Pull the device's next poll forward to delay_ms after now. Never pushes it later.

Definition at line 50 of file rain_poll_policy.cpp.

◆ first_error_reply()

bool esphome::home_io_control::RainPollPolicy::first_error_reply ( const std::string & device_id)
nodiscard

True the first time it is called for a device that answered the limitation read with an error reply, false afterwards, so the log names that once instead of every poll.

Definition at line 74 of file rain_poll_policy.cpp.

◆ get_failures()

uint8_t esphome::home_io_control::RainPollPolicy::get_failures ( const std::string & device_id) const
nodiscard

Consecutive unanswered polls (0 for an unscheduled device).

Definition at line 82 of file rain_poll_policy.cpp.

◆ get_interval()

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

Return the configured interval (0 when the device is not scheduled).

Definition at line 30 of file rain_poll_policy.cpp.

◆ get_next_poll()

uint32_t esphome::home_io_control::RainPollPolicy::get_next_poll ( const std::string & device_id) const
nodiscard

Absolute millis() time of the device's next poll (0 for an unscheduled device).

Definition at line 87 of file rain_poll_policy.cpp.

◆ has_due()

bool esphome::home_io_control::RainPollPolicy::has_due ( uint32_t now) const
nodiscard

True when any device's poll is due at now.

Lets the caller draw a random number only when pop_due_device() will use it.

Definition at line 35 of file rain_poll_policy.cpp.

◆ on_poll_failed()

bool esphome::home_io_control::RainPollPolicy::on_poll_failed ( const std::string & device_id)

Count one unanswered poll (saturating).

Returns
True once RAIN_POLL_FAILURES_BEFORE_UNKNOWN is reached, i.e. the last reading is no longer usable. Stays true until on_poll_succeeded().

Definition at line 59 of file rain_poll_policy.cpp.

◆ on_poll_succeeded()

void esphome::home_io_control::RainPollPolicy::on_poll_succeeded ( const std::string & device_id)

Clear the unanswered-poll count.

Definition at line 68 of file rain_poll_policy.cpp.

◆ pop_due_device()

std::optional< std::string > esphome::home_io_control::RainPollPolicy::pop_due_device ( uint32_t now,
uint32_t random )
nodiscard

Return one device whose poll is due and immediately schedule its next poll at rain_poll_jittered_interval_ms() after now, so a poll that is later dropped from the operation queue (pairing flushes background work) is skipped rather than lost forever.

Returns nullopt when nothing is due. Comparison is wrap-safe across the 32-bit millis() rollover.

Definition at line 40 of file rain_poll_policy.cpp.

Here is the call graph for this function:

◆ set_interval()

void esphome::home_io_control::RainPollPolicy::set_interval ( const std::string & device_id,
uint32_t interval_ms,
uint32_t now,
uint32_t random )

Set the poll interval and schedule the first poll at rain_poll_first_delay_ms(random) after now.

0 removes the device from the schedule.

Definition at line 19 of file rain_poll_policy.cpp.

Here is the call graph for this function:

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