pub struct EspHomeClientBuilder { /* private fields */ }Implementations§
Source§impl EspHomeClientBuilder
impl EspHomeClientBuilder
Sourcepub fn address(self, addr: &str) -> Self
pub fn address(self, addr: &str) -> Self
Sets the host address of the ESPHome API server to connect to.
Takes the address of the server in the format “host:port”.
Sourcepub fn key(self, key: &str) -> Self
pub fn key(self, key: &str) -> Self
Enables the use of a 32-byte base64-encoded key for encrypted communication.
If no key is provided, the connection will be established in plain text. Further reference: https://esphome.io/components/api.html#configuration-variables
Sourcepub fn password(self, password: &str) -> Self
pub fn password(self, password: &str) -> Self
Enables the use of a password to authenticate the client.
Note that this password is deprecated and will be removed in a future version of ESPHome. This only works if connection setup is enabled.
Sourcepub const fn timeout(self, timeout: Duration) -> Self
pub const fn timeout(self, timeout: Duration) -> Self
Sets the timeout duration during the tcp connection.
Sourcepub fn client_info(self, client_info: &str) -> Self
pub fn client_info(self, client_info: &str) -> Self
Sets the client info string that will be sent in the HelloRequest.
Defaults to the package name and version of the client. This only works if connection setup is enabled.
Sourcepub const fn without_connection_setup(self) -> Self
pub const fn without_connection_setup(self) -> Self
Disable connection setup messages.
Most api requests require a connection setup, which requires a sequence of messages to be sent and received.
HelloRequest->HelloResponseConnectionRequest->ConnectionResponse
By disabling this, the connection can be established manually.
Sourcepub const fn without_ping_handling(self) -> Self
pub const fn without_ping_handling(self) -> Self
Disable automatic handling of ping request.
The ESPHome API server will send a ping request to the client on a regular interval.
The client needs to respond with a PingResponse to keep the connection alive.
Sourcepub async fn connect(self) -> Result<EspHomeClient, ClientError>
pub async fn connect(self) -> Result<EspHomeClient, ClientError>
Connect to the ESPHome API server.
§Errors
Will return an error if the connection fails, or if the connection setup fails.