Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove constructors that take client types from public HassModel API #1177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/HassModel/NetDeamon.HassModel/Internal/HassObjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,17 @@ public static EntityRegistration Map(this HassEntity hassEntity, IHaRegistryNavi
Device = device,
Labels = hassEntity.Labels.Select(registry.GetLabel).OfType<Label>().ToList(),
Platform = hassEntity.Platform,
Options = new EntityOptions(hassEntity.Options)
Options = hassEntity.Options?.Map()
};
}

private static EntityOptions Map(this HassEntityOptions entityOptions)
{
return new EntityOptions { ConversationOptions = entityOptions.Conversation?.Map() };
}

private static ConversationOptions Map(this HassEntityConversationOptions options)
{
return new ConversationOptions { ShouldExpose = options.ShouldExpose };
}
}
32 changes: 8 additions & 24 deletions src/HassModel/NetDeamon.HassModel/Registry/ConversationOptions.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
namespace NetDaemon.HassModel.Entities
namespace NetDaemon.HassModel.Entities;

/// <summary>
/// The options related to Assist/Conversation Assistants
/// </summary>
public record ConversationOptions
{
/// <summary>
/// The options related to Assist/Conversation Assistants
/// If the entity should be available to voice/ai assistants
/// </summary>
public record ConversationOptions
{
/// <summary>
/// If the entity should be available to voice/ai assistants
/// </summary>
public bool? ShouldExpose { get; init; }

/// <summary>
/// Default Constructor
/// </summary>
public ConversationOptions() { }

/// <summary>
/// Conversion from Websocket/API Model
/// </summary>
/// <param name="entityConversationOpts"></param>
public ConversationOptions(HassEntityConversationOptions entityConversationOpts)
{
ShouldExpose = entityConversationOpts.ShouldExpose;
}
}

public bool? ShouldExpose { get; init; }
}
13 changes: 0 additions & 13 deletions src/HassModel/NetDeamon.HassModel/Registry/EntityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,5 @@ public record EntityOptions
/// The Assist/Conversation options for a registration entity
/// </summary>
public ConversationOptions? ConversationOptions { get; init; }

/// <summary>
/// Conversion from Websocket/API Model
/// </summary>
/// <param name="entityOpts"></param>
public EntityOptions(HassEntityOptions? entityOpts)
{
if (entityOpts?.Conversation == null)
ConversationOptions = new ConversationOptions();
else
ConversationOptions = new ConversationOptions(entityOpts.Conversation);

}
}

Loading