Hello, Home Assistant Community,
I’m encountering an issue with my ESPHome configuration specifically related to the MQTT log_topic
setting.
Problem Description
In my ESPHome configuration, I attempted to disable MQTT logging by setting log_topic
to null
within the MQTT section, following the ESPHome documentation which suggests this method to disable sending logs over MQTT.
mqtt:
broker: !secret mqtt_broker
username: !secret mqtt_user
password: !secret mqtt_pass
log_topic: null
discovery: true
discovery_prefix: homeassistant
discovery_unique_id_generator: mac
However, after compiling and uploading the firmware, I encounter the following error in the ESPHome log:
INFO Successfully compiled program.
INFO Resolving IP address of esphome03.local
INFO -> 192.168.33.146
INFO Uploading /data/build/esphome03/.pioenvs/esphome03/firmware.bin (441472 bytes)
INFO Compressed to 307937 bytes
Uploading: [============================================================] 100% Done...
INFO Upload took 5.58 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
Traceback (most recent call last):
File "/usr/local/bin/esphome", line 33, in <module>
sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/__main__.py", line 1041, in main
return run_esphome(sys.argv)
^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/__main__.py", line 1028, in run_esphome
rc = POST_CONFIG_ACTIONS[args.command](args, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/__main__.py", line 487, in command_run
return show_logs(config, args, port)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/__main__.py", line 362, in show_logs
return mqtt.show_logs(
^^^^^^^^^^^^^^^
File "/esphome/esphome/mqtt.py", line 213, in show_logs
topic = config[CONF_MQTT][CONF_LOG_TOPIC][CONF_TOPIC]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
This error suggests a Python TypeError
occurs when the script tries to access a log_topic
that is set to null
. The error disappears, and the logs function as expected when I remove log_topic: null
from the configuration.
Questions
- Is this behavior a bug in ESPHome, or am I misunderstanding the correct way to disable MQTT logging?
- Given that I am new to Home Assistant and ESPHome, could there be a more appropriate method to disable MQTT logs that I am not aware of?
I would be grateful for any advice on how to resolve this issue or where to look next.
Thank you in advance for your help and patience.