Interface IPlugin
public interface IPlugin
Namespace: HomeSeer.PluginSdk
Assembly: PluginSdk.dll
The core plugin interface used by HomeSeer to interact with third-party plugins.
The AbstractPlugin class provides a default implementation of this interface that should be used to develop plugins.
Properties
View SourceAccessLevel
Return the access level of this plug-in. Access level is the licensing mode. Use the integer value corresponding to the EAccessLevel for your plugin
Declaration
int AccessLevel { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ActionCount
The number of unique event actions the plugin supports
Declaration
int ActionCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
HasSettings
Whether the plugin has settings pages or not.
If this is TRUE, you must return valid JUI data in GetJuiSettingsPages()
Declaration
bool HasSettings { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Id
Unique ID for this plugin, needs to be unique for all plugins.
Do NOT use special characters or spaces in your plugin ID
Declaration
string Id { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The ID is used throughout the HomeSeer platform to target this plugin specifically via URL or internal code. It is recommended to use the name of your plugin, removing special characters and spaces, as the ID to make it easy to match them with one-another.
Name
The name of the plugin
Do NOT use special characters in your plugin name with the exception of "-", ".", and " " (space).
This is used to identify your plug-in to HomeSeer and your users. Keep the name to 16 characters or less.
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
SupportsConfigDevice
Whether this plugin supports a device configuration page for devices created/managed by it
TRUE will cause HomeSeer to call GetJuiDeviceConfigPage() for devices this plugin manages. FALSE means HomeSeer will not call GetJuiDeviceConfigPage() for any devices
Declaration
bool SupportsConfigDevice { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportsConfigDeviceAll
Whether this plugin supports a device configuration page for all devices
TRUE will cause HomeSeer to call GetJuiDeviceConfigPage() for every device. FALSE means HomeSeer will not call GetJuiDeviceConfigPage() for all devices
Declaration
bool SupportsConfigDeviceAll { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportsConfigFeature
Whether this plugin supports a feature configuration page for features created/managed by it
TRUE will cause HomeSeer to call GetJuiDeviceConfigPage() for features this plugin manages. FALSE means HomeSeer will not call GetJuiDeviceConfigPage() for any features
Declaration
bool SupportsConfigFeature { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Setting this to TRUE allows you to display a unique page for each feature instead of using a single page for the device and all of its features.
TriggerCount
The number of unique event triggers the plugin supports
Declaration
int TriggerCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
View SourceActionBuildUI(TrigActInfo)
Called by the HomeSeer system when an event is in edit mode and in need of HTML controls for the user.
Declaration
string ActionBuildUI(TrigActInfo actInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | actInfo | Object that contains information about the action like current selections. |
Returns
Type | Description |
---|---|
System.String | HTML controls that need to be displayed so the user can select the action parameters. |
ActionConfigured(TrigActInfo)
Called by the HomeSeer system to verify that the configuration is valid and can be saved
Declaration
bool ActionConfigured(TrigActInfo actInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | actInfo | Object describing the action. |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the given action is configured properly; FALSE if the action shouldn't be saved |
ActionFormatUI(TrigActInfo)
Called by the HomeSeer system when an event action is finished being configured and needs to be displayed in an easy to read format.
Declaration
string ActionFormatUI(TrigActInfo actInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | actInfo | Object that contains information about the current configuration of the trigger. |
Returns
Type | Description |
---|---|
System.String | HTML representing easy to read text describing the action |
ActionProcessPostUI(Dictionary<String, String>, TrigActInfo)
Called by the HomeSeer system to process selections when a user edits your event actions.
Declaration
EventUpdateReturnData ActionProcessPostUI(Dictionary<string, string> postData, TrigActInfo trigInfoIn)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | postData | A collection of name value pairs that include the user's selections. |
TrigActInfo | trigInfoIn | Object that contains information about the action. |
Returns
Type | Description |
---|---|
EventUpdateReturnData | Object the holds the parsed information for the action. HomeSeer will save this information for you in the database. |
ActionReferencesDevice(TrigActInfo, Int32)
Called by the HomeSeer system to determine if a specified device is referenced by a certain action.
Declaration
bool ActionReferencesDevice(TrigActInfo actInfo, int devRef)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | actInfo | Object describing the action. |
System.Int32 | devRef | The reference ID of the device to check |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the action references the device; FALSE if it does not |
GetActionNameByNumber(Int32)
Return the name of the action given an action number
The name of the action will be displayed in the HomeSeer events actions list.
Declaration
string GetActionNameByNumber(int actionNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | actionNum | The number of the action to get the name for |
Returns
Type | Description |
---|---|
System.String | The name of the action associated with the action number |
GetJuiDeviceConfigPage(Int32)
Called by the HomeSeer software to obtain a HS-JUI device or feature configuration page for a specific device or feature
Declaration
string GetJuiDeviceConfigPage(int devOrFeatRef)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | devOrFeatRef | The device or feature reference to get the page for |
Returns
Type | Description |
---|---|
System.String | A JSON serialized Jui.Page |
GetJuiSettingsPages()
Called by the HomeSeer software to obtain a list of settings pages
Declaration
string GetJuiSettingsPages()
Returns
Type | Description |
---|---|
System.String | A SettingsCollection serialized to a JSON string |
GetSubTriggerCount(Int32)
Returns the number of sub triggers the plugin supports for the specified trigger number
Declaration
int GetSubTriggerCount(int triggerNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | triggerNum | The number of the trigger to check |
Returns
Type | Description |
---|---|
System.Int32 | The number of sub triggers the specified trigger number supports |
GetSubTriggerNameByNumber(Int32, Int32)
The name of the sub trigger with the specified number of the trigger with the specified number
Declaration
string GetSubTriggerNameByNumber(int triggerNum, int subTriggerNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | triggerNum | The number of the trigger to check |
System.Int32 | subTriggerNum | The number of the sub trigger to check |
Returns
Type | Description |
---|---|
System.String | The name of the sub trigger |
GetTriggerNameByNumber(Int32)
Return the name of the given trigger based on the specified trigger number
Declaration
string GetTriggerNameByNumber(int triggerNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | triggerNum | The trigger number to get the name for |
Returns
Type | Description |
---|---|
System.String | The name of the trigger |
HandleAction(TrigActInfo)
Called by the HomeSeer system when an event is triggered and the plugin needs to carry out a specific action.
Declaration
bool HandleAction(TrigActInfo actInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | actInfo | Object describing the trigger and action. |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the action was executed successfully; FALSE if there was an error |
HasJuiDeviceConfigPage(Int32)
Called by HomeSeer Core to determine if a device or feature configuration page is available for a particular device or feature. Only called if SupportsConfigDevice or SupportsConfigFeature or SupportsConfigDeviceAll is set to TRUE.
Declaration
bool HasJuiDeviceConfigPage(int devOrFeatRef)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | devOrFeatRef | The Ref of the device |
Returns
Type | Description |
---|---|
System.Boolean | True if there is a page available, false if not. Returning True will cause HomeSeer Core to call GetJuiDeviceConfigPage(Int32) for the device or feature |
HsEvent(Constants.HSEvent, Object[])
When you wish to have HomeSeer call back in to your plug-in or application when certain events
happen in the system, call the RegisterEventCB procedure and provide it with event you wish to monitor.
See RegisterEventCB for more information and an example and event types.
The parameters are passed in an array of objects. Each entry in the array is a parameter. The number of entries depends on the type of event and are described below. The event type is always present in the first entry or params(0).
Declaration
void HsEvent(Constants.HSEvent eventType, object[] params)
Parameters
Type | Name | Description |
---|---|---|
Constants.HSEvent | eventType | The type of event that has occurred |
System.Object[] | params | The data associated with the event |
InitIO()
Called by the HomeSeer system to initialize the plugin.
This is the primary entry point for all plugins. Start the plugin and get it ready for use.
Declaration
bool InitIO()
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the plugin started successfully; FALSE if it did not You should opt for throwing an exception that contains a detailed messaged over returning FALSE whenever possible. |
IsTriggerConfigValid(TrigActInfo)
Given a TrigActInfo object, detect if this trigger is configured properly
Declaration
bool IsTriggerConfigValid(TrigActInfo trigInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | trigInfo | The trigger info to validate |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the trigger is configured properly, FALSE otherwise |
OnStatusCheck()
Called by the HomeSeer system to determine the status of the plugin.
Declaration
PluginStatus OnStatusCheck()
Returns
Type | Description |
---|---|
PluginStatus | A PluginStatus object describing the state of the plugin |
See Also
View SourcePluginFunction(String, Object[])
Called by the HomeSeer system to run a plugin function by name using reflection
Declaration
object PluginFunction(string procName, object[] params)
Parameters
Type | Name | Description |
---|---|---|
System.String | procName | The name of the method to execute |
System.Object[] | params | The parameters to execute the method with |
Returns
Type | Description |
---|---|
System.Object | The result of the method execution |
PluginPropertyGet(String)
Called by the HomeSeer system to get the value of a property by name using reflection
Declaration
object PluginPropertyGet(string propName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propName | The name of the property |
Returns
Type | Description |
---|---|
System.Object | The value of the property |
PluginPropertySet(String, Object)
Called by the HomeSeer system to set the value of a property by name using reflection
Declaration
void PluginPropertySet(string propName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propName | The name of the property |
System.Object | value | The new value of the property |
PostBackProc(String, String, String, Int32)
Called by the HomeSeer system when a page owned by this plugin receives an HTTP POST request
Declaration
string PostBackProc(string page, string data, string user, int userRights)
Parameters
Type | Name | Description |
---|---|---|
System.String | page | The page that received the POST request |
System.String | data | The data included in the request |
System.String | user | The user responsible for initiating the request |
System.Int32 | userRights | The user's rights |
Returns
Type | Description |
---|---|
System.String | A string of data that is returned to the requester |
SaveJuiDeviceConfigPage(String, Int32)
Save updated values for a HS-JUI formatted device or feature config page
Declaration
bool SaveJuiDeviceConfigPage(string pageContent, int devOrFeatRef)
Parameters
Type | Name | Description |
---|---|---|
System.String | pageContent | A JSON serialized Jui.Page describing what has changed about the page |
System.Int32 | devOrFeatRef | The reference of the device or feature the config page is for |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the save was successful; FALSE if it was unsuccessful. An exception should be thrown with details about the error if it was unsuccessful |
SaveJuiSettingsPages(String)
Called by the HomeSeer system when settings changes need to be saved
Declaration
bool SaveJuiSettingsPages(string jsonString)
Parameters
Type | Name | Description |
---|---|---|
System.String | jsonString | A List of Jui.Pages containing views that have changed, serialized as JSON |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the save was successful; FALSE if it was unsuccessful. An exception should be thrown with details about the error if it was unsuccessful |
SetIOMulti(List<ControlEvent>)
Called by the HomeSeer system when a device that this plugin owns is controlled.
A plugin owns a device when its Interface property is set to the plugin ID.
Declaration
void SetIOMulti(List<ControlEvent> controlEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<ControlEvent> | controlEvents | A collection of ControlEvent objects, one for each device being controlled |
ShutdownIO()
Called by the HomeSeer system to shutdown the plugin and its operations
Declaration
void ShutdownIO()
SpeakIn(Int32, String, Boolean, String)
If your plug-in is registered as a Speak proxy plug-in, then when HomeSeer is asked to speak something. It will pass the speak information to your plug-in using this procedure. When your plug-in is ready to do the actual speaking, it should call SpeakProxy, and pass the information that it got from this procedure to SpeakProxy. It may be necessary or a feature of your plug-in to modify the text being spoken or the host/instance list provided in the host parameter - this is acceptable.
Declaration
void SpeakIn(int speechDevice, string spokenText, bool wait, string host)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | speechDevice | This is the device that is to be used for the speaking. In older versions of HomeSeer, this value was used to indicate the sound card to use, and if it was over 100, then it indicated that it was speaking for HomeSeer Phone (device - 100 = phone line), or the WAV audio device to use. Although this is still used for HomeSeer Phone, speaks for HomeSeer phone are never proxied and so values >= 100 should never been seen in the device parameter. Pass the device parameter unchanged to SpeakProxy. |
System.String | spokenText | This is the text to be spoken, or if it is a WAV file to be played, then the characters ":" will be found starting at position 2 of the string as playing a WAV file with the speak command in HomeSeer REQUIRES a fully qualified path and filename of the WAV file to play. |
System.Boolean | wait | This parameter tells HomeSeer whether to continue processing commands immediately or to wait until the speak command is finished - pass this parameter unchanged to SpeakProxy. |
System.String | host | This is a list of host:instances to speak or play the WAV file on. An empty string or a single asterisk (*) indicates all connected speaker clients on all hosts. Normally this parameter is passed to SpeakProxy unchanged. |
Remarks
PLEASE NOTE: Code related to the Speech components in HomeSeer were ported from the HS3 plugin API and have not been fully tested to verify full functionality from the new SDK. The Speech API may undergo significant changes in the near future. Please use with caution.
TriggerBuildUI(TrigActInfo)
Called by the HomeSeer system when an event is in edit mode and in need of HTML controls for the user.
Declaration
string TriggerBuildUI(TrigActInfo trigInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | trigInfo | Object that contains information about the current configuration of the trigger. |
Returns
Type | Description |
---|---|
System.String | HTML controls that need to be displayed so the user can select the trigger parameters. |
TriggerCanBeCondition(Int32)
Called by HomeSeer to determine if a given trigger can also be used as a condition
Declaration
bool TriggerCanBeCondition(int triggerNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | triggerNum | The number of the trigger to check |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the given trigger can also be used as a condition, for the given trigger number. |
TriggerFormatUI(TrigActInfo)
Called by the HomeSeer system when an event trigger is finished being configured and needs to be displayed in an easy to read format.
Declaration
string TriggerFormatUI(TrigActInfo trigInfo)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | trigInfo | Object that contains information about the current configuration of the trigger. |
Returns
Type | Description |
---|---|
System.String | HTML representing easy to read text describing the trigger |
TriggerProcessPostUI(Dictionary<String, String>, TrigActInfo)
Called by the HomeSeer system to process selections when a user edits your event triggers.
Declaration
EventUpdateReturnData TriggerProcessPostUI(Dictionary<string, string> postData, TrigActInfo trigInfoIn)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | postData | A collection of name value pairs that include the user's selections. |
TrigActInfo | trigInfoIn | Object that contains information about the trigger. |
Returns
Type | Description |
---|---|
EventUpdateReturnData | Object the holds the parsed information for the trigger. HomeSeer will save this information for you in the database. |
TriggerReferencesDeviceOrFeature(TrigActInfo, Int32)
Called by the HomeSeer system to determine if a specified device is referenced by a certain trigger.
Declaration
bool TriggerReferencesDeviceOrFeature(TrigActInfo trigInfo, int devOrFeatRef)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | trigInfo | Object describing the trigger. |
System.Int32 | devOrFeatRef | The reference ID of the device or feature to check |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the trigger references the device; FALSE if it does not |
TriggerTrue(TrigActInfo, Boolean)
Called by HomeSeer when a trigger needs to be evaluated as a condition
Declaration
bool TriggerTrue(TrigActInfo trigInfo, bool isCondition = false)
Parameters
Type | Name | Description |
---|---|---|
TrigActInfo | trigInfo | Object describing the trigger |
System.Boolean | isCondition | TRUE if the trigger represents a condition, FALSE if it is a trigger |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the conditions are met; FALSE if they are not |
UpdateStatusNow(Int32)
Called by the HomeSeer system when it needs the current status for a device/feature owned by the plugin.
This should force the device/feature to update its current status on HomeSeer.
Declaration
EPollResponse UpdateStatusNow(int devOrFeatRef)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | devOrFeatRef | The reference ID of the device/feature to poll |
Returns
Type | Description |
---|---|
EPollResponse | An EPollResponse describing the result of the request |