If you want to send X10 commands over the power line from within a script, the 'old' ExecX10() plugin function is still available. However, you cannot access it using hs.ExecX10() as many of you have discovered and you must make a special call to the plugin to access it. Below is the info you'll need to use this. I've also included a simple VB.Net 'script' that will send Preset Dim commands when called from an event that you can easily modify for your needs.
Note: using the scripting interface simply sends the X10 command to your hardware interface to be transmitted onto the power line. It DOES NOT update devices in HS nor will it trigger events.
****** OLD (PRE-HS3) method of calling ExecX10() ******
****** NEW HS3 method of calling ExecX10() ******
Format of call:
Parameters for plugin function 'ExecX10':
Here is an example of sending Preset Dim commands:
Here's how to quickly save this as a new script in HS:
****** NEW HS3 method of calling ExecX10() ******
Format of call:
PluginFunction("ExecX10", {parameters})
VERY IMPORTANT: parameters must be enclosed in {} and separated by commas!
Parameters for plugin function 'ExecX10':
Code As string
Command As string
DimVal As String
ExtCmd As String
ExtData As String
Notes:
You can easily expand or change the script to send other commands, I just wanted to demonstrate sending preset dims.
Give it a try and let me know how you fare.
Note: using the scripting interface simply sends the X10 command to your hardware interface to be transmitted onto the power line. It DOES NOT update devices in HS nor will it trigger events.
****** OLD (PRE-HS3) method of calling ExecX10() ******
Code:
Dim Code As String = "B2" ' Device Code - a string of devices like "A1" or "A1+2+3+9". Dim Cmd As String = "On" ' Command - the name of the command as a string. Dim DimVal As Integer = 0 ' Dim Value - (optional) This is the % dim for "Dim" and "Bright" commands. For the "Pre-set Dim" command, this is a value between 0 and 31. Dim Data2 As Integer = 0 ' Data2 - (optional) This is the second data byte for the "Extended" X10 command. The dimval parameter is the first data byte if the command is "Extended". Dim Wait As Boolean = False ' Wait - (optional) If TRUE, the command will not return until after the X10 command has actually been sent on the power line. hs.ExecX10(code, cmd, dimval, data2, wait)
****** NEW HS3 method of calling ExecX10() ******
Valid ONLY for the "X10" Plugin! See below for CM15a for Windows.
Code:
Dim Code As String = "B2" ' Device Code Dim Cmd As String = "On" ' Command Dim DimVal As Integer = 0 ' Dim % Dim Data2 As Integer = 0 ' Extended data or Preset Dim % (non-standard) Dim Wait As Boolean = False ' Always set to FALSE!! Dim sRet As String ' Create an object that references the X10 plugin Dim X10plugin as HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "X10","") ' Call the ExecX10() function within the plugin Sret = X10plugin.PluginFunction("ExecX10",{Code,Cmd,DimVal,Data2,Wait})
PluginFunction("ExecX10", {parameters})
VERY IMPORTANT: parameters must be enclosed in {} and separated by commas!
VERY IMPORTANT: parameters must be enclosed in {} and separated by commas!
Parameters for plugin function 'ExecX10':
Code As string
Command As string
DimVal As Integer
Data2 As Integer
Wait As Boolean
Notes:
Command As string
DimVal As Integer
Data2 As Integer
Wait As Boolean
Notes:
- These parameters are the same as the old HS2 version EXCEPT when commanding a Preset Dim.
- Dim values for Preset Dim commands are passed to the plugin as Data2 and NOT as DimVal.
- Dim values for Preset Dim commands are specified as 0-100 (% dim) rather than the standard 0-31.
Here is an example of sending Preset Dim commands:
Code:
'-------------------------------- ' Send X10 Preset Dim commands on the powerline using the X10 plugin. ' Specify Main as the "Sub or Function" and enter the X10 code and Preset Dim level (in the range 0-31) separated by a comma for "Parameters". Sub Main(parm as object) Dim X10plugin as HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "X10","") Dim sRet As String Dim sTemp() as String = Split(Parm, ",") Dim Code as String = Trim(sTemp(0)) Dim Pdim As Integer = Cint(sTemp(1)) Dim DimPercent As Integer If Pdim <= 31 And Pdim >= 0 Then DimPercent = Pdim * 100 / 31 ' PluginFunction(Function to call [as string], parameters [as object]) ' Parameters for ExecX10: ' X10 Code As string ' such as "B2" ' X10 Command As string ' "preset dim" ' DimVal As Integer (0-100) ' dim % for standard X10 devices ' Data2 As Integer (0-100) ' dim % for preset dim ' Wait As Boolean ' always use False ' Important: parameters must be enclosed in {} and separated by commas! sRet = X10plugin.PluginFunction("ExecX10",{Code,"preset dim",0,DimPercent,False}) hs.WriteLog("X10 Plugin", "X10 plugin response: " & sRet) Else hs.WriteLog("X10 Plugin Error", "Preset dim value provided is outside the range 0 - 31") End If End Sub '--------------------------------
- Create a new event in HS and select a trigger of your choice.
- Select "Run a Script or Script Command" for the action.
- Click the Edit button next to "Choose or change the script file to run:"
- At the end of path in the "address bar" (very top of "Select a script file." dialog), add the name for this script. Perhaps X10pdim.vb. Mine reads like this: C:/Program Files (x86)/HomeSeer HS3/scripts/X10pdim.vb
- Click Submit.
- Expand the event action line (yellow arrow on the right).
- Copy the script code above.
- Paste the code into the "Script:" box
- Click "Save Script Edits"
- Enter Main (no quotes) in the "Sub or Function:" box
- Enter the X10 code for the device you want to address, a comma, and then the preset dim level you want to send (in the range 0-31). Here's an example for device B3 at Pdim 12: B3,12 (again, no quotes)
- Click the test button for the event (blue arrow up on the event line).
- Verify code is sent.
****** NEW HS3 method of calling ExecX10() ******
Valid ONLY for CM15a Plugin for Windows! (Added 04Jan2020)
Code:
[SIZE=12px][FONT=courier new][COLOR=#000000]Dim Code As String = "B2" ' Device Code[/COLOR] [COLOR=#000000]Dim Cmd As String = "On" ' X10 Command[/COLOR] [COLOR=#000000]Dim DimVal As String = "0" ' For standard dims, in % dim (0-100)[/COLOR] [COLOR=#000000]Dim ExtCmd As String = "32" ' Extended X10 Command byte, as a hex string ("00" - "FF"), both upper and lower case are accepted.[/COLOR] [COLOR=#000000]Dim ExtData As String = "9F" ' [/COLOR][COLOR=#000000]Extended X10 Data byte, as a hex string ("00" - "FF"), both upper and lower case are accepted.[/COLOR] [COLOR=#000000]Dim sRet As String[/COLOR][/FONT][/SIZE] [SIZE=12px][FONT=courier new][COLOR=#000000]' Create an object that references the X10 plugin[/COLOR][/FONT][/SIZE] [LEFT][SIZE=12px][FONT=courier new][COLOR=#000000]Dim CM15aPlugin as HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "CM15A","")[/COLOR][/FONT][/SIZE][/LEFT] [LEFT][SIZE=12px][FONT=courier new][COLOR=#000000]' Call the ExecX10() function within the plugin[/COLOR] [COLOR=#000000]Sret = X10plugin.PluginFunction("ExecX10",{Code,Cmd,DimVal,ExtCmd,ExtData})[/COLOR][/FONT][/SIZE][/LEFT]
Format of call:
PluginFunction("ExecX10", {parameters})
VERY IMPORTANT: parameters must be enclosed in {} and separated by commas!
Parameters for plugin function 'ExecX10':
Code As string
Command As string
DimVal As String
ExtCmd As String
ExtData As String
Notes:
- These parameters are the same as the old HS2 version EXCEPT the last 2 parameters, ExtCmd & ExtData, are for extended X10 commands only and are entered as hex strings.
You can easily expand or change the script to send other commands, I just wanted to demonstrate sending preset dims.
Give it a try and let me know how you fare.
Comment