From 624017810f2f79f8a22d4689a61dd95ed0c68e09 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 25 Sep 2026 12:52:26 +0000 Subject: [PATCH 1/2] Initial plan From 5afedbd4813b012425d948403ae221e3dd694673 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 25 Sep 2026 12:54:18 +0000 Subject: [PATCH 2/2] Forward requested Home Assistant event type Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com> --- .../HomeAssistantConnectionTests.cs | 22 +++++++++++++++++++ .../Internal/HomeAssistantConnection.cs | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Client/NetDaemon.HassClient.Tests/HomeAssistantClientTest/HomeAssistantConnectionTests.cs b/src/Client/NetDaemon.HassClient.Tests/HomeAssistantClientTest/HomeAssistantConnectionTests.cs index d341a086a..a39982a74 100644 --- a/src/Client/NetDaemon.HassClient.Tests/HomeAssistantClientTest/HomeAssistantConnectionTests.cs +++ b/src/Client/NetDaemon.HassClient.Tests/HomeAssistantClientTest/HomeAssistantConnectionTests.cs @@ -75,6 +75,28 @@ public async Task UsingDisposedConnectionWhenPostApiShouldThrowException() await act.Should().ThrowAsync(); } + [Fact] + public async Task SubscribeToSpecificEventShouldSendRequestedEventType() + { + var pipeline = new TransportPipelineMock(); + SubscribeEventCommand? sentCommand = null; + pipeline + .Setup(n => n.SendMessageAsync(It.IsAny(), It.IsAny())) + .Returns((command, _) => + { + sentCommand = command; + pipeline.AddResponse(new HassMessage { Type = "result", Id = command.Id, Success = true }); + return Task.CompletedTask; + }); + + await using var homeAssistantConnection = CreateHomeAssistantConnection(pipeline); + + _ = await homeAssistantConnection.SubscribeToHomeAssistantEventsAsync("state_changed", CancellationToken.None); + + sentCommand.Should().NotBeNull(); + sentCommand!.EventType.Should().Be("state_changed"); + } + [Fact] public async Task HomeAssistantConnectionDisposedMultipleTimesShouldNotThrow() { diff --git a/src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs b/src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs index 3ba2643c1..304023dbf 100644 --- a/src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs +++ b/src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs @@ -83,7 +83,10 @@ private async Task> SubscribeToHomeAssistantEventsInterna _internalCancelSource.Token ); - var result = await SendCommandAndReturnHassMessageResponseAsync(new SubscribeEventCommand(), + var result = await SendCommandAndReturnHassMessageResponseAsync(new SubscribeEventCommand + { + EventType = eventType + }, combinedTokenSource.Token).ConfigureAwait(false); // The id if the message we used to subscribe should be used as the filter for the event messages