-
-
Notifications
You must be signed in to change notification settings - Fork 79
Add support for getting action responses from home-assistant #1374
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1374 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 3263 3279 +16
=========================================
+ Hits 3263 3279 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #1374 will not alter performanceComparing Summary
|
|
Caution Review failedThe pull request is closed. WalkthroughAdds request/response correlation for Home Assistant actions: extends HomeassistantActionRequest with Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor HA as Home Assistant
participant Device as ESPHome Device
participant API as APIClient
participant Core as Proto/Core
Note over HA,Device: HomeassistantActionRequest (may include call_id/wants_response/response_template)
HA->>Device: HomeassistantActionRequest(service, data, call_id, wants_response, response_template)
Device->>API: on_home_assistant_action_request(msg)
API->>Device: Callback with HomeassistantServiceCall(call_id, wants_response, response_template, ...)
rect rgba(200,235,255,0.12)
note right of Device: Device handles action and optionally responds
Device->>API: send_homeassistant_action_response(call_id, response_data, success, error_message)
API->>Core: Encode HomeassistantActionResponse (id=130)
Core-->>HA: HomeassistantActionResponse(call_id, success, error_message, response_data)
end
alt success
note over HA,Device: success=true
else failure
note over HA,Device: success=false, error_message set
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
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
📒 Files selected for processing (6)
aioesphomeapi/api.proto(1 hunks)aioesphomeapi/client.py(5 hunks)aioesphomeapi/client_base.py(1 hunks)aioesphomeapi/core.py(2 hunks)aioesphomeapi/model.py(1 hunks)tests/test_client.py(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
- Do not generate or add any sequence diagrams
Files:
aioesphomeapi/core.pyaioesphomeapi/api.protoaioesphomeapi/model.pyaioesphomeapi/client.pytests/test_client.pyaioesphomeapi/client_base.py
🧬 Code graph analysis (4)
aioesphomeapi/core.py (1)
aioesphomeapi/model.py (1)
HomeassistantActionResponse(1167-1171)
aioesphomeapi/client.py (3)
aioesphomeapi/model.py (1)
HomeassistantActionResponse(1167-1171)aioesphomeapi/client_base.py (2)
on_home_assistant_action_request(88-92)_get_connection(363-371)aioesphomeapi/connection.py (1)
send_message(760-762)
tests/test_client.py (2)
aioesphomeapi/model.py (2)
HomeassistantActionResponse(1167-1171)HomeassistantServiceCall(1150-1163)aioesphomeapi/client.py (1)
send_homeassistant_action_response(1598-1611)
aioesphomeapi/client_base.py (1)
aioesphomeapi/model.py (6)
HomeassistantServiceCall(1150-1163)from_pb(86-87)from_pb(1269-1312)from_pb(1358-1364)from_pb(1398-1409)from_pb(1441-1453)
🔇 Additional comments (2)
aioesphomeapi/api.proto (2)
783-784: LGTM! Field additions are well-designed.The new
call_idandresponse_templatefields properly extend the message for request/response correlation. Field numbering is sequential, types are appropriate, and protobuf's optional field handling ensures backward compatibility.
787-798: LGTM! Well-structured response message.The
HomeassistantActionResponsemessage follows best practices for request/response correlation:
- Proper message ID assignment (130)
- Correct SOURCE_CLIENT direction (response from Home Assistant)
call_idenables matching responses to requestssuccess+error_messagepattern supports clear error handlingno_delay=trueensures timely delivery
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
📒 Files selected for processing (1)
aioesphomeapi/client.py(5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
- Do not generate or add any sequence diagrams
Files:
aioesphomeapi/client.py
🧬 Code graph analysis (1)
aioesphomeapi/client.py (3)
aioesphomeapi/model.py (1)
HomeassistantActionResponse(1168-1174)aioesphomeapi/client_base.py (2)
on_home_assistant_action_request(88-92)_get_connection(363-371)aioesphomeapi/connection.py (1)
send_message(760-762)
🔇 Additional comments (4)
aioesphomeapi/client.py (4)
49-50: LGTM!The import of
HomeassistantActionResponseis correctly added to support the new public API method.
101-101: LGTM!The import of
on_home_assistant_action_requestaligns with the handler rename fromclient_base.pyand is used correctly in the subscription methods.
404-411: LGTM!The handler update to use
on_home_assistant_action_requestis correct. The partial application properly binds the callback, leavingmsgas the remaining parameter for the subscription mechanism.
943-982: LGTM!The combined subscription method correctly uses
on_home_assistant_action_requestat line 963, maintaining consistency with the rename throughout the codebase.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
What does this implement/fix?
Related PRs:
Types of changes
Related issue or feature (if applicable):
Pull request in esphome (if applicable):
Checklist:
tests/folder).