|
Home IO Control
ESPHome add-on for IO-Homecontrol devices
|
Serialized pending-operation queue with coalescing, deduplication, and two-band ordering. More...
#include <operation_queue.h>
Public Member Functions | |
| bool | enqueue_set_position (const std::string &device_id, uint8_t position) |
| Enqueue SET_POSITION, or coalesce with a pending SET_TILT into SET_POSITION_AND_TILT. | |
| bool | enqueue_set_tilt (const std::string &device_id, uint8_t tilt_percent) |
| Enqueue SET_TILT, or coalesce with a pending SET_POSITION into SET_POSITION_AND_TILT. | |
| void | enqueue_set_position_and_tilt (const std::string &device_id, uint8_t position, uint8_t tilt_percent) |
| Enqueue SET_POSITION_AND_TILT directly (no coalescing needed). | |
| void | enqueue_device_command (const std::string &device_id, CoverCommand cmd) |
| void | enqueue_set_light_position (const std::string &device_id, uint8_t position) |
| Enqueue SET_LIGHT_STATE with an arbitrary IO position (0-100), for dimmable lights. | |
| void | enqueue_set_light_state (const std::string &device_id, bool on) |
| void | enqueue_set_lock_state (const std::string &device_id, bool locked) |
| void | enqueue_set_switch_state (const std::string &device_id, bool on) |
| void | enqueue_oneway_command (const std::string &controller_id, CoverCommand cmd) |
| Enqueue a 1W named command for a controller identity. | |
| void | enqueue_oneway_position (const std::string &controller_id, uint8_t position) |
| Enqueue a 1W numeric position for a controller identity. | |
| void | enqueue_oneway_enroll (const std::string &controller_id) |
| Enqueue a 1W enrollment (add-controller) for a controller identity. | |
| void | enqueue_oneway_unenroll (const std::string &controller_id) |
| Enqueue a 1W un-enrollment (remove-controller) for a controller identity. | |
| bool | enqueue_request_status (const std::string &device_id) |
| Enqueue REQUEST_STATUS, suppressing duplicates. | |
| bool | enqueue_request_name (const std::string &device_id) |
| Enqueue REQUEST_NAME, suppressing duplicates. | |
| bool | enqueue_discover_and_pair () |
| Enqueue DISCOVER_AND_PAIR with elevated priority. | |
| std::optional< PendingOperation > | pop () |
| bool | empty () const |
| std::size_t | size () const |
| const PendingOperation & | front () const |
| const PendingOperation & | back () const |
| const PendingOperation & | operator[] (std::size_t index) const |
| std::deque< PendingOperation >::const_iterator | begin () const |
| std::deque< PendingOperation >::const_iterator | end () const |
Static Public Member Functions | |
| static bool | is_background_op (PendingOperationType t) |
| True for background poll types (REQUEST_STATUS, REQUEST_NAME) that yield to control operations. | |
Serialized pending-operation queue with coalescing, deduplication, and two-band ordering.
Ordering: DISCOVER_AND_PAIR > control operations > background polls. Control operations (SET_*, DEVICE_COMMAND) are inserted before any queued REQUEST_STATUS / REQUEST_NAME entries so user-visible commands execute with minimum queue latency. DISCOVER_AND_PAIR always front-inserts ahead of all other entries.
Stale-poll drop: enqueueing a control operation for device X drops any queued REQUEST_STATUS for X, since the command reply supersedes it and re-arms tracking.
Coalescing rules (both directions):
Deduplication rules:
All coalescing and deduplication log messages are suppressed here — callers are responsible for emitting them because OperationQueue must remain free of ESPHome logging dependencies.
Definition at line 80 of file operation_queue.h.
|
nodiscard |
Definition at line 164 of file operation_queue.cpp.
|
nodiscard |
Definition at line 168 of file operation_queue.cpp.
|
nodiscard |
Definition at line 158 of file operation_queue.cpp.
|
nodiscard |
Definition at line 170 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_device_command | ( | const std::string & | device_id, |
| CoverCommand | cmd ) |
Definition at line 71 of file operation_queue.cpp.
| bool esphome::home_io_control::OperationQueue::enqueue_discover_and_pair | ( | ) |
Enqueue DISCOVER_AND_PAIR with elevated priority.
Flushes pending REQUEST_STATUS / REQUEST_NAME entries and pushes to front.
Definition at line 135 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_oneway_command | ( | const std::string & | controller_id, |
| CoverCommand | cmd ) |
Enqueue a 1W named command for a controller identity.
Deliberately neither coalesced nor deduplicated, unlike their 2W counterparts. A 2W command can be superseded because the device reports back what it did; a 1W command cannot be confirmed at all, so dropping one is dropping a press the user made with nothing to notice it. Each press also consumes its own sequence, and merging two would leave a gap that looks like a lost frame to a device tracking the counter.
| controller_id | Controller-identity handle (see PendingOperation::device_id). |
| cmd | Named command to send. |
Definition at line 79 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_oneway_enroll | ( | const std::string & | controller_id | ) |
Enqueue a 1W enrollment (add-controller) for a controller identity.
Same no-coalesce, no-dedup contract as the other 1W ops, for the same reason.
| controller_id | Controller-identity handle (see PendingOperation::device_id). |
Definition at line 91 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_oneway_position | ( | const std::string & | controller_id, |
| uint8_t | position ) |
Enqueue a 1W numeric position for a controller identity.
| controller_id | Controller-identity handle (see PendingOperation::device_id). |
| position | Target position 0–100. |
Definition at line 87 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_oneway_unenroll | ( | const std::string & | controller_id | ) |
Enqueue a 1W un-enrollment (remove-controller) for a controller identity.
| controller_id | Controller-identity handle (see PendingOperation::device_id). |
Definition at line 95 of file operation_queue.cpp.
| bool esphome::home_io_control::OperationQueue::enqueue_request_name | ( | const std::string & | device_id | ) |
Enqueue REQUEST_NAME, suppressing duplicates.
Definition at line 126 of file operation_queue.cpp.
| bool esphome::home_io_control::OperationQueue::enqueue_request_status | ( | const std::string & | device_id | ) |
Enqueue REQUEST_STATUS, suppressing duplicates.
Definition at line 117 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_set_light_position | ( | const std::string & | device_id, |
| uint8_t | position ) |
Enqueue SET_LIGHT_STATE with an arbitrary IO position (0-100), for dimmable lights.
enqueue_set_light_state() is a thin binary-position wrapper around this.
Definition at line 99 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_set_light_state | ( | const std::string & | device_id, |
| bool | on ) |
| void esphome::home_io_control::OperationQueue::enqueue_set_lock_state | ( | const std::string & | device_id, |
| bool | locked ) |
Definition at line 107 of file operation_queue.cpp.
| bool esphome::home_io_control::OperationQueue::enqueue_set_position | ( | const std::string & | device_id, |
| uint8_t | position ) |
Enqueue SET_POSITION, or coalesce with a pending SET_TILT into SET_POSITION_AND_TILT.
Definition at line 38 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_set_position_and_tilt | ( | const std::string & | device_id, |
| uint8_t | position, | ||
| uint8_t | tilt_percent ) |
Enqueue SET_POSITION_AND_TILT directly (no coalescing needed).
Definition at line 66 of file operation_queue.cpp.
| void esphome::home_io_control::OperationQueue::enqueue_set_switch_state | ( | const std::string & | device_id, |
| bool | on ) |
Definition at line 112 of file operation_queue.cpp.
| bool esphome::home_io_control::OperationQueue::enqueue_set_tilt | ( | const std::string & | device_id, |
| uint8_t | tilt_percent ) |
Enqueue SET_TILT, or coalesce with a pending SET_POSITION into SET_POSITION_AND_TILT.
Definition at line 53 of file operation_queue.cpp.
|
nodiscard |
Definition at line 162 of file operation_queue.cpp.
|
staticnodiscard |
True for background poll types (REQUEST_STATUS, REQUEST_NAME) that yield to control operations.
Public because the dispatch gate in loop() defers only background work when a 1W remote is transmitting; a user command must never be held back for it.
Definition at line 12 of file operation_queue.cpp.
|
nodiscard |
Definition at line 166 of file operation_queue.cpp.
|
nodiscard |
Definition at line 150 of file operation_queue.cpp.
|
nodiscard |
Definition at line 160 of file operation_queue.cpp.