Originally posted by jono
View Post
Here is the script that I ended up writing...
Code:
CONST Outlet_Device_HC = "U" CONST Outlet_Device_DC_Start = "1" CONST Outlet_Device_Count = "8" CONST SurgeURL = "132.111.1.230:80" CONST Username = "xxxxx" CONST Password = "xxxxx" Sub Main(parm as object) dim dv dim i as integer '*****************Create HomeSeer Devices if they do Not Exist************* For i = Outlet_Device_DC_Start to Outlet_Device_Count If hs.deviceexists(Outlet_Device_HC & i) = -1 then hs.writelog("SurgeControl", "Creating HomeSeer Devices") dv = hs.NewDeviceEx("Surge Outlet " & i) dv.hc = Outlet_Device_HC dv.dc = i dv.location2 = "Surge Control" dv.dev_type_string = "Surge Control" dv.misc = &h10 End if '*****************Add Buttons to HomeSeer Devices*************************** hs.DeviceButtonRemove(Outlet_Device_HC & i, "On") hs.DeviceButtonRemove(Outlet_Device_HC & i, "Off") hs.DeviceButtonRemove(Outlet_Device_HC & i, "Cycle") dim command command = i & "On" hs.DeviceButtonAdd(Outlet_Device_HC & i,"SurgeControl.vb(""OutletControl"",""" & Command & """)","On") command = i & "Off" hs.DeviceButtonAdd(Outlet_Device_HC & i,"SurgeControl.vb(""OutletControl"",""" & Command & """)","Off") command = i & "Pulse" hs.DeviceButtonAdd(Outlet_Device_HC & i,"SurgeControl.vb(""OutletControl"",""" & Command & """)","Cycle") Next End Sub sub OutletControl(parms as object) Dim Outlet_DC 'Device Code of the Outlet We are Controlling Dim Outlet_Command 'Command that we are sending Dim Debug as String 'Variable to Control Debug Setting ("On" / "Off") Outlet_DC = left(parms, 1) Outlet_Command = right(parms, len(parms)-1) Debug = "On" If Debug = "On" Then hs.writelog("SurgeControl", Outlet_DC) hs.writelog("SurgeControl", Outlet_Command) hs.writelog("SurgeControl", parms) End If Dim strAppPath Dim strEXEPath '*****************Get the Path to the UU.W32.exe Executable that controls the switch************* strAppPath = hs.GetAppPath If (Right(strAppPath, 1) <> "\") Then strAppPath = strAppPath & "\" strEXEPath = strAppPath & "UU.W32.exe" If Debug = "On" Then hs.writelog("SurgeControl", strEXEPath) End If '*****************Launch the UU.W32.exe Executable that controls the switch*********************** hs.Launch(strEXEPath, SurgeURL & " " & UserName & ":" & Password & " " & parms) hs.writelog("SurgeControl", "Outlet " & Outlet_DC & " " & Outlet_Command) If Debug = "On" Then hs.writelog("SurgeControl",SurgeURL & " " & UserName & ":" & Password & " " & parms) End If '*****************Update Device Status************************************************************ hs.writelog("SurgeControl", Outlet_Command) If Outlet_Command = "On" Then hs.writelog("SurgeControl", Outlet_Command & " - Got Here On") hs.setDeviceString(Outlet_Device_HC & Outlet_DC, "On") Else If Outlet_Command = "Off" Then hs.writelog("SurgeControl", Outlet_Command & " - Got Here Off") hs.setDeviceString(Outlet_Device_HC & Outlet_DC, "Off") End If hs.SetDeviceLastChange(Outlet_Device_HC & Outlet_DC, now()) End Sub
Also, I can't remember if I ever got the "Cycle" option to work...I don't think I did, but I also don't think it would be a huge deal to make it work.
I am not a developer, so this code is probably not the best

Good Luck!
If you can't find the executable, let me know.
Leave a comment: