Repository navigation
Use call_service with return_response for response-returning HA services - #1470
FrankBakkerNl with Copilot wants to merge 15 commits into
Conversation
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
call_service with return_response for response-returning HA services
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
helto4real
left a comment
There was a problem hiding this comment.
Requesting changes for one reproducible test failure on commit 8a2604066a9621e694eb598b5f619b8be47617ee.
[P2] Update the existing HassModel regression test for the new service command
CallServiceWithResponseAsync now sends CallServiceCommand, but AppScopedHaContextProviderTest.TestCallServiceWithResponseAsync still looks for a CallExecuteScriptCommand in the mock invocations. Its Single(...) call at src/HassModel/NetDaemon.HassModel.Tests/Internal/AppScopedHaContextProviderTest.cs:144 therefore throws InvalidOperationException: Sequence contains no matching element.
This reproduces locally and matches the failure in CI run 36135897430. Please update the test to assert CallServiceCommand, ReturnResponse == true, and correct forwarding of domain, service, service data, and target, retaining coverage of the IHaContext forwarding path. Then rerun the required CI checks.
Validation on the reviewed commit:
- Client tests: 172 passed.
- HassModel tests: 154 passed, 1 failed as described above.
- Selected calendar integration and helper tests: 7 passed, including execution against an isolated Home Assistant 2026.8.2 container.
I found no other blocking production-code issues in this review. The label check is also failing and needs to be addressed separately. Validation did not include an actual non-admin token, Home Assistant beta, or the full integration suite.
Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1470 +/- ##
====================================
- Coverage 83% 83% -1%
====================================
Files 201 201
Lines 4173 4164 -9
Branches 477 477
====================================
- Hits 3480 3466 -14
- Misses 496 501 +5
Partials 197 197
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
CallServiceWithResponseAsyncwas always routing through Home Assistant'sexecute_scriptwebsocket command, which requires admin privileges even when the underlying service does not. This change switches response-returning service calls to the nativecall_servicecommand withreturn_response: true, so non-admin tokens can use services such astodo.get_itemsandcalendar.get_eventswhen otherwise authorized.Protocol change
return_responseto the internalCallServiceCommandCallServiceWithResponseAsyncto send a plaincall_servicecommand instead of wrapping the call inexecute_scriptBehavior preservation
return_responseopt-in and omit it from normalcall_servicepayloads when unsetTest coverage
CancellationToken.Nonebranchcalendar.get_eventsreturn_responserequestsThis now emits a websocket
call_servicecommand equivalent to:{ "type": "call_service", "domain": "calendar", "service": "get_events", "service_data": { ... }, "target": { ... }, "return_response": true }