-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Run Pipeline methods to HASSWSApi
- Loading branch information
Showing
11 changed files
with
390 additions
and
1 deletion.
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
src/HassClient.Core/Models/Events/KnownPipelineEventTypes.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,68 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace HassClient.Models | ||
{ | ||
/// <summary> | ||
/// Collection of built-in pipeline event types. See <see href="https://developers.home-assistant.io/docs/voice/pipelines/#events"/>. | ||
/// </summary> | ||
public enum KnownPipelineEventTypes | ||
{ | ||
/// <summary> | ||
/// Used to represent a type not defined within this enum. | ||
/// </summary> | ||
Undefined = 0, | ||
|
||
/// <summary> | ||
/// Start of pipeline run. | ||
/// </summary> | ||
[EnumMember(Value = "run-start")] | ||
RunStart, | ||
|
||
/// <summary> | ||
/// End of pipeline run. | ||
/// </summary> | ||
[EnumMember(Value = "run-end")] | ||
RunEnd, | ||
|
||
/// <summary> | ||
/// Start of speech to text. | ||
/// </summary> | ||
[EnumMember(Value = "stt-start")] | ||
STTStart, | ||
|
||
/// <summary> | ||
/// End of speech to text. | ||
/// </summary> | ||
[EnumMember(Value = "stt-end")] | ||
STTEnd, | ||
|
||
/// <summary> | ||
/// Start of intent recognition. | ||
/// </summary> | ||
[EnumMember(Value = "intent-start")] | ||
IntentStart, | ||
|
||
/// <summary> | ||
/// End of intent recognition. | ||
/// </summary> | ||
[EnumMember(Value = "intent-end")] | ||
IntentEnd, | ||
|
||
/// <summary> | ||
/// Start of text to speech. | ||
/// </summary> | ||
[EnumMember(Value = "tts-start")] | ||
TTSStart, | ||
|
||
/// <summary> | ||
/// End of text to speech. | ||
/// </summary> | ||
[EnumMember(Value = "tts-end")] | ||
TTSEnd, | ||
|
||
/// <summary> | ||
/// Error in pipeline. | ||
/// </summary> | ||
Error, | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/HassClient.WS/Messages/Commands/Pipeline/IPipelineRunInput.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,9 @@ | ||
namespace HassClient.WS.Messages | ||
{ | ||
/// <summary> | ||
/// Represents a <see cref="PipelineRunMessage"/> input. | ||
/// </summary> | ||
internal interface IPipelineRunInput | ||
{ | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/HassClient.WS/Messages/Commands/Pipeline/PipelineRunMessage.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,49 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace HassClient.WS.Messages | ||
{ | ||
internal class PipelineRunMessage : BaseOutgoingMessage | ||
{ | ||
public PipelineRunMessage() | ||
: base("assist_pipeline/run") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The first stage to run. | ||
/// </summary> | ||
public StageTypes StartStage { get; set; } | ||
|
||
/// <summary> | ||
/// The last stage to run. | ||
/// </summary> | ||
public StageTypes EndStage { get; set; } | ||
|
||
/// <summary> | ||
/// Depends on <see cref="StartStage"/>. | ||
/// <para> | ||
/// For <see cref="StageTypes.STT"/>, it should be an <see cref="PipelineRunSampleRateInput"/>. | ||
/// </para> | ||
/// <para> | ||
/// For <see cref="StageTypes.Intent"/> and <see cref="StageTypes.TTS"/>, it should be an <see cref="PipelineRunTextInput"/>. | ||
/// </para> | ||
/// </summary> | ||
public IPipelineRunInput Input { get; set; } | ||
|
||
/// <summary> | ||
/// ID of the pipeline. | ||
/// </summary> | ||
public string Pipeline { get; set; } | ||
|
||
/// <summary> | ||
/// Unique id for conversation. <see href="https://developers.home-assistant.io/docs/intent_conversation_api#conversation-id"/>. | ||
/// </summary> | ||
public string ConversationId { get; set; } | ||
|
||
/// <summary> | ||
/// Number of seconds before pipeline times out (default: 30). | ||
/// </summary> | ||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] | ||
public float? Timeout { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/HassClient.WS/Messages/Commands/Pipeline/PipelineRunSampleRateInput.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,12 @@ | ||
namespace HassClient.WS.Messages | ||
{ | ||
internal class PipelineRunSampleRateInput : IPipelineRunInput | ||
{ | ||
public PipelineRunSampleRateInput(int sampleRate) | ||
{ | ||
this.SampleRate = sampleRate; | ||
} | ||
|
||
public int SampleRate { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/HassClient.WS/Messages/Commands/Pipeline/PipelineRunTextInput.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,12 @@ | ||
namespace HassClient.WS.Messages | ||
{ | ||
internal class PipelineRunTextInput : IPipelineRunInput | ||
{ | ||
public PipelineRunTextInput(string text) | ||
{ | ||
this.Text = text; | ||
} | ||
|
||
public string Text { get; set; } | ||
} | ||
} |
Oops, something went wrong.