Skip to content

Document AutomationList for hubs that fire their own automations - #284

Merged
J. Nick Koston (bdraco) merged 4 commits into
mainfrom
automation-list
Nov 3, 2026
Merged

J. Nick Koston (bdraco) merged 4 commits into
mainfrom
automation-list

Conversation

@bdraco

@bdraco J. Nick Koston (bdraco) commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

Documents AutomationList and build_automation_lists for a hub that fires its own automations, such as a keypad's on_key: each automation is a pointer-sized slot (4 bytes on 32-bit chips) in a list sized at build time, with no Trigger object, and an unused list compiles out. It also adds a row to the "When to use which method" table.

Pull request in esphome this documents (if applicable):

@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for esphome-dev-docs ready!

Name Link
🔨 Latest commit d888e8f
🔍 Latest deploy log https://app.netlify.com/projects/esphome-dev-docs/deploys/6aea2893072a144ef4eafaad
😎 Deploy Preview https://deploy-preview-284--esphome-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bdraco
J. Nick Koston (bdraco) marked this pull request as ready for review October 29, 2026 08:30
Copilot AI balanced review requested due to automatic review settings October 29, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Python example registers on_tag without a corresponding C++ implementation, so configuring it generates a call to the nonexistent add_on_tag_automation() and causes compilation to fail.

1 open issue
What changed in this PR

Adds developer guidance for hubs that fire their own automations using AutomationList, documenting the API introduced in esphome/esphome#21788.

Changes:

  • Adds Python registration and C++ dispatch examples using build-time-sized automation lists.
  • Explains memory usage, conditional compilation, and when to prefer callbacks or per-automation stored values.
  • Extends the method-selection table with a hub-owned event example.
File Description
src/​content/​docs/​architecture/​components/​automations.md Documents AutomationList and build_automation_lists, with examples and method-selection guidance.

Review effort: Balanced

@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

@esphbot

ESPHome Bot (esphbot) commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Previous review — superseded by a newer review below.

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@esphbot

Copy link
Copy Markdown
Contributor

Note

No code changes since the last review (e89fb7c) — skipping. Push new commits or re-request a review to run again.

@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

@esphbot

Copy link
Copy Markdown
Contributor

PR Review — Document AutomationList for hubs that fire their own automations

Merge-ready. Both earlier findings are fixed, and only one small, non-blocking nit is left.

What works well:

  • d888e8f fixes the earlier slot-size suggestion. The text now says each automation takes "one pointer-sized slot (4 bytes on 32-bit chips)", which is also correct for the 64-bit host platform.
  • e89fb7c fixes Copilot's on_tag mismatch. The Python _AUTOMATION_LISTS entry and the C++ add_on_key_automation setter now line up.
  • The C++ example puts the setter, the dispatch and the member behind #ifdef MY_HUB_ON_KEY_COUNT. That shows clearly how an unused list compiles out.
  • The text tells readers when to use something else: a callback when other code listens to the same event, and new_automation when each automation needs its own stored value. It also says to check empty() before building an argument that is costly to make.
  • The section follows the page's existing structure (a description, then #### Python, then #### C++) and adds a matching row to the method table.

One nit:

  • The pending wiegand row links to a dev file that does not use AutomationList yet. The pending lock row uses plain text with only the PR link instead.


Checklist

  • Python and C++ examples are consistent (setter name matches add_<conf_key>_automation)
  • Prior review feedback (on_tag mismatch, pointer-sized slot) resolved
  • Pending upstream links clearly marked and consistent with other pending rows
  • Diff matches PR description

Automated review by Kōan (Claude) HEAD=d888e8f 28s

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The documentation change covering hub-owned automation lists has no active review issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@bdraco
J. Nick Koston (bdraco) merged commit 4da6847 into main Nov 3, 2026
11 checks passed
@bdraco
J. Nick Koston (bdraco) deleted the automation-list branch November 3, 2026 18:47
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.

3 participants