Expose response data from service calls #890
Replies: 3 comments 1 reply
-
Yea I noticed and at some point I think we should support it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Bumping this, because I'd like to see this enhancement as well. (Forgive me if this is poor comment etiquette; I'm new here) Thanks for all the great work you are doing! |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is actually supported now. We just have not got the docs up and running for it. public async Task InitializeAsync(CancellationToken cancellationToken)
{
var result = await _ha.CallServiceWithResponseAsync("calendar", "list_events", ServiceTarget.FromEntity("calendar.cal"),
data: new { start_date_time = "2023-07-21 00:00:00", end_date_time = "2023-07-22 03:00:00"});
if (result is not null)
{
var events = result.Value.Deserialize<CalendarEvents>(_jsonOptions);
if (events is null)
_logger.LogWarning("No results!");
else
_logger.LogInformation("Events: {Events}", events);
}
} For the full sample: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hot off the presses, HA now allows service calls to return data. You pass it a variable name that you'd like to store the data in. Though ideally NetDaemon could return the data straight from CallService. This would be super handy to have!
https://www.home-assistant.io/docs/scripts/service-calls#use-templates-to-handle-response-data
Beta Was this translation helpful? Give feedback.
All reactions