Documentation Index
Fetch the complete documentation index at: https://mintlify.com/richard87/esphome-apiclient/llms.txt
Use this file to discover all available pages before exploring further.
What is Noise encryption
ESPHome uses theNoise_NNpsk0_25519_ChaChaPoly_SHA256 cipher suite to secure API connections. This is a well-established authenticated encryption protocol with the following properties:
- No certificates required — authentication is based solely on a pre-shared 32-byte key (PSK)
- Perfect forward secrecy — ephemeral X25519 key pairs are generated for each session
- Authenticated encryption — ChaCha20-Poly1305 provides both confidentiality and integrity
github.com/flynn/noise.
Getting your encryption key
Find the encryption key in your ESPHome device YAML configuration:Enabling encryption in the client
PassWithEncryptionKey when dialing:
base64.StdEncoding.DecodeString before passing the 32-byte PSK to the Noise handshake. An invalid base64 string causes an immediate error before any TCP connection is attempted.
Key format
The encryption key must be a standard base64-encoded string (with padding) that decodes to exactly 32 bytes. For example, to generate a new key:Device name validation
WithExpectedName validates the device name reported by the ESPHome device during the Noise handshake. If the name does not match, the connection is rejected before any protobuf messages are exchanged.
expectedName is compared against the null-terminated server name that the device sends in its Noise server hello. If the names differ, Dial returns an error such as:
Plain connections
OmitWithEncryptionKey to connect without encryption:
Common connection errors
| Error message | Cause |
|---|---|
invalid encryption key: illegal base64 data | The key string is not valid base64 |
noise PSK must be 32 bytes, got N | The decoded key is not 32 bytes |
invalid encryption key: Handshake MAC failure | The PSK does not match the device |
server name mismatch: expected X, got Y | WithExpectedName check failed |
device is using plaintext protocol | Client sent a Noise hello to a plain device |