Skip to main content
esphome-cli is a bundled command-line tool for interacting with ESPHome devices directly from the terminal. It wraps the Go client library and exposes the most common operations — scanning for devices, reading device info, streaming sensor values, tailing logs, and controlling switches — as simple subcommands.

Installation

Install with go install:
go install github.com/richard87/esphome-apiclient/cmd/esphome-cli@latest
Ensure your GOBIN directory (usually $HOME/go/bin) is in your PATH. If esphome-cli is not found after installation, add export PATH="$HOME/go/bin:$PATH" to your shell profile.

Global flags

Global flags can be placed before or after the subcommand — flags are inherited by all subcommands.
FlagShortDescription
--address-aDevice address in host:port format. Overrides the address derived from --yaml.
--yaml-yPath to an ESPHome device YAML config file. Derives the device address and encryption key automatically.
--key-kBase64-encoded Noise encryption key. Overrides the key from --yaml.
--name-nExpected device name used for Noise handshake validation.
--timeout-tConnection timeout (default: 5s).

Using --yaml for automatic configuration

The --yaml flag accepts the path to an ESPHome device YAML file and automatically derives the device address (<name>.local:6053) and Noise encryption key from the esphome.name and api.encryption.key fields. This is the most convenient way to connect when you have the device YAML on hand. If a secrets.yaml file exists in the same directory, !secret references inside the device YAML are substituted automatically before parsing.
esphome-cli --yaml path/to/device.yaml info

Available subcommands

SubcommandDescription
scanScan for ESPHome devices on the local network using mDNS
infoPrint device info (name, MAC address, ESPHome version, model, API version)
entitiesList all entities on the device grouped by domain
sensorsStream live state updates for sensors, binary sensors, switches, and text sensors
logsStream device log output with optional level filtering
switchList switches or control a specific switch
bluetoothStream Bluetooth LE advertisement packets

Quick examples

# Scan for ESPHome devices on the local network
esphome-cli scan

# Connect using an ESPHome YAML config (derives address and key automatically)
esphome-cli --yaml device.yaml info

# Connect by specifying address and key directly
esphome-cli --address mydevice.local:6053 --key "base64-noise-psk" logs
See CLI commands for the full reference for each subcommand and its flags.