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

What the hub predicted ahead of confirmation, kept apart from what the device reported. More...

#include <proto_device_model.h>

Collaboration diagram for esphome::home_io_control::OptimisticState:

Public Types

enum class  Motion : uint8_t { NONE = 0 , MOVING , STOPPED }
 Predicted movement. More...

Public Member Functions

bool empty () const
void clear ()
 Withdraw every prediction.
void clear_position ()
 Withdraw the position prediction; call when a decoded position observation supersedes it.
void forget_replaced_movement ()
 Drop the movement a STOP replaced, once nothing can roll the STOP back any more.
void clear_tilt ()
 Withdraw the tilt prediction; call when a decoded tilt observation supersedes it.

Public Attributes

float target {UNKNOWN_POSITION}
 Predicted main-position target, or UNKNOWN_POSITION.
float tilt {UNKNOWN_POSITION}
 Predicted slat angle, or UNKNOWN_POSITION.
Motion motion {Motion::NONE}
 Predicted movement state.
bool stop_replaced_movement {false}
 True while a pending STOP replaced a Motion::MOVING prediction that a failed STOP should bring back (DeviceRegistry::rollback_optimistic()).
float stop_replaced_target {UNKNOWN_POSITION}
 The replaced target; meaningful only with the flag.

Detailed Description

What the hub predicted ahead of confirmation, kept apart from what the device reported.

The observed fields on IoDevice (position, target, tilt, is_stopped) mean "this is what the device last told us" and are never written by a guess. Anything the hub predicts — to give the Home Assistant UI immediate feedback across the queue-dispatch and exchange gap — lands here instead, so it can be withdrawn when the command that produced it fails (DeviceRegistry::rollback_optimistic()) without risking a real observation.

Consumers read through effective_target() / effective_tilt() / effective_is_stopped() rather than either set of fields directly.

Definition at line 278 of file proto_device_model.h.

Member Enumeration Documentation

◆ Motion

Predicted movement.

NONE defers to the observed is_stopped; a bool could not express "predict stopped" (apply_optimistic_stop) distinctly from "no prediction".

Enumerator
NONE 

No movement prediction; the observed is_stopped decides.

MOVING 

Predicted to be travelling (a position command was issued).

STOPPED 

Predicted to be at rest (a STOP was issued).

Definition at line 281 of file proto_device_model.h.

Member Function Documentation

◆ clear()

void esphome::home_io_control::OptimisticState::clear ( )
inline

Withdraw every prediction.

Definition at line 302 of file proto_device_model.h.

◆ clear_position()

void esphome::home_io_control::OptimisticState::clear_position ( )
inline

Withdraw the position prediction; call when a decoded position observation supersedes it.

Clears motion with target because apply_optimistic_target() sets the two together, and the replaced movement with them: an observation outranks every guess about travel.

Definition at line 306 of file proto_device_model.h.

Here is the call graph for this function:

◆ clear_tilt()

void esphome::home_io_control::OptimisticState::clear_tilt ( )
inline

Withdraw the tilt prediction; call when a decoded tilt observation supersedes it.

Definition at line 317 of file proto_device_model.h.

◆ empty()

bool esphome::home_io_control::OptimisticState::empty ( ) const
inlinenodiscard
Returns
true when nothing is predicted, so a rollback would be a no-op.

Definition at line 298 of file proto_device_model.h.

◆ forget_replaced_movement()

void esphome::home_io_control::OptimisticState::forget_replaced_movement ( )
inline

Drop the movement a STOP replaced, once nothing can roll the STOP back any more.

Definition at line 312 of file proto_device_model.h.

Member Data Documentation

◆ motion

Motion esphome::home_io_control::OptimisticState::motion {Motion::NONE}

Predicted movement state.

Definition at line 289 of file proto_device_model.h.

◆ stop_replaced_movement

bool esphome::home_io_control::OptimisticState::stop_replaced_movement {false}

True while a pending STOP replaced a Motion::MOVING prediction that a failed STOP should bring back (DeviceRegistry::rollback_optimistic()).

A failed STOP means the device keeps travelling, and a device that reports nothing mid-travel has no observation to fall back on that still carries the direction. Only set alongside Motion::STOPPED.

Definition at line 294 of file proto_device_model.h.

◆ stop_replaced_target

float esphome::home_io_control::OptimisticState::stop_replaced_target {UNKNOWN_POSITION}

The replaced target; meaningful only with the flag.

Definition at line 295 of file proto_device_model.h.

◆ target

float esphome::home_io_control::OptimisticState::target {UNKNOWN_POSITION}

Predicted main-position target, or UNKNOWN_POSITION.

Definition at line 287 of file proto_device_model.h.

◆ tilt

float esphome::home_io_control::OptimisticState::tilt {UNKNOWN_POSITION}

Predicted slat angle, or UNKNOWN_POSITION.

Definition at line 288 of file proto_device_model.h.


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