Skip to content

Commit

Permalink
Input helper support in Client (#831)
Browse files Browse the repository at this point in the history
* Support create input helper on IHomeAssistantConnection

* Remove the Model folder

* Fix public to internal for commands
  • Loading branch information
helto4real authored Jan 31, 2023
1 parent 172aa61 commit e30122f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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<InputBooleanHelper?> CreateInputBooleanHelperAsync(
this IHomeAssistantConnection connection,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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
{
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -109,7 +108,7 @@ public async Task TestGetStateAsyncNotExistReturnsCorrectStateEnabled()
n.SendCommandAndReturnResponseAsync<CreateInputBooleanHelperCommand, InputBooleanHelper>(
It.IsAny<CreateInputBooleanHelperCommand>(), It.IsAny<CancellationToken>()));
haConnectionMock.Verify(n =>
n.SendCommandAsync<CallServiceCommand>(It.IsAny<CallServiceCommand>(),
n.SendCommandAsync(It.IsAny<CallServiceCommand>(),
It.IsAny<CancellationToken>()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e30122f

Please sign in to comment.