Skip to content

Commit 0a9ba40

Browse files
authored
Merge branch 'current' into addressable_light_digital_display
2 parents 6edc7c9 + fc29968 commit 0a9ba40

File tree

8 files changed

+190
-0
lines changed

8 files changed

+190
-0
lines changed

components/api.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ A Python library that implements this protocol is `aioesphomeapi <https://github
3131
# Example configuration entry
3232
api:
3333
34+
.. code-block:: yaml
35+
36+
# Example with more options
37+
api:
38+
port: 6053
39+
batch_delay: 50ms # Reduce latency for real-time applications
40+
encryption:
41+
key: "YOUR_ENCRYPTION_KEY_HERE"
42+
reboot_timeout: 30min
43+
3444
Configuration variables:
3545
------------------------
3646

@@ -75,6 +85,9 @@ Configuration variables:
7585
Support for configuring the encryption key on-the-fly will be implemented in a future release of Home Assistant.
7686

7787
- **actions** (*Optional*, list): A list of user-defined actions. See :ref:`api-device-actions`.
88+
- **batch_delay** (*Optional*, :ref:`config-time`): The delay time for batching multiple state update messages
89+
together to reduce network overhead. Lower values send updates sooner but use more network packets,
90+
while higher values batch more efficiently but add latency. Defaults to ``100ms``.
7891
- **reboot_timeout** (*Optional*, :ref:`config-time`): The amount of time to wait before rebooting when no
7992
client connects to the API. This is needed because sometimes the low level ESP functions report that
8093
the ESP is connected to the network, when in fact it is not - only a full reboot fixes it.

components/debug.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ See Also
9898

9999
- :ref:`sensor-filters`
100100
- :doc:`logger`
101+
- :doc:`/guides/troubleshooting` - Troubleshooting guide for debugging crashes and boot failures
101102
- :apiref:`debug/debug_component.h`
102103
- :ghedit:`Edit`

components/logger.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,6 @@ See Also
343343

344344
- :doc:`/components/uart`
345345
- :doc:`/components/select/logger`
346+
- :doc:`/guides/troubleshooting` - Troubleshooting guide for debugging crashes and boot failures
346347
- :apiref:`logger/logger.h`
347348
- :ghedit:`Edit`

components/safe_mode.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ See Also
5050
- :apiref:`safe_mode/safe_mode.h`
5151
- :doc:`/components/button/safe_mode`
5252
- :doc:`/components/switch/safe_mode`
53+
- :doc:`/guides/troubleshooting` - Troubleshooting guide for debugging crashes and boot failures
5354
- :ghedit:`Edit`

components/voice_assistant.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ ESPHome devices with a microphone are able to stream the audio to Home Assistant
1818
**Crashes are likely to occur** if you include too many additional components in your device's
1919
configuration. In particular, Bluetooth/BLE components are known to cause issues when used in
2020
combination with Voice Assistant and/or other audio components.
21+
22+
If you experience crashes, see the :doc:`/guides/troubleshooting` guide for how to get a backtrace.
2123

2224
Configuration variables:
2325
------------------------

guides/cli.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,53 @@ You can register ESPHome for auto-completion by adding the following to your ~/.
285285
eval "$(register-python-argcomplete esphome)"
286286
287287
For more information, see `argcomplete <https://kislyuk.github.io/argcomplete/>`__ documentation.
288+
289+
Using logging tools supplied with ESPHome
290+
-----------------------------------------
291+
There are two types of logging interfaces supplied with ESPHome: API and Serial (UART) logging.
292+
For serial logging, there are many options including `ESPHome Web <https://web.esphome.io>`__ and
293+
the ESPHome CLI's ``run`` command.
294+
295+
For basic API based logging uses, one can use the ``aioesphomeapi-logs`` command bundled with ESPHome,
296+
Which is especially useful for ESP devices in a remote/inaccessible location.
297+
298+
The syntax is as follows:
299+
300+
.. code-block:: console
301+
302+
aioesphomeapi-logs <IPv4 pr IPv6 address>
303+
304+
Some working examples include:
305+
306+
.. code-block:: console
307+
308+
aioesphomeapi-logs 192.168.x.y
309+
aioesphomeapi-logs fe80::cdef:0123:4567:89ab
310+
aioesphomeapi-logs 2001:0db8:3333:4444:5555:6666:7777:8888
311+
312+
Press ``CTRL+C`` to exit the logging view.
313+
314+
If you have configured encryption for API, provide the key from the yaml as follows:
315+
316+
.. code-block:: console
317+
318+
aioesphomeapi-logs 192.168.x.y --noise-psk <your-api-key-from-yaml>
319+
320+
If you do not know/wish to know the IP address of an ESPHome device,
321+
one can also use ``aioesphomeapi-discover`` to discover online ESPHome devices on the local network.
322+
323+
The syntax is as follows:
324+
325+
.. code-block:: console
326+
327+
aioesphomeapi-discover
328+
329+
The response lists info about currently available ESPHome devices:
330+
331+
``Status |Name |Address |MAC |Version |Platform |Board``
332+
333+
See Also
334+
--------
335+
336+
- :doc:`Guides </guides/index>`
337+
- :ghedit:`Edit`

guides/faq.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ That's no good. Here are some steps that resolve some problems:
267267

268268
- **If you're having Wi-Fi problems**: See :ref:`wifi-problems`.
269269
- :ref:`Enable verbose logs<logger-log_levels>` in your ESPHome device's ``logger:`` section.
270+
- **If your device is crashing**: See the :doc:`/guides/troubleshooting` guide for how to get a backtrace.
270271
- **Still seeing an error?** Check if there is a known issue in the
271272
`ESPHome issue tracker <https://github.com/esphome/issues/issues>`__. If not, you can create a new issue to describe your
272273
problem there. We will take a look at it as soon as we can. Thanks!

guides/troubleshooting.rst

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Troubleshooting
2+
===============
3+
4+
.. seo::
5+
:description: Guide for troubleshooting ESPHome issues, debugging crashes, and obtaining decoded stack traces from device failures.
6+
:image: bug-report.svg
7+
8+
This guide helps you diagnose and debug ESPHome device issues, particularly crashes and boot failures. Whether you're experiencing random resets, watchdog timeouts, or need to analyze stack traces, this guide provides step-by-step instructions for capturing and understanding crash data.
9+
10+
.. note::
11+
12+
This guide assumes you have ESPHome installed and basic familiarity with the command line. For installation instructions, see :doc:`/guides/installing_esphome`.
13+
14+
Getting a Stack Trace from Crashes
15+
-----------------------------------
16+
17+
When your ESPHome device crashes, you can obtain a decoded stack trace to help identify the cause. This requires:
18+
19+
1. Compiling the firmware locally (to have matching debug symbols)
20+
2. Connecting the device via USB cable for serial console access
21+
3. Running the logs command to capture and decode the crash
22+
23+
Steps to Get a Stack Trace
24+
~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
26+
1. **Compile locally**: Build your configuration on your local machine to ensure you have matching debug symbols.
27+
28+
If you're using the ESPHome Device Builder web interface:
29+
30+
- Click the overflow menu (three dots) next to your device
31+
- Select "Download YAML" to get your configuration file
32+
- Save it to a local directory
33+
34+
Then use the command line interface (see the :doc:`/guides/cli` guide for full details):
35+
36+
.. code-block:: bash
37+
38+
esphome compile your-device.yaml
39+
esphome upload your-device.yaml
40+
41+
.. note::
42+
43+
While you can use OTA for the upload, you'll need a USB connection anyway to capture the crash output in the next steps, so uploading via USB is usually more convenient.
44+
45+
2. **Connect via USB**: Connect your device to your computer using a USB cable. The device must be connected via serial console (not over WiFi/OTA) to capture the crash output.
46+
47+
3. **Monitor logs**: Run the logs command to monitor the device output:
48+
49+
.. code-block:: bash
50+
51+
esphome logs your-device.yaml
52+
53+
4. **Wait for crash**: When the device crashes, ESPHome will automatically detect and decode the stack trace. You'll see output similar to this:
54+
55+
.. code-block:: text
56+
57+
[08:17:06]E (5906) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
58+
[08:17:06]E (5906) task_wdt: - loopTask (CPU 0)
59+
[08:17:06]E (5906) task_wdt: Tasks currently running:
60+
[08:17:06]E (5906) task_wdt: CPU 0: esp_timer
61+
[08:17:06]E (5906) task_wdt: CPU 1: IDLE1
62+
[08:17:06]E (5906) task_wdt: Aborting.
63+
[08:17:06]E (5906) task_wdt: Print CPU 0 (current core) backtrace
64+
65+
[08:17:06]Backtrace: 0x4013d30e:0x3ffbac20 0x4013d383:0x3ffbac40 0x4014b23e:0x3ffbac70
66+
WARNING Found stack trace! Trying to decode it
67+
WARNING Decoded 0x4013d30e: touch_ll_is_measure_done at /Users/bdraco/.platformio/packages/framework-espidf/components/hal/esp32/include/hal/touch_sensor_ll.h:505
68+
(inlined by) _touch_pad_read at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:365
69+
WARNING Decoded 0x4013d383: touch_pad_filter_cb at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:108
70+
(inlined by) touch_pad_filter_cb at /Users/bdraco/.platformio/packages/framework-espidf/components/driver/touch_sensor/esp32/touch_sensor.c:98
71+
WARNING Decoded 0x4014b23e: timer_process_alarm at /Users/bdraco/.platformio/packages/framework-espidf/components/esp_timer/src/esp_timer.c:456
72+
(inlined by) timer_task at /Users/bdraco/.platformio/packages/framework-espidf/components/esp_timer/src/esp_timer.c:482
73+
74+
The decoded stack trace shows:
75+
76+
- The exact function names and source files where the crash occurred
77+
- Line numbers in the source code
78+
- The call stack leading to the crash
79+
80+
.. note::
81+
82+
**Important**: You must compile locally and upload the firmware before capturing the crash. The debug symbols must match the running firmware for the stack trace to be decoded correctly.
83+
84+
Common Issues
85+
~~~~~~~~~~~~~
86+
87+
- **No decoded output**: Ensure you compiled and uploaded the firmware locally before capturing the crash
88+
- **Cannot connect**: Make sure you're using a USB data cable (not just a charging cable) and the correct serial port
89+
90+
Alternative: Web-Based Stack Trace Decoder
91+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92+
93+
If you already have a stack trace but need to decode it, you can use the `ESP Stack Trace Decoder <https://esphome.github.io/esp-stacktrace-decoder/>`__ web tool:
94+
95+
1. **Download the .elf file**: From the ESPHome dashboard, click the overflow menu (three dots) on your device card and select "Download .elf file"
96+
97+
.. note::
98+
99+
The .elf file must be from the same compilation that produced the firmware currently running on your device. If you've recompiled since flashing, the debug symbols won't match.
100+
101+
2. **Open the decoder**: Navigate to https://esphome.github.io/esp-stacktrace-decoder/
102+
103+
3. **Upload files**:
104+
105+
- Click "Choose File" under "ELF File" and select your downloaded .elf file
106+
- Paste your stack trace into the text area
107+
- Click "Decode Stack Trace"
108+
109+
4. **View results**: The tool will decode the addresses and show you the function names, file paths, and line numbers
110+
111+
.. note::
112+
113+
This tool runs entirely in your browser - no data is sent to any server, ensuring your firmware and debug information remain private.
114+
115+
See Also
116+
--------
117+
118+
- :doc:`/components/logger` - Configure logging levels and outputs
119+
- :doc:`/components/debug` - Debug component for additional diagnostics
120+
- :doc:`/components/safe_mode` - Safe Mode recovery guide
121+
- :doc:`/guides/faq` - Frequently asked questions

0 commit comments

Comments
 (0)