22 const bool addresses_a_device =
25 if (addresses_a_device) {
26 queue_.erase(std::remove_if(queue_.begin(), queue_.end(),
28 return existing.type == PendingOperationType::REQUEST_STATUS &&
29 existing.device_id == op.device_id;
34 std::find_if(queue_.begin(), queue_.end(), [](
const PendingOperation &o) { return is_background_op(o.type); });
35 queue_.insert(it, std::move(op));
39 for (
auto &op : queue_) {
42 uint8_t
const pending_tilt = op.
position;
45 op.
tilt = pending_tilt;
54 for (
auto &op : queue_) {
57 op.
tilt = tilt_percent;
67 uint8_t tilt_percent) {
76 push_control_(std::move(op));
84 push_control_(std::move(op));
118 for (
const auto &op : queue_) {
127 for (
const auto &op : queue_) {
136 for (
const auto &op : queue_) {
140 queue_.erase(std::remove_if(queue_.begin(), queue_.end(),
142 return op.type == PendingOperationType::REQUEST_STATUS ||
143 op.type == PendingOperationType::REQUEST_NAME;
std::deque< PendingOperation >::const_iterator begin() const
const PendingOperation & front() const
void enqueue_oneway_unenroll(const std::string &controller_id)
Enqueue a 1W un-enrollment (remove-controller) for a controller identity.
void enqueue_set_lock_state(const std::string &device_id, bool locked)
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_oneway_command(const std::string &controller_id, CoverCommand cmd)
Enqueue a 1W named command for a controller identity.
std::optional< PendingOperation > pop()
void enqueue_device_command(const std::string &device_id, CoverCommand cmd)
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.
void enqueue_set_switch_state(const std::string &device_id, bool on)
void enqueue_oneway_position(const std::string &controller_id, uint8_t position)
Enqueue a 1W numeric position for a controller identity.
bool enqueue_discover_and_pair()
Enqueue DISCOVER_AND_PAIR with elevated priority.
static bool is_background_op(PendingOperationType t)
True for background poll types (REQUEST_STATUS, REQUEST_NAME) that yield to control operations.
std::deque< PendingOperation >::const_iterator end() const
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.
const PendingOperation & back() const
void enqueue_oneway_enroll(const std::string &controller_id)
Enqueue a 1W enrollment (add-controller) for a controller identity.
void enqueue_set_light_state(const std::string &device_id, bool on)
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.
const PendingOperation & operator[](std::size_t index) const
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.
PendingOperationType
Discriminator for entries in the pending-operation deque.
@ SET_LOCK_STATE
set_lock_state call (locked/unlocked).
@ SET_TILT
set_device_tilt call (tilt percentage 0–100).
@ SET_POSITION_AND_TILT
Combined set_device_position_and_tilt call.
@ SET_LIGHT_STATE
set_light_state call (binary on/off).
@ SET_SWITCH_STATE
set_switch_state call (binary on/off).
@ REQUEST_NAME
request_device_name call (poll for stored device name).
@ ONEWAY_COMMAND
1W named command sent as a controller identity.
@ DISCOVER_AND_PAIR
discover_and_pair call (starts 3-phase pairing flow).
@ REQUEST_STATUS
request_device_status call (poll for current position).
@ ONEWAY_UNENROLL
1W remove-controller (0x39) un-registering an identity.
@ DEVICE_COMMAND
Named device command (STOP, FAVORITE, VENT).
@ SET_POSITION
set_device_position call (position 0–100 or special values).
@ ONEWAY_ENROLL
1W add-controller (0x30) registering an identity.
@ ONEWAY_POSITION
1W numeric position sent as a controller identity.
CoverCommand
Named device commands for cover-type actuators.
static constexpr uint8_t BINARY_ENTITY_ON_POSITION
Position value written for binary ON commands (light on, switch on, lock unlock).
static constexpr uint8_t BINARY_ENTITY_OFF_POSITION
Position value written for binary OFF commands (light off, switch off, lock lock).
Pending-operation queue with per-type coalescing and deduplication.
A single queued operation to be dispatched from loop().
CoverCommand command
Named command for DEVICE_COMMAND operations.
std::string device_id
Target device ID (hex string, e.g., "123ABC") — except for the ONEWAY_* types, where it carries the c...
uint8_t tilt
Tilt value for SET_POSITION_AND_TILT (0–100).
uint8_t position
Position/tilt value (0–100) or binary state (ON=0, OFF=100).
PendingOperationType type
Operation type (determines which handler to invoke).