From 1404844cfc5dde9404ed2f14ae1a9ecf510db404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Hellstr=C3=B6m?= Date: Sun, 29 Jan 2023 16:46:46 +0100 Subject: [PATCH 1/4] Support create input helper on IHomeAssistantConnection --- .../HomeAssistantConnectionHelpersExtensions.cs} | 6 ++---- .../Common/HomeAssistant/Model/InputBooleanHelper.cs} | 8 ++++---- .../Commands}/CreateInputBooleanHelperCommand.cs | 8 ++++---- .../Internal/AppStateManagerTests.cs | 3 +-- .../Internal/AppStateRepositoryTests.cs | 1 - src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj | 4 ++++ 6 files changed, 15 insertions(+), 15 deletions(-) rename src/{Runtime/NetDaemon.Runtime/Internal/HomeAssistantConnectionExtensions.cs => Client/NetDaemon.HassClient/Common/HomeAssistant/Extensions/HomeAssistantConnectionHelpersExtensions.cs} (90%) rename src/{Runtime/NetDaemon.Runtime/Internal/Model/HassHelper.cs => Client/NetDaemon.HassClient/Common/HomeAssistant/Model/InputBooleanHelper.cs} (53%) rename src/{Runtime/NetDaemon.Runtime/Internal/Model => Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands}/CreateInputBooleanHelperCommand.cs (69%) diff --git a/src/Runtime/NetDaemon.Runtime/Internal/HomeAssistantConnectionExtensions.cs b/src/Client/NetDaemon.HassClient/Common/HomeAssistant/Extensions/HomeAssistantConnectionHelpersExtensions.cs similarity index 90% rename from src/Runtime/NetDaemon.Runtime/Internal/HomeAssistantConnectionExtensions.cs rename to src/Client/NetDaemon.HassClient/Common/HomeAssistant/Extensions/HomeAssistantConnectionHelpersExtensions.cs index 2c775f87a..ddbd34fc2 100644 --- a/src/Runtime/NetDaemon.Runtime/Internal/HomeAssistantConnectionExtensions.cs +++ b/src/Client/NetDaemon.HassClient/Common/HomeAssistant/Extensions/HomeAssistantConnectionHelpersExtensions.cs @@ -1,8 +1,6 @@ -using NetDaemon.Runtime.Internal.Model; +namespace NetDaemon.Client.HomeAssistant.Extensions; -namespace NetDaemon.Runtime.Internal; - -internal static class HomeAssistantConnectionExtensions +public static class HomeAssistantConnectionHelpersExtensions { public static async Task CreateInputBooleanHelperAsync( this IHomeAssistantConnection connection, diff --git a/src/Runtime/NetDaemon.Runtime/Internal/Model/HassHelper.cs b/src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/InputBooleanHelper.cs similarity index 53% rename from src/Runtime/NetDaemon.Runtime/Internal/Model/HassHelper.cs rename to src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/InputBooleanHelper.cs index c945645e5..0850c8e53 100644 --- a/src/Runtime/NetDaemon.Runtime/Internal/Model/HassHelper.cs +++ b/src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/InputBooleanHelper.cs @@ -1,10 +1,10 @@ using System.Text.Json.Serialization; -namespace NetDaemon.Runtime.Internal.Model; +namespace NetDaemon.Client.HomeAssistant.Model; -internal record InputBooleanHelper +public record InputBooleanHelper { - [JsonPropertyName("name")] public string Name { get; init; } = string.Empty; + [JsonPropertyName("name")] public string Name { get; init; } = String.Empty; [JsonPropertyName("icon")] public string? Icon { get; init; } - [JsonPropertyName("id")] public string Id { get; init; } = string.Empty; + [JsonPropertyName("id")] public string Id { get; init; } = String.Empty; } \ No newline at end of file diff --git a/src/Runtime/NetDaemon.Runtime/Internal/Model/CreateInputBooleanHelperCommand.cs b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs similarity index 69% rename from src/Runtime/NetDaemon.Runtime/Internal/Model/CreateInputBooleanHelperCommand.cs rename to src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs index 3d8a60990..3959b463c 100644 --- a/src/Runtime/NetDaemon.Runtime/Internal/Model/CreateInputBooleanHelperCommand.cs +++ b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs @@ -1,9 +1,9 @@ using System.Text.Json.Serialization; using NetDaemon.Client.HomeAssistant.Model; -namespace NetDaemon.Runtime.Internal.Model; +namespace NetDaemon.Client.Internal.HomeAssistant.Commands; -internal record CreateInputBooleanHelperCommand : CommandMessage +public record CreateInputBooleanHelperCommand : CommandMessage { public CreateInputBooleanHelperCommand() { @@ -13,7 +13,7 @@ public CreateInputBooleanHelperCommand() [JsonPropertyName("name")] public string Name { get; init; } = string.Empty; } -internal record DeleteInputBooleanHelperCommand : CommandMessage +public record DeleteInputBooleanHelperCommand : CommandMessage { public DeleteInputBooleanHelperCommand() { @@ -23,7 +23,7 @@ public DeleteInputBooleanHelperCommand() [JsonPropertyName("input_boolean_id")] public string InputBooleanId { get; init; } = string.Empty; } -internal record ListInputBooleanHelperCommand : CommandMessage +public record ListInputBooleanHelperCommand : CommandMessage { public ListInputBooleanHelperCommand() { diff --git a/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateManagerTests.cs b/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateManagerTests.cs index eaa8553b3..fd9d61433 100644 --- a/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateManagerTests.cs +++ b/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateManagerTests.cs @@ -6,7 +6,6 @@ using NetDaemon.Client.Internal.Exceptions; using NetDaemon.HassModel; using NetDaemon.Runtime.Internal; -using NetDaemon.Runtime.Internal.Model; namespace NetDaemon.Runtime.Tests.Internal; @@ -109,7 +108,7 @@ public async Task TestGetStateAsyncNotExistReturnsCorrectStateEnabled() n.SendCommandAndReturnResponseAsync( It.IsAny(), It.IsAny())); haConnectionMock.Verify(n => - n.SendCommandAsync(It.IsAny(), + n.SendCommandAsync(It.IsAny(), It.IsAny())); } diff --git a/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateRepositoryTests.cs b/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateRepositoryTests.cs index 0a7ec8a4e..f006b32b2 100644 --- a/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateRepositoryTests.cs +++ b/src/Runtime/NetDaemon.Runtime.Tests/Internal/AppStateRepositoryTests.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Hosting; using NetDaemon.Client.Internal.Exceptions; using NetDaemon.Runtime.Internal; -using NetDaemon.Runtime.Internal.Model; namespace NetDaemon.Runtime.Tests.Internal; diff --git a/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj b/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj index f21b8571d..d9bf3dbd3 100644 --- a/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj +++ b/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj @@ -40,4 +40,8 @@ + + + + From a937d8bb5f2af13d11a16dedb9fc73d366afb5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Hellstr=C3=B6m?= Date: Sun, 29 Jan 2023 16:53:54 +0100 Subject: [PATCH 2/4] Remove the Model folder --- src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj b/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj index d9bf3dbd3..f21b8571d 100644 --- a/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj +++ b/src/Runtime/NetDaemon.Runtime/NetDaemon.Runtime.csproj @@ -40,8 +40,4 @@ - - - - From bd47e365993cad3a715c0f554777daa6ff02205e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Hellstr=C3=B6m?= Date: Tue, 31 Jan 2023 17:22:24 +0100 Subject: [PATCH 3/4] Fix public to internal for commands --- .../Commands/CreateInputBooleanHelperCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs index 3959b463c..52ffea4f5 100644 --- a/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs +++ b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs @@ -3,7 +3,7 @@ namespace NetDaemon.Client.Internal.HomeAssistant.Commands; -public record CreateInputBooleanHelperCommand : CommandMessage +internal record CreateInputBooleanHelperCommand : CommandMessage { public CreateInputBooleanHelperCommand() { @@ -13,7 +13,7 @@ public CreateInputBooleanHelperCommand() [JsonPropertyName("name")] public string Name { get; init; } = string.Empty; } -public record DeleteInputBooleanHelperCommand : CommandMessage +internal record DeleteInputBooleanHelperCommand : CommandMessage { public DeleteInputBooleanHelperCommand() { @@ -23,7 +23,7 @@ public DeleteInputBooleanHelperCommand() [JsonPropertyName("input_boolean_id")] public string InputBooleanId { get; init; } = string.Empty; } -public record ListInputBooleanHelperCommand : CommandMessage +internal record ListInputBooleanHelperCommand : CommandMessage { public ListInputBooleanHelperCommand() { From 5dc49a87e78627c16aa4043d6e3217052636e7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Hellstr=C3=B6m?= Date: Tue, 31 Jan 2023 18:28:13 +0100 Subject: [PATCH 4/4] Fix required keyword --- .../HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs index 52ffea4f5..758270374 100644 --- a/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs +++ b/src/Client/NetDaemon.HassClient/Internal/HomeAssistant/Commands/CreateInputBooleanHelperCommand.cs @@ -10,7 +10,7 @@ public CreateInputBooleanHelperCommand() Type = "input_boolean/create"; } - [JsonPropertyName("name")] public string Name { get; init; } = string.Empty; + [JsonPropertyName("name")] public required string Name { get; init; } } internal record DeleteInputBooleanHelperCommand : CommandMessage @@ -20,7 +20,7 @@ public DeleteInputBooleanHelperCommand() Type = "input_boolean/delete"; } - [JsonPropertyName("input_boolean_id")] public string InputBooleanId { get; init; } = string.Empty; + [JsonPropertyName("input_boolean_id")] public required string InputBooleanId { get; init; } = string.Empty; } internal record ListInputBooleanHelperCommand : CommandMessage