Skip to content

Conversation

@swoboda1337
Copy link
Member

What does this implement/fix?

Fix AttributeError: 'Logger' object has no attribute 'Warn' that occurs in MQTT message handling.

Python's logging module uses lowercase method names (debug, info, warning, error, critical). The code incorrectly used _LOGGER.Warn() with a capital 'W' instead of _LOGGER.warning().

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Developer breaking change (an API change that could break external components)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

Pull request in esphome-docs with documentation (if applicable):

  • N/A (no documentation changes needed)

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx
  • nRF52840

Note: This is a Python-only fix that doesn't require device testing.

Example entry for config.yaml:

# N/A - no configuration changes

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

🤖 Generated with Claude Code

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.58%. Comparing base (3eaa9f1) to head (a926bf3).
⚠️ Report is 3 commits behind head on dev.

Files with missing lines Patch % Lines
esphome/mqtt.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #12379      +/-   ##
==========================================
+ Coverage   72.55%   72.58%   +0.02%     
==========================================
  Files          53       53              
  Lines       11189    11189              
  Branches     1516     1516              
==========================================
+ Hits         8118     8121       +3     
+ Misses       2677     2675       -2     
+ Partials      394      393       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Change _LOGGER.Warn() to _LOGGER.warning() to fix AttributeError.

Python's logging module uses lowercase method names, so Warn with
a capital W causes an AttributeError when MQTT receives a message
from a device with a different name than expected.

Fixes esphome#12378

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@swoboda1337
Copy link
Member Author

Thanks

@swoboda1337 swoboda1337 merged commit 27e031c into esphome:dev Dec 9, 2025
22 checks passed
@swoboda1337 swoboda1337 added this to the 2025.11.5 milestone Dec 9, 2025
swoboda1337 added a commit that referenced this pull request Dec 9, 2025
Co-authored-by: Claude <noreply@anthropic.com>
@swoboda1337 swoboda1337 mentioned this pull request Dec 9, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'Logger' object has no attribute 'Warn'. Did you mean: 'warn'?

3 participants