esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
esphome::api::SyncClient Class Reference

Synchronous, single-threaded client. More...

#include <sync_client.hpp>

Public Member Functions

 SyncClient (const ClientOptions &options)
 
void connect () const
 Connect and complete the handshake, blocking until ready.
 
void disconnect () const
 Gracefully disconnect, blocking briefly for the close to settle.
 
bool is_connected () const
 
ConnectionState state () const
 
const ServerHelloserver_hello () const
 
DeviceInfo device_info () const
 Request the device's DeviceInfoResponse and return it as a typed struct.
 
void list_entities () const
 Request the full entity list and block until ListEntitiesDoneResponse.
 
void subscribe_states () const
 Subscribe to live state updates.
 
EntityRegistry entities ()
 Object-oriented view of the discovered entities: entities().switches(), entities().light("ceiling").turn_on(), etc.
 
EntityStorestore () noexcept
 The underlying entity store (raw typed info/state access).
 
const EntityStorestore () const noexcept
 
BluetoothProxybluetooth ()
 
LogStreamlogs ()
 
HomeAssistantServiceshome_assistant ()
 
VoiceAssistantvoice ()
 
ZWaveProxyzwave ()
 
SerialProxyserial ()
 
SerialPort serial_proxy (std::uint32_t instance)
 Instance-bound serial-proxy handle: sync.serial_proxy(0).write(...).
 
SerialPort serial_proxy (const std::string &name)
 Serial-proxy handle by advertised name.
 
void set_request_timeout (const std::chrono::milliseconds timeout)
 Default per-request deadline (does not apply to connect, which uses the connection's own handshake timeout).
 
void pump_until (const std::function< bool()> &predicate, std::chrono::milliseconds timeout) const
 Pump the loop until predicate is true or timeout elapses.
 
Clientasync ()
 Access the underlying async client (register handlers, send raw, etc.).
 

Detailed Description

Synchronous, single-threaded client.

Construct, connect(), issue blocking requests, then disconnect(). Not thread-safe.

Constructor & Destructor Documentation

◆ SyncClient()

esphome::api::SyncClient::SyncClient ( const ClientOptions options)
explicit

Member Function Documentation

◆ async()

Client & esphome::api::SyncClient::async ( )
inline

Access the underlying async client (register handlers, send raw, etc.).

◆ bluetooth()

BluetoothProxy & esphome::api::SyncClient::bluetooth ( )
inline

◆ connect()

void esphome::api::SyncClient::connect ( ) const

Connect and complete the handshake, blocking until ready.

Throws ConnectionError / TimeoutError on failure.

◆ device_info()

DeviceInfo esphome::api::SyncClient::device_info ( ) const

Request the device's DeviceInfoResponse and return it as a typed struct.

◆ disconnect()

void esphome::api::SyncClient::disconnect ( ) const

Gracefully disconnect, blocking briefly for the close to settle.

◆ entities()

EntityRegistry esphome::api::SyncClient::entities ( )
inline

Object-oriented view of the discovered entities: entities().switches(), entities().light("ceiling").turn_on(), etc.

◆ home_assistant()

HomeAssistantServices & esphome::api::SyncClient::home_assistant ( )
inline

◆ is_connected()

bool esphome::api::SyncClient::is_connected ( ) const
inline

◆ list_entities()

void esphome::api::SyncClient::list_entities ( ) const

Request the full entity list and block until ListEntitiesDoneResponse.

The entities are available afterwards via entities().

◆ logs()

LogStream & esphome::api::SyncClient::logs ( )
inline

◆ pump_until()

void esphome::api::SyncClient::pump_until ( const std::function< bool()> &  predicate,
std::chrono::milliseconds  timeout 
) const

Pump the loop until predicate is true or timeout elapses.

Exposed for building custom blocking request/response flows on top of async().

◆ serial()

SerialProxy & esphome::api::SyncClient::serial ( )
inline

◆ serial_proxy() [1/2]

SerialPort esphome::api::SyncClient::serial_proxy ( const std::string &  name)

Serial-proxy handle by advertised name.

Fetches device info on first use to resolve the name; throws ApiError if the name is unknown.

◆ serial_proxy() [2/2]

SerialPort esphome::api::SyncClient::serial_proxy ( std::uint32_t  instance)

Instance-bound serial-proxy handle: sync.serial_proxy(0).write(...).

◆ server_hello()

const ServerHello & esphome::api::SyncClient::server_hello ( ) const
inline

◆ set_request_timeout()

void esphome::api::SyncClient::set_request_timeout ( const std::chrono::milliseconds  timeout)
inline

Default per-request deadline (does not apply to connect, which uses the connection's own handshake timeout).

◆ state()

ConnectionState esphome::api::SyncClient::state ( ) const
inline

◆ store() [1/2]

const EntityStore & esphome::api::SyncClient::store ( ) const
inlinenoexcept

◆ store() [2/2]

EntityStore & esphome::api::SyncClient::store ( )
inlinenoexcept

The underlying entity store (raw typed info/state access).

◆ subscribe_states()

void esphome::api::SyncClient::subscribe_states ( ) const

Subscribe to live state updates.

They are applied to entities() as the loop is pumped (e.g. inside pump_until or run_for on the async client).

◆ voice()

VoiceAssistant & esphome::api::SyncClient::voice ( )
inline

◆ zwave()

ZWaveProxy & esphome::api::SyncClient::zwave ( )
inline

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