-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Blog post for new MQTT subscribe status callback option #2807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughA blog post documents new MQTT subscription features: an Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant async_subscribe
participant Broker
participant on_subscribe_status
Caller->>async_subscribe: subscribe(topic, on_subscribe_status=callback)
async_subscribe->>Broker: SUBSCRIBE message
Broker-->>async_subscribe: SUBACK
async_subscribe->>on_subscribe_status: invoke callback(status)
on_subscribe_status-->>Caller: subscription ready
Caller->>Caller: proceed with operations
sequenceDiagram
participant Caller
participant async_on_subscribe_done
participant async_subscribe
participant Broker
Caller->>async_on_subscribe_done: monitor subscription
alt Subscription exists
async_on_subscribe_done-->>Caller: immediate readiness
else Subscription pending
async_on_subscribe_done->>async_subscribe: wait for confirmation
async_subscribe->>Broker: SUBSCRIBE
Broker-->>async_subscribe: SUBACK
async_on_subscribe_done-->>Caller: ready after confirmation
end
Caller->>Caller: perform post-subscription actions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
blog/2025-09-26-mqtt-subscribe-wait.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)
⚙️ CodeRabbit configuration file
*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
*/**(html|markdown|md): - Use bold to mark UI strings.
If "" are used to mark UI strings, replace them by bold.
Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Use sentence-style capitalization also in headings.
do not comment on HTML used for icons
Avoid flagging inline HTML for embedding videos in future reviews for this repository.
Files:
blog/2025-09-26-mqtt-subscribe-wait.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Redirect rules - developers-home-assistant
- GitHub Check: Header rules - developers-home-assistant
- GitHub Check: Pages changed - developers-home-assistant
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
blog/2025-10-29-mqtt-subscribe-wait.md (1)
67-67: Improve clarity of description and grammar."to allow doing additional task" should be "to perform additional tasks". Also, rewrite for directness per documentation guidelines.
- In case a subscription is already pending, or when we want to keep monitoring, the `mqtt.async_on_subscribe_done` helper can be used to monitor its subscription, to allow doing additional task. Make sure the same QoS is used. + Use the `mqtt.async_on_subscribe_done` helper to monitor an existing or pending subscription and perform additional tasks. Ensure you use the same QoS value.As per coding guidelines, use direct language, avoid passive constructions, and front goals.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
blog/2025-10-29-mqtt-subscribe-wait.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)
⚙️ CodeRabbit configuration file
*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
*/**(html|markdown|md): - Use bold to mark UI strings.
If "" are used to mark UI strings, replace them by bold.
Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Use sentence-style capitalization also in headings.
do not comment on HTML used for icons
Avoid flagging inline HTML for embedding videos in future reviews for this repository.
Files:
blog/2025-10-29-mqtt-subscribe-wait.md
| author: Jan Bouwhuis | ||
| authorURL: https://github.com/jbouwh | ||
| authorImageURL: https://avatars.githubusercontent.com/u/7188918?s=96&v=4 | ||
| title: Option added to add a callback for status updates on an MQTT subscription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Improve title and heading phrasing.
Both the title (line 5) and heading (line 8) use awkward phrasing with "add to add" and "add a callback on". Use more concise language.
- title: Option added to add a callback for status updates on an MQTT subscription
+ title: Add a status callback for MQTT subscriptions
- ## Option added to add a callback on an MQTT subscription
+ ## Add a status callback for MQTT subscriptionsAs per coding guidelines, prefer direct, authoritative language and front the goal.
Also applies to: 8-8
🤖 Prompt for AI Agents
In blog/2025-10-29-mqtt-subscribe-wait.md around lines 5 and 8, the title and
heading use awkward duplicate phrasing ("add to add" and "add a callback on");
update both to concise, authoritative language that fronts the goal. Replace the
title with something like "Option to receive status updates for MQTT
subscriptions" and the heading with "Add status-update callback for MQTT
subscriptions" (or similar short, active variants) so they are clear, direct,
and free of duplicated words.
| """Callback example.""" | ||
| # Do stuff | ||
|
|
||
| def _on_subscribe() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix function name mismatch in code example.
Line 44 defines the callback as _on_subscribe(), but line 58 references it as _on_subscribe_status. These must match.
- def _on_subscribe() -> None:
+ def _on_subscribe_status() -> None:
"""Publish an online state when we are ready to receive updates."""
hass.async_create_task(
mqtt.async_publish(Also applies to: 58-58
🤖 Prompt for AI Agents
In blog/2025-10-29-mqtt-subscribe-wait.md around lines 44 and 58, the callback
name is inconsistent: the function is defined as `_on_subscribe()` at line 44
but referenced as `_on_subscribe_status` at line 58; rename the definition to
`_on_subscribe_status()` (or update the reference to `_on_subscribe`) so both
the definition and call use the same identifier, and ensure any other references
in the example are updated accordingly.
| ... | ||
| ``` | ||
|
|
||
| ## Receive status updates on for as specific MQTT subscription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix heading grammar.
"Receive status updates on for as specific MQTT subscription" is grammatically incorrect.
- ## Receive status updates on for as specific MQTT subscription
+ ## Monitor subscription status with the helper function📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## Receive status updates on for as specific MQTT subscription | |
| ## Monitor subscription status with the helper function |
🤖 Prompt for AI Agents
In blog/2025-10-29-mqtt-subscribe-wait.md around line 65, the heading "Receive
status updates on for as specific MQTT subscription" is grammatically incorrect;
replace it with a corrected heading such as "Receive status updates for a
specific MQTT subscription" (or "Receive status updates on a specific MQTT
subscription") so the sentence reads properly.
| """Integration .""" | ||
| # Do stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete the callback docstring.
Line 78 contains an incomplete comment that reads only "Integration ."
def _on_subscribe_status() -> None:
- """Integration ."""
+ """Handle subscription ready signal."""
# Do stuff📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| """Integration .""" | |
| # Do stuff | |
| """Handle subscription ready signal.""" | |
| # Do stuff |
🤖 Prompt for AI Agents
In blog/2025-10-29-mqtt-subscribe-wait.md around lines 78 to 79, the callback
docstring is incomplete ("Integration ."); replace it with a complete,
self-contained docstring describing the callback's purpose (e.g., what
integration it performs), its parameters (names, types, and meanings), return
value (if any), and any side effects or exceptions raised — keep it concise and
use conventional docstring style consistent with the project.
Proposed change
Blog post for new MQTT subscribe subscribe status callback option
Type of change
Checklist
Additional information
Summary by CodeRabbit
Release Notes
New Features
Documentation