-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose Entity Registration Conversation Options (#1167)
* add deserialization off entity conversation options * add conversation options to HassModel * add HassClient and HassModel test updates for conversation options * add Options handling to HassObjectMapper * remove unused constructor --------- Co-authored-by: Tomas Hellström <[email protected]>
- Loading branch information
1 parent
eb6227f
commit 4a090e9
Showing
10 changed files
with
160 additions
and
28 deletions.
There are no files selected for viewing
61 changes: 36 additions & 25 deletions
61
src/Client/NetDaemon.HassClient.Tests/Integration/Testdata/result_get_entities.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
{ | ||
"id": 3, | ||
"type": "result", | ||
"success": true, | ||
"result": [ | ||
{ | ||
"config_entry_id": null, | ||
"device_id": "42cdda32a2a3428e86c2e27699d79ead", | ||
"disabled_by": null, | ||
"entity_id": "media_player.tv_uppe2", | ||
"area_id": "42cdda1212a3428e86c2e27699d79ead", | ||
"name": null, | ||
"icon": null, | ||
"platform": "cast" | ||
}, | ||
{ | ||
"config_entry_id": "4b85129c61c74b27bd90e593f6b7482e", | ||
"device_id": "6e17380a6d2744d18045fe4f627db706", | ||
"disabled_by": null, | ||
"entity_id": "sensor.plex_plex", | ||
"name": null, | ||
"icon": null, | ||
"platform": "plex" | ||
} | ||
] | ||
} | ||
"id": 3, | ||
"type": "result", | ||
"success": true, | ||
"result": [ | ||
{ | ||
"config_entry_id": null, | ||
"device_id": "42cdda32a2a3428e86c2e27699d79ead", | ||
"disabled_by": null, | ||
"entity_id": "media_player.tv_uppe2", | ||
"area_id": "42cdda1212a3428e86c2e27699d79ead", | ||
"name": null, | ||
"icon": null, | ||
"platform": "cast", | ||
"options": { | ||
"conversation": { | ||
"should_expose": true | ||
} | ||
} | ||
|
||
}, | ||
{ | ||
"config_entry_id": "4b85129c61c74b27bd90e593f6b7482e", | ||
"device_id": "6e17380a6d2744d18045fe4f627db706", | ||
"disabled_by": null, | ||
"entity_id": "sensor.plex_plex", | ||
"name": null, | ||
"icon": null, | ||
"platform": "plex", | ||
"options": { | ||
"conversation": { | ||
"should_expose": false | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/HassConversationOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NetDaemon.Client.HomeAssistant.Model | ||
{ | ||
public record HassEntityConversationOptions | ||
{ | ||
[JsonPropertyName("should_expose")] public bool ShouldExpose { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/HassEntityOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NetDaemon.Client.HomeAssistant.Model | ||
{ | ||
public record HassEntityOptions | ||
{ | ||
[JsonPropertyName("conversation")] public HassEntityConversationOptions? Conversation { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/HassModel/NetDeamon.HassModel/Registry/ConversationOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace NetDaemon.HassModel.Entities | ||
{ | ||
/// <summary> | ||
/// The options related to Assist/Conversation 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; | ||
} | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/HassModel/NetDeamon.HassModel/Registry/EntityOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace NetDaemon.HassModel.Entities; | ||
|
||
/// <summary> | ||
/// Details of Options in the Home Assistant Registry | ||
/// </summary> | ||
public record EntityOptions | ||
{ | ||
/// <summary> | ||
/// 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); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters