Skip to content

Commit

Permalink
Added SpeakerClient class sample implementation PSDK-64
Browse files Browse the repository at this point in the history
  • Loading branch information
rjhelmke committed Mar 29, 2020
1 parent 83fa7c6 commit a8aac30
Show file tree
Hide file tree
Showing 4 changed files with 350 additions and 6 deletions.
20 changes: 19 additions & 1 deletion HSPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace HSPI_HomeSeerSamplePlugin {
// ReSharper disable once InconsistentNaming
public class HSPI : AbstractPlugin, WriteLogSampleActionType.IWriteLogActionListener {

// Local vars

// speaker client instance
private SpeakerClient _speakerClient;

#region Properties

Expand Down Expand Up @@ -57,7 +61,7 @@ public class HSPI : AbstractPlugin, WriteLogSampleActionType.IWriteLogActionList

public HSPI() {
//Initialize the plugin

//Enable internal debug logging to console
LogDebug = true;
//Setup anything that needs to be configured before a connection to HomeSeer is established
Expand Down Expand Up @@ -186,6 +190,20 @@ protected override void Initialize() {
HomeSeerSystem.RegisterFeaturePage(Id, "sample-blank.html", "Sample Blank Page");
HomeSeerSystem.RegisterFeaturePage(Id, "sample-trigger-feature.html", "Trigger Feature Page");
HomeSeerSystem.RegisterDeviceIncPage(Id, "add-sample-device.html", "Add Sample Device");

// If a speaker client is needed that handles sending speech to an audio device, initialize that here.
// If you are supporting multiple speak devices such as multiple speakers, you would make this call
// in your reoutine that initializes each speaker device. Create a new instance of the speaker client
// for each speaker. We simply initalize one here as a sample implementation
_speakerClient = new SpeakerClient(Name);
// if the HS system has the setting "No password required for local subnet" enabled, the user/pass passed to Connect are ignored
// if the connection is from the local subnet, else the user/pass passed here are must exist as a user in the system
// You will need to allow the user to supply a user/pass in your plugin settings
// This functions connects your speaker client to the system. Your client will then appear as a speaker client in the system
// and can be selected as a target for speech and audio in event actions.
// When the system speaks to your client, your SpeakText function is called in SpeakerClient class
_speakerClient.Connect("default", "default");

Console.WriteLine("Initialized");
Status = PluginStatus.Ok();
}
Expand Down
8 changes: 4 additions & 4 deletions HomeSeerSamplePlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\HomeSeer\HomeSeer\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -66,9 +66,8 @@
<HintPath>packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PluginSdk, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\HomeSeer-PluginSDK.1.0.5\lib\net462\PluginSdk.dll</HintPath>
<Private>False</Private>
<Reference Include="PluginSdk">
<HintPath>..\HomeSeer\HomeSeer\bin\homeseer\PluginSdk.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -83,6 +82,7 @@
<Compile Include="Features\TriggerOptionItem.cs" />
<Compile Include="HSPI.cs" />
<Compile Include="SampleTriggerType.cs" />
<Compile Include="SpeakerClient.cs" />
<Compile Include="WriteLogSampleActionType.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class Program {
/// <summary>
/// The instance of the plugin class
/// </summary>
private static HSPI _plugin;
public static HSPI _plugin;

public static void Main(string[] args) {

Expand Down
Loading

0 comments on commit a8aac30

Please sign in to comment.