Can someone help me make this work?
Everything appears to run, no Errors reported; however, nothing works. Can't turn modules on/off, and no X10 Power Line or RF Activity is reported.
When sending commands, I get the same positive returns whether or not the CM15a is connected.
I have included the test project code below - please advise.
*********************************************************
' VBScript source code
Imports ActiveHomeScriptLib
Imports System
Public Class FishTankTestX10Heater
Dim WithEvents ActiveHomeObj As ActiveHome
'
'Valid/Supported Commands:
' ON: <X10 address (range A1 to P16)> on
' Examples: "sendplc", "a3 dim 75"
' "sendrf", "a1 on" (NOTE: refer to command constants in "Radio Frequency Command Reference"
' OFF: <X10 address> off
' DIM: <X10 address> dim <dim percentage of 100%)>
' BRIGHT: <X10 address> bright <bright percentage of 100%>
' All Lights ON: <X10 address (must include Unit Code)> alllightson
' All Units OFF: <X10 address (must include Unit Code)> allunitsoff
' Extended Code Command: <X10 address> <command> <value> (command and value specified in hex)
'
Private Sub FishTankTestX10Heater_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'create ActiveHome object
Try
ActiveHomeObj = CreateObject("X10.ActiveHome")
Catch exc As Exception
MsgBox("Initialize X10 err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'
Select Case SendPLCcmd("f1", "off")
Case Is = -1
MsgBox("PLC Command Failed")
Case Is = 1
MsgBox("PLC Command Succeeded")
End Select
Select Case SendPLCcmd("f1", "on")
Case Is = -1
MsgBox("PLC Command Failed")
Case Is = 1
MsgBox("PLC Command Succeeded")
End Select
Select Case SendPLCcmd("f1", "dim 50")
Case Is = -1
MsgBox("PLC Command Failed")
Case Is = 1
MsgBox("PLC Command Succeeded")
End Select
Select Case CheckOnSTATUS("f1")
Case Is = 0
MsgBox("OFF")
Case Is = 1
MsgBox("ON")
Case Is = -1
MsgBox("Status Unknown")
End Select
End Sub
'
Function SendPLCcmd(ByVal X10addr As String, ByVal X10cmd As String, Optional ByVal DimPcnt As String = "", Optional ByVal ExtdCmdVal As String = "") As Integer
'
'send a1 on
Try
ActiveHomeObj.SendAction("sendplc", X10addr & " " & X10cmd)
Catch exc As Exception
MsgBox("X10 PLC Command err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Return -1
Finally
End Try
'
Return 1
'
End Function
'
Function SendRFcmd(ByVal X10addr As String, ByVal X10cmd As String, Optional ByVal DimPcnt As String = "", Optional ByVal ExtdCmdVal As String = "") As Integer
'
'send a1 on
Try
ActiveHomeObj.SendAction("sendrf", "a1 on")
Catch exc As Exception
MsgBox("X10 RF Command err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'
End Function
'
Function CheckOnSTATUS(ByVal X10addr As String) As Integer
'
'"queryplc", "a1 on" Returns: 0 if Off, 1 if on, or -1 if not known
'
Dim DeviceOnStatus As Integer
'
DeviceOnStatus = ActiveHomeObj.SendAction("queryplc", X10addr & " on")
Select Case DeviceOnStatus
Case Is = -1 'ON Status NOT Known
Return DeviceOnStatus
Case Else
Return DeviceOnStatus
End Select
'
End Function
Function CheckDimSTATUS(ByVal X10addr As String) As Integer
'
'"queryplc", "a1 dim" Returns Percentage of Full Brightness, or -1 if not known
'
Dim DeviceDimStatus As Integer
'
DeviceDimStatus = ActiveHomeObj.SendAction("queryplc", X10addr & " dim")
Select Case DeviceDimStatus
Case Is = -1 'DIM Status NOT Known
Return DeviceDimStatus
Case Else
Return DeviceDimStatus
End Select
'
End Function
'events from ActiveHome: write out received event
Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
, ByVal vParm1 As Object _
, ByVal vParm2 As Object _
, ByVal vParm3 As Object _
, ByVal vParm4 As Object _
, ByVal vParm5 As Object _
, ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction
MsgBox("RecvAction: " & bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)
Dim _bszRecv As String = DirectCast(bszRecv, String)
Dim _DevAddr As String = DirectCast(vParm1, String)
Dim _Command As String = DirectCast(vParm2, String)
Dim _CmdData As String = DirectCast(vParm3, String)
Dim _rfTimeStamp As String = DirectCast(vParm4, String)
Dim _vParm5 As String = DirectCast(vParm5, String)
Dim _vReserved As String = DirectCast(vReserved, String)
Dim PercentDIM As Integer
Dim SysTimeStamp As DateTime = Now
Select Case _bszRecv
'
Case Is = "recvpld" 'From the Power Line
'
'"receive source", "X10 Address", "PLC command", "additional data"
'Like:
' A1 On = "recvplc", "a1", "on"
' B3 dimmed 30% = "recvplc", "e1", "dim", "30"
'
Select Case UCase(_DevAddr)
Case Is = "F1"
Select Case UCase(_Command)
Case Is = "ON"
Case Is = "OFF"
Case Is = "DIM"
PercentDIM = CInt(_CmdData) 'Whole Percent Only
End Select
End Select
Case Is = "recvrf" 'From an RF Device
'
'"receive source", "X10 Address", "RF command", "key status", "time stamp"
'Like:
'User Presess A2 On with a PalmPad
' 1st return: "recvrf", "a2", "On", "0", "timestamp"
' Followed by: "recrf", "a2", "On", "-1", "timestamp"
'
Select Case UCase(_DevAddr)
Case Is = "F1"
Select Case UCase(_Command)
Case Is = "ON"
Case Is = "OFF"
Case Is = "DIM"
PercentDIM = CInt(_CmdData) 'Whole Percent Only
End Select
End Select
End Select
'
End Sub
'
End Class