Announcement

Collapse
No announcement yet.

vb/asp to control plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    vb/asp to control plugin

    In my asp pages that I use code like this for interacting with the HS2 plugin.

    hs.runex "alarmfunctions.vb", "armstay", "2" 'for partition 2
    hs.runex "alarmfunctions.vb", "disarm", "2" 'for partition 2

    hs.plugin("Vista Alarm").Armstay
    hs.plugin("Vista Alarm").ChimeMode
    hs.plugin("Vista Alarm").Disarm

    Contents of alarmfunctions.vb

    sub disarm(parms as object)
    dim partnum as integer
    partnum = cint(parms)
    hs.Plugin("Vista Alarm").disarm(partnum)
    end sub

    sub chimemode(parms as object)
    dim partnum as integer
    partnum = cint(parms)
    hs.Plugin("Vista Alarm").chimemode(partnum)
    end sub

    sub armstay(parms as object)
    dim partnum as integer
    partnum = cint(parms)
    hs.Plugin("Vista Alarm").armstay(partnum)
    end sub

    sub armaway(parms as object)
    dim partnum as integer
    partnum = cint(parms)
    hs.Plugin("Vista Alarm").armaway(partnum)
    end sub

    Does this port to HS3?

    -Rick
    -Rick

    #2
    you must use the hs.runpluginfunc to make calls the plugin now
    Mark

    HS3 Pro 3.0.0.534
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
    Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

    Comment


      #3
      -Rick

      Comment


        #4
        runex doesn't exist in hs3. use hs.runscriptfunc instead

        here is a pointer to hs3 scripting reference
        http://homeseer.com/support/homeseer...lp/default.htm
        Mark

        HS3 Pro 3.0.0.534
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
        Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

        Comment


          #5
          Mark,

          I am completely lost not having the background or skills to address my problem and have not made any discernable progress trying various permutations of your suggestions - all failing. So to try and get it working I have removed my feeble attempts in ASP and created a simple 4 line .vb script that I am trying to run from an event, figuring if I can get this example to work I can expand on it to solve my problems. It fails with errors that leave me without hope.

          Ps. I am happy to search for examples, but even that strikes out (feeling like an idiot) by using search terms like Example (Examples) or hs.pluginfunc in the Ademco forum doesn't seem to provide much so I can't even seem to do that right...

          Any help is greatly appreciated.

          -Rick

          This is the error that is written to the log:

          "Compiling script C:\Program Files\HomeSeer HS3\scripts\test.vb: Method arguments must be enclosed in parentheses.
          Feb-07 8:20:44 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\test.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."
          Attached Files
          -Rick

          Comment


            #6
            try the following in place of the runpluginfunc call

            hs.pluginfunction("vista alarm","","chimemode", new integer (){partnum})
            Mark

            HS3 Pro 3.0.0.534
            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
            Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

            Comment


              #7
              You mean like this? New Integer? Where would I find the values and how is it set?

              -r

              Error in log
              Feb-07 9:51:45 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\test.vb: Comma, ')', or a valid expression continuation expected.
              Feb-07 9:51:45 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\test.vb: Expression is not an array or a method, and cannot have an argument list.
              Feb-07 9:51:45 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\test.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
              Attached Files
              -Rick

              Comment


                #8
                Mark,

                I concluded that I don't have the ability to figure this out. The good news is I think I can do this with events, albeit a bit slower...

                -Rick
                -Rick

                Comment


                  #9
                  While I still don't have the ability to solve this on my own I did find a way. It's an easy way for us non-vb coders - not real technical types and it cheats by using tenScriptAid (it's a freebie tool though he does support Cystic Fibrosis Foundation and he suggests donations to them - what could be better give a few bucks to CSF and then get to parade around like a big dog with your coding greatness ) and from my perspective its a rocking powerful tool to build the syntax for CAPI control. You tell it (dropdown) the device and it builds the vb code/script you need. Then you just paste the code in your asp or script and wham, it works. Here is the CAPI code (the rest of the code surrounding the CAPI is my hackery and I can now control the alarm via the plugin without relying on events. this stub is the actions for the form post stuff so you can press a button and have the page do something.

                  Code:
                  	If Request.Form("sValA01") = "Arm Alarm" then  		'p1
                  		hs.CAPIControlHandler(hs.CAPIGetSingleControl(269,True,"Arm-Stay",False,False))
                  		AlarmBCp1("269")
                  	End If 
                  
                  	If Request.Form("sValA02") = "Arm Alarm" then   	'p2
                  		hs.CAPIControlHandler(hs.CAPIGetSingleControl(271,True,"Arm-Away",False,False))	
                  		AlarmBCp2("271")	
                  	End If 
                  
                  	If Request.Form("sValA03") = "Disarm Alarm" then	'p1
                  		hs.CAPIControlHandler(hs.CAPIGetSingleControl(269,True,"Disarm",False,False))
                  		AlarmBCp1("269")	
                  	End If 
                  
                  	If Request.Form("sValA04") = "Disarm Alarm" then	'p2
                  		hs.CAPIControlHandler(hs.CAPIGetSingleControl(271,True,"Disarm",False,False))
                  		AlarmBCp2("271")	
                  	End If 
                  
                  	If Request.Form("sValA05") = "Chime" Then'
                  		value = hs.DeviceValue("270")
                  			if value = 0 then 
                  				hs.CAPIControlHandler(hs.CAPIGetSingleControl(270,True,"On",False,False))
                  			Else
                  				hs.CAPIControlHandler(hs.CAPIGetSingleControl(270,True,"Off",False,False))  	
                  			end if 
                  	End if
                  
                  	If Request.Form("sValA06") = "Chime" Then
                  		value = hs.DeviceValue("272")
                  			if value = 0 then 
                  				hs.CAPIControlHandler(hs.CAPIGetSingleControl(272,True,"On",False,False))
                  			Else
                  				hs.CAPIControlHandler(hs.CAPIGetSingleControl(272,True,"Off",False,False))  	
                  	    	end if
                  	End If
                  Attached Files
                  -Rick

                  Comment


                    #10
                    Here's a simple asp page that arms the alarm using the devices the plugin creates:

                    Code:
                    <%
                    	'set the alarm to Arm Stay
                    
                    	devicename = "System Status"
                    	dvref = hs.GetDeviceRefByName(devicename)
                    
                    	hs.CAPIControlHandler(hs.CAPIGetSingleControl(dvref,true ,"Arm-Stay",false,true))
                    
                    	response.write "Setting alarm set to Armed Stay ..."
                    %>
                    This assumes you have no other devices called 'System Status' other than the one the plugin created. If you do, you need to include the Location of the device so the device name is unique.

                    You can use CAPI to send any other commands to the plugin as well (for example, Disarm, or Arm Stay) - just select the System Status device in HS3 and go to the 'Status Graphics' tab, and you'll see the value control pairs that correspond to the various alarm commands.

                    In HS3 CAPI is the best way to control devices because the nomenclature, while quite confusing, is standardized across every plugin.

                    Hope this is helpful.


                    EDIT: Sorry, after posting I saw you had already discovered CAPI (I didn't read your prior post carefully enough). I'll leave my example up, though, for someone looking for the simplest .asp page.

                    By the way - you can also easily arm the alarm on an asp page by setting up an event to trigger the alarm, and then having the asp page trigger the event using hs.TriggerEvent("Event name"). Both CAPI and event triggering are essentially instantaneous, and the latter doesn't rely on so much code.

                    Comment

                    Working...
                    X