ESPHome firmware writes structured log messages at configurable severity levels. The API client can subscribe to these messages in real time, which is useful for debugging device behaviour and monitoring firmware output without needing a serial connection.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.
Function signature
SubscribeLogs sends a SubscribeLogsRequest to the device with DumpConfig: true set automatically. This causes the device to emit its current configuration as log messages immediately after the subscription is accepted.
Example
Log levels
Pass one of the following constants as thelevel argument. The device will deliver messages at that level and all higher-severity levels.
| Constant | Severity |
|---|---|
pb.LogLevel_LOG_LEVEL_NONE | No log output |
pb.LogLevel_LOG_LEVEL_ERROR | Errors only |
pb.LogLevel_LOG_LEVEL_WARN | Warnings and errors |
pb.LogLevel_LOG_LEVEL_INFO | Informational messages and above |
pb.LogLevel_LOG_LEVEL_CONFIG | Configuration messages and above |
pb.LogLevel_LOG_LEVEL_DEBUG | Debug messages and above (default for CLI) |
pb.LogLevel_LOG_LEVEL_VERBOSE | Verbose trace messages and above |
pb.LogLevel_LOG_LEVEL_VERY_VERBOSE | All messages including very verbose trace |
SubscribeLogsResponse fields
| Field | Type | Description |
|---|---|---|
Level | pb.LogLevel | Severity level of this message |
Message | string | Log message text |
SendFailed | bool | True if the device could not send a previous message (buffer overflow) |
Unsubscribing
The returnedunsubscribe function removes the log handler. After calling it, no further messages will be delivered to the handler.
Practical uses
- Debugging sensor readings — stream
DEBUGlogs to see raw values before filtering - Monitoring firmware boot — the automatic config dump on subscribe shows the active component configuration
- Detecting errors in production — subscribe at
ERRORlevel to receive only actionable messages - Developing automations — trace state machine transitions by watching
INFOorDEBUGoutput