Expand description
Low-level ESPHome native API implementation.
This module provides EspHomeApi, which handles the core protocol communication
with ESPHome devices. It manages connection establishment, encryption handshakes,
message framing, and protocol state.
§Examples
§Plaintext Connection
use esphome_native_api::esphomeapi::EspHomeApi;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let stream = TcpStream::connect("192.168.1.100:6053").await?;
let mut api = EspHomeApi::builder()
.name("my-client".to_string())
.build();
let (tx, mut rx) = api.start(stream).await?;
Ok(())
}§Encrypted Connection
use esphome_native_api::esphomeapi::EspHomeApi;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let stream = TcpStream::connect("192.168.1.100:6053").await?;
let mut api = EspHomeApi::builder()
.name("my-client".to_string())
.encryption_key("your-base64-encoded-key".to_string())
.build();
let (tx, mut rx) = api.start(stream).await?;
Ok(())
}Structs§
- EspHome
Api - Low-level ESPHome native API client.