Skip to content

Fix builds on ESPHome 2026.10/2026.11 and upgrades from pre-1.3.0 releases - #78

Closed
robsonek wants to merge 3 commits into
IoTLabs-pl:masterfrom
robsonek:fix/esphome-2026.11-and-legacy-drivers
Closed

robsonek wants to merge 3 commits into
IoTLabs-pl:masterfrom
robsonek:fix/esphome-2026.11-and-legacy-drivers

Conversation

@robsonek

Copy link
Copy Markdown
Contributor

Three independent fixes, one commit each.

1. wmbus_meter: doesn't load on ESPHome 2026.10

esphome/esphome#19602 turned mqtt.publish into an apply action and removed MQTTPublishAction and mqtt_publish_action_to_code. On 2026.10.0b3 (and dev), every config that uses wmbus_meter therefore fails at validation:

ImportError: cannot import name 'MQTTPublishAction' from 'esphome.components.mqtt'
Component not found: wmbus_meter.

This PR adds an equivalent SendTelegramWithMQTTAction to wmbus_meter/automation.h (guarded by USE_MQTT), along with its own to_code. The action only relies on things that are identical in 2026.9.1, 2026.10.0b3 and dev: MQTT_PUBLISH_ACTION_SCHEMA, MQTTClientComponent::publish(std::string, std::string, uint8_t, bool), TEMPLATABLE_VALUE and register_action(..., synchronous=True). The YAML of wmbus_meter.send_telegram_with_mqtt is unchanged.

2. Builds upgraded from < v1.3.0 fail on a leftover drivers directory

Before v1.3.0, drivers were synced into src/wmbusmeters_drivers. They now go to src/wmbusmeters_generated, and only that directory is pruned. When an existing build directory gets upgraded (for example wM-Bus Gateway 1.1.x to 1.2.x without "Clean Build Files"), the old directory stays behind. ESP-IDF globs src/ recursively, so the build fails:

../src/wmbusmeters_drivers/amiplus.cpp:18:9: fatal error: ../esphome/components/wmbus_common/meters_common_implementation.h: No such file or directory

wmbus_common now removes the legacy directory before syncing drivers.

3. Include alloc_helpers.h directly (ESPHome 2026.11)

helpers.h stops re-exporting alloc_helpers.h in 2026.11.0 (esphome/esphome#20389). quirks.cpp, packet.cpp and component.cpp (wmbus_radio) and extractor.h (panasonic_aquarea) use str_sprintf, format_hex or format_hex_pretty without including it. wmbus_meter.cpp, meter.cpp and records.cpp already include it.

Testing

All builds use the esphome/esphome Docker images and tests/wmbus/sx1276.yaml (esp32) unless noted otherwise.

Scenario Before After
2026.9.1 ✅ ✅
2026.10.0b3 ❌ ImportError (MQTT) ✅
dev (2026.11), MQTT action stripped from a throwaway copy to get past (1) ❌ 'str_sprintf' is not a member of 'esphome' in quirks.cpp ✅
dev, full config incl. send_telegram_with_mqtt ❌ (MQTT) ✅
2026.9.1, built once, then a v1.2.5 driver_amiplus.cpp dropped into src/wmbusmeters_drivers/ and rebuilt (no clean) ❌ fatal error above, dir kept ✅, dir removed
tests/panasonic_aquarea/test.yaml on dev ✅ ✅
wM-Bus Gateway v1.2.1 package + these components + hydrocalm4/amiplus meters + a wmbus_meter sensor on 2026.10.0b3 ❌ (MQTT) ✅

panasonic_aquarea builds on dev even without the extra include, probably because the string extractor template isn't instantiated in the test config. The include follows ESPHome's recommendation to include alloc_helpers.h directly, so it doesn't break once that template is instantiated.

clang-format --dry-run --Werror passes on all touched C++ files.

🤖 Generated with Claude Code

robsonek and others added 3 commits October 13, 2026 13:49
…ases

Before v1.3.0 drivers were synced into src/wmbusmeters_drivers. They now
go to src/wmbusmeters_generated, and only that directory is pruned. The
old directory stayed behind, and esp-idf globs src/ recursively, so
upgrading an existing build failed with:

  wmbusmeters_drivers/amiplus.cpp: fatal error:
  ../esphome/components/wmbus_common/meters_common_implementation.h:
  No such file or directory

Drop the legacy directory before syncing drivers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h directly

str_sprintf(), format_hex() and format_hex_pretty() moved to
alloc_helpers.h, and helpers.h stops re-exporting it in ESPHome 2026.11.0
(esphome/esphome#20389). Include it explicitly wherever these helpers are
used, as wmbus_meter.cpp, meter.cpp and records.cpp already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ESPHome 2026.10 turned mqtt.publish into an apply action
(esphome/esphome#19602) and removed MQTTPublishAction and
mqtt_publish_action_to_code, so importing wmbus_meter failed with
"Component not found: wmbus_meter". Keep an equivalent action in
wmbus_meter instead; it only relies on MQTTClientComponent::publish(),
which is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kubasaw

kubasaw commented Oct 13, 2026

Copy link
Copy Markdown
Member

Thank you @robsonek! Closing this one, since the three commits went different ways:

  1. (wmbus_meter) Use own action for send_telegram_with_mqtt: merged in (wmbus_meter) Fix send_telegram_with_mqtt on ESPHome 2026.10 #79. A follow-up commit there registers send_telegram_with_mqtt the same way mqtt.publish is registered, so it works on both 2026.9 and 2026.10+.
  2. Include alloc_helpers.h directly: moved to (wmbus_radio, wmbus_common, panasonic_aquarea) Fix builds on ESPHome 2026.11 #80. On top of it, the log-only hex dumps and the Aquarea error code now go into stack buffers, so wmbus_radio/component.cpp and panasonic_aquarea no longer need alloc_helpers.h. The Aquarea test config was also extended so every extractor gets compiled.
  3. (wmbus_common) Remove drivers left in the build dir by pre-1.3.0 releases: not taken over. It only hits a one-off upgrade of an existing build directory, and "Clean Build Files" fixes that. We'd rather not have the component deleting paths in src/ on every build.

@kubasaw kubasaw closed this Oct 13, 2026
@robsonek
robsonek deleted the fix/esphome-2026.11-and-legacy-drivers branch October 13, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants