Announcement

Collapse
No announcement yet.

Session 3 - Tuesday, January 19th, 2010, 8:30PM EST - Topic: Scripts

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

  • #31
    Rick,

    Thanks for the webinar, it was excellent!

    Quick question: At one point you showed CreateVar / SaveVar / GetVar being used in a vbscript example to hold a COM port number.

    Is there any use for these "Var" functions in a VB.NET script, or can one simply declare ordinary global variables instead (i.e., assuming that the variables will retain their values across script executions since the VB.NET script remains in memory after compilation)?

    Thanks,
    Don

    Comment


    • #32
      Originally posted by dschoppe View Post
      Rick,

      Thanks for the webinar, it was excellent!

      Quick question: At one point you showed CreateVar / SaveVar / GetVar being used in a vbscript example to hold a COM port number.

      Is there any use for these "Var" functions in a VB.NET script, or can one simply declare ordinary global variables instead (i.e., assuming that the variables will retain their values across script executions since the VB.NET script remains in memory after compilation)?

      Thanks,
      Don
      Glad you enjoyed it.

      You can use those same variables in VB.NET scripts without any problems or changes. Global variables in any script are global to all procedures (subs and functions) within that script, and are lost when the script ends. The HomeSeer global variables are stored within HomeSeer though, so that is why they are quite beneficial - they are retained as long as HomeSeer is running, and can be accessed by scripts or plug-ins. The HomeSeer global variables are objects, which is the near equivalent to variants in VBScript, and can hold pretty much anything - strings, integers, other objects, etc.
      Regards,

      Rick Tinker (a.k.a. "Tink")

      Comment


      • #33
        Originally posted by tenholde View Post
        Would you consider touching on the use of tenScripting for .net script development?

        http://www.tenholder.net/tenWare2/tenScripting

        tenholde
        There were some people expecting/hoping that we would teach them the scripting languages, and others with much more complicated/advanced questions, so the experience level ran the gamut. Thus, I felt it was better not to confuse people by showing a lot of different development environments - I pretty much used only notepad and VBSEdit just for purposes of color coding.

        However, I mentioned tenScripting and a couple of other scripting editors, and I have had a chance to look at the tenScripting package. While it would be beneficial to beginners to have a link to the free Visual Studio Express package as the dev system to use with tenScripting, it does look like a very nice system for working with scripts. The best feature though is the quick link to donate to Cystic Fibrosis foundation.
        Regards,

        Rick Tinker (a.k.a. "Tink")

        Comment


        • #34
          Originally posted by Rick Tinker View Post
          Glad you enjoyed it.

          You can use those same variables in VB.NET scripts without any problems or changes. Global variables in any script are global to all procedures (subs and functions) within that script, and are lost when the script ends. The HomeSeer global variables are stored within HomeSeer though, so that is why they are quite beneficial - they are retained as long as HomeSeer is running, and can be accessed by scripts or plug-ins. The HomeSeer global variables are objects, which is the near equivalent to variants in VBScript, and can hold pretty much anything - strings, integers, other objects, etc.
          Rick,

          It's interesting that this seems to work fine without the use of SaveVar() and GetVar(). Note how the count increases each time I run the event. I assume this is because the garbage collector hasn't reclaimed memory, and I'm rerunning the same instance of the script?

          Thanks,
          Don

          Script:
          Code:
          Public count As Integer = 0
          
          Public Sub IncrementGlobalAndPrint(ByVal param As Object)
              count = count + 1
              hs.WriteLog("Debug", "count is " & count)
          End Sub
          Log:
          Code:
          1/21/2010 7:21:35 PM  Event  Event Trigger "TestGlobalData" 
          1/21/2010 7:21:35 PM  Event  Running script in background: hsutil.vb("IncrementGlobalAndPrint","") 
          1/21/2010 7:21:35 PM  Debug  count is 1 
          1/21/2010 7:21:40 PM  Event  Event Trigger "TestGlobalData" 
          1/21/2010 7:21:40 PM  Event  Running script in background: hsutil.vb("IncrementGlobalAndPrint","") 
          1/21/2010 7:21:40 PM  Debug  count is 2
          Manual Event:
          Attached Files

          Comment


          • #35
            Originally posted by dschoppe View Post
            Rick,

            It's interesting that this seems to work fine without the use of SaveVar() and GetVar(). Note how the count increases each time I run the event. I assume this is because the garbage collector hasn't reclaimed memory, and I'm rerunning the same instance of the script?

            Thanks,
            Don
            Not because of garbage collection, but because of .NET - in the webinar I mentioned that VB.NET scripts when they are run for the first time are compiled, and then kept in memory - until HomeSeer is shut down! When the script is done running, it goes into an idle state, but it is still as if it were running in memory, hence all of the variables are kept in-tact, which is what you are seeing.

            However, you do not want to count on this as a way of keeping variables because as I also mentioned, if you make a change to your script and then run it, the old copy in memory is left there but the system starts using the new copy, which means that the variables are all reset. So, using the HomeSeer global variables is safer.

            It does, however, point out something I did not mention the other night - when working with VB.NET scripts, it is good to dispose of objects and set string variables to null to help compact memory and minimize the impact of having multiple .NET scripts in the system on system resources.
            Regards,

            Rick Tinker (a.k.a. "Tink")

            Comment


            • #36
              Gotcha Rick, thanks again!

              Don

              Comment


              • #37
                Session 3 Transcript - Part 1 of 2


                Audience Question:
                Q: Is the colon better/worse than just having two actions in the event? What are the pros/cons to each?[Danal Estes] [Q: 8:38 PM] [A: 4:22 AM]
                A: It would be faster.

                Audience Question:
                Q: can script access the paramaters on zwave devices that are not supported by hs2, for example the paramter nightligt in the act receptacal or th varius command class that are in the homemanageables temp and humidity deivce[richard morton] [Q: 8:37 PM] [A: 4:23 AM]
                A: There is a way to do this, but it's not documented. I'll see if I can get the details.

                Audience Question:
                Q: how can you pass the ID of a device into a script... so you can have a single script that handles multiple devices - like security sensors[Graham Mitchell] [Q: 8:39 PM] [A: 4:24 AM]
                A: Scripts can take a parameter, so it depends on how the script is called.

                Audience Question:
                Q: How did you get to that script editing screen? Mine says "Events - All Groups" and looks different (no place to edit a script).[Terry Wysocki] [Q: 8:40 PM] [A: 4:24 AM]
                A: Add an action to run a script, then you get the script window.

                Audience Question:
                Q: r events quicker than script?[WEBPC (Antony)] [Q: 8:41 PM] [A: 4:25 AM]
                A: Yes, events are quicker since a script needs to be compiled first, then run.

                Q: how do you get the small window not to cover the big window? ... i tried undocking to no avail[Tahl Milburn] [Q: 8:33 PM] [A: 4:26 AM]
                A: Click on the 2 little arrows in the small window.

                Audience Question:
                Q: Is there documentation of limitations of scripts vs. connecting to HS with the .net api? Are there significant limitations? [Tim Webb] [Q: 8:42 PM] [A: 4:27 AM]
                A: Scripts will always be faster than accessing using the external remoting .NET API.

                Audience Question:
                Q: how to get some simple scripting system (net, vb, visual studio), and use it outside homeseer, to control homeseer:? what needs instlled to do this?[nick spagnola] [Q: 8:45 PM] [A: 4:30 AM]
                A: We will show you this, stand by.

                Audience Question:
                Q: but the external .NET API is also available from other machines, and not just on the HS machine[Graham Mitchell] [Q: 8:46 PM] [A: 4:30 AM]
                A: Correct. We expose HS via .NET using the HomeSeer2.dll.

                Q: What are your 'best practice' recommendations for using .NET with HomeSeer, in regards to which is the client and which is the server? Specifically, a .Net app can begin and then instantiate HomeSeer and control it as a server component, or you can start Homeseer web and call .NET classes as 'servers'.[F_ Walton] [Q: 8:50 PM]
                A: You would never want to start HomeSeer from a .NET script - it would already be running. Whether you create your own reference to HomeSeer within a script, or run it from HomeSeer so that HomeSeer puts the reference in for you does not matter, but accessing HomeSeer is a matter of getting a reference to the interface object which lives within the running instance of HomeSeer. Thus, it is not really client or server - it is referencing an existing object - or if you wish, you could look at it as the script is always the client.

                Audience Question:
                Q: Any concerns about Microsoft dropping support for VBScript? They dropped support for VB6.[Mike Lucas] [Q: 8:48 PM] [A: 4:33 AM]
                A: Not really, vbscript is handled through the msscript.ocx file which should always work with Windows. But we are moving forward and supporting the .net languages.

                Q: http://www.microsoft.com/downloads/d...displaylang=en[Stu Alden] [Q: 8:51 PM]
                A: Thank you for that link to the Microsoft scripting documentation for the Microsoft script technologies. (VBS Scripts, JavaScript)

                Audience Question:
                Q: is there documentation somewhere on the COM and .NET interfaces?[Graham Mitchell] [Q: 8:49 PM] [A: 4:34 AM]
                A: I assume you mean the HomeSeer interfaces? That is in the HomeSeer help file.

                Audience Question:
                Q: Is vb.net not susceptible to the 'long running' script issue that plagues vbs and the inability to know which script is long running?[steve ponnath] [Q: 8:51 PM] [A: 4:34 AM]
                A: It is not.

                Audience Question:
                Q: if you find the link to that script help file, can you post it in the transcript later?[nick spagnola] [Q: 8:51 PM] [A: 4:35 AM]
                A: Sure. Looks like someone else posted it also.

                Q: That was the key point from my ealier question.. Correct me if I'm wrong in saying this... The plugin designer must expose the necessary interfaces for the .net api access, however, using the built in scripting engine will always work.. Which would bring my next question, what is the main differences between the HS object reference from .net VS. the HS object reference from the scripting engine...?[Tim Webb] [Q: 8:53 PM]
                A: The plug-in designer does not have to add a reference to HomeSeer at design time - that is just for providing intellisense on the HomeSeer procedures. You can define the HomeSeer reference object as anything you want to call it, make it an Object type, and then at runtime there is a Callback procedure where the actual HomeSeer reference is passed to the plug-in, and you can then store it in your object variable. So it really does not matter, but if you add a reference in your project to HomeSeer's scripting interface, and then do not remove it before you distribute your plug-in, then you have likely created a plug-in that will work with only one specific version of HomeSeer. This is why we recommend using the reference if you need it for intellisense, to make programming easier, but then change it to an 'Object' before you compile your release so there is no version dependency in it.

                Q: Did you say c# can be used?[Dwayne George] [Q: 8:53 PM]
                A: It can be used for a plug-in, but not for a script as there is no script interpreter for C# - it is a compiled language.

                Audience Question:
                Q: Isn't there a .doc or .pdf version of the HS help files? The help file doesn't work properly under Chrome...[Jim Madigan] [Q: 8:53 PM] [A: 4:38 AM]
                A: There is an old one on the message board, you might find it with a search. It is not complete though.

                Q: Is there a script to view which scripts and events a device is a part of and the individual device's log.[Dain Webster] [Q: 8:56 PM]
                A: No, but it would not be too hard to create one. There are external tools that can get you that information though - 1) To find out which events reference a device, use the status page - check the device you are interested in, and then at the bottom of the status page choose the device operation to "View Event References for a device" - it will show you all the events that reference that device as a trigger, condition, or action in the event. 2) If you use Windows Explorer's Search feature, you can search your scripts folder, and for the text to find, enter the name of a script that you are interested in finding as being referenced by other scripts. 3) If you use the Search feature in HomeSeer, you can find all of the events that call a particular script filename.

                Audience Question:
                Q: Please post this in a MS board post. The clipboard does not work in the webinar questions area so we cant grap this url. Thank[Frank Ruffino] [Q: 8:54 PM] [A: 4:38 AM]
                A: Ok, will do.

                Q: is there an adgenda for this and general times for certain topics?[david norman] [Q: 8:55 PM] [A: 4:39 AM]
                A: The agenda is rough, no fixed times.

                Audience Question:
                Q: I have a STARTUP.TXT file in my scripts folder. What language is this?[Terry Wysocki] [Q: 9:00 PM] [A: 4:43 AM]
                A: VBScript.
                A: Newer versions of HomeSeer will also look for and run a Startup.VB script instead if you prefer to use VB.NET

                Audience Question:
                Q: Plans to support Powershell?[Scott DesBles] [Q: 8:59 PM] [A: 4:44 AM]
                A: We have not looked into that yet.

                Q: notepad++ is a great utility for editing vbs scripts[Rodney Sharp] [Q: 9:01 PM]

                Q: notepad++ is AWESOME for scripting (sourceforge)[Mike Brand] [Q: 9:01 PM]

                Audience Question:
                Q: will these vb scripts be able to be executed, with HomeSeer Basic?[nick spagnola] [Q: 9:02 PM] [A: 4:47 AM]
                A: Scripting is not supported in HSBasic.

                Q: consider also UltraEdit - http://www.ultraedit.com/[Mitch Matteau] [Q: 9:07 PM]

                Q: I believe that does answer my question. If I'm connected via a .NET instance, can you 'pump' scripts through the remote instance for some of the trickier spots (like where plugin authors don't expose the proper COM access)? (Its probably an un-othodox thing to do - but its for the sake of having all the code executing via .NET... Kinda like an "Eval()" method or equivalent)[Tim Webb] [Q: 9:07 PM]
                A: Not sure I follow what you want to do, but a VBS or VB.NET script can run another script that is VBS or VB.NET. Thus, you can have a VB.NET script that cannot execute a COM object, create and run a VBS script that does the job and then returns a value or writes a return to a global variable for your VB.NET script to then access.

                Audience Question:
                Q: Can I write to a different log than the main HS log?[Ken Johnson] [Q: 9:09 PM] [A: 4:54 AM]
                A: Yes, there is an object called Scripting.FileSystemObject. You can Google this.

                Audience Question:
                Q: Can Windows Powershell be used with Homeseer for scrripts?[Mitch Mitchell] [Q: 9:10 PM] [A: 4:54 AM]
                A: Not sure, have not tried that.

                Audience Question:
                Q: What's the difference in the .TXT extension and the .VB or .VBS extensions?[Terry Wysocki] [Q: 9:12 PM] [A: 4:55 AM]
                A: .TXT is VBScript, .VB is a .NET script.

                Audience Question:
                Q: just a simple example of external scripting - suppose I monitor an alarm system, outside homeseer - ON ALARM TRIGGER (someone broke in), trigger SHUT DOWN OF LIGHT MODULES[nick spagnola] [Q: 9:13 PM] [A: 4:57 AM]
                A: We have a small app called HSC.EXE that connects to HS and sends commands. This might be what your looking for. I'll find a link to it.

                Q: can use hungarian notation eg IntCount, strFred[Graham Mitchell] [Q: 9:14 PM] [A: 4:58 AM]
                A: I don't believe so.

                Q: When a .vb script fails to compile the error log will give the line number of the syntax error. The logged line number is different where the syntax error is in my script (.vb file error is on line 2, HS logs line 15). 1) Why is the line number reported differently 2) Is line number delta always 13 lines? 3) What is in these 13 "phantom" lines?[Bill Smith] [Q: 9:15 PM] [A: 4:58 AM]
                A: There is hidden code that is added to the file when it is compiled, so this messes up the actual line number.
                A: The hidden code is the code that gets a reference to HomeSeer, HomeSeer Phone, and other interfaces that are supported by a script running under HomeSeer.

                Audience Question:
                Q: do you also hve the link to the visual studio lite version?[nick spagnola] [Q: 9:15 PM] [A: 4:59 AM]
                A: Go to Microsoft.com and search for visual basic express, you will find it.

                Audience Question:
                Q: Did I hear that C# isn't support in the way the VB.NET is? Can I write scripts in C# like I can in VB.Net?[michael mcglinn] [Q: 9:17 PM] [A: 5:00 AM]
                A: Not in HS. You can access HS externally with a simple C# app though.

                Audience Question:
                Q: what does "Sub" mean? and why does it have to be set? (sorry I have not coded before)[david norman] [Q: 9:17 PM] [A: 5:01 AM]
                A: Sub means "Subroutine", it's just the syntax of the language.
                A: There are different types of procedures, but the two used in scripting and the most commonly used overall are Subs and Functions. Sub/Subs is short for subroutine. A subroutine is a procedure that you can call many times, rather than coding the same lines of code over and over again. Subroutines do work without returning a result. Functions are like subroutines in that you can call them frequently to make life easier, but they return a result. This was explained in the video as well - I created an example function that takes text as an input, and returns the text converted to all upper case - that is an example of a function. In VBS scripts only, it is important to look at the HomeSeer script procedure you are calling because if it returns a value, then it is a function, and it will require the use of parenthesis around the values passed to the procedure, but if it is a Sub, then parenthesis are not required. In VB.NET, parenthesis are always used. Example: In a VBS script, you can use WriteLog like this: hs.WriteLog "This", "Is a test" - there are no parenthesis - but if you use the DeviceValue function which returns a result, then in VBS you must pass it the parameter with parenthesis - here is an example of that for the device at address "B2": MyValue = hs.DeviceValue("B2")

                Q: If its optional, would you use "Sub Main(Optional ByVal parm As Object)"[F_ Walton] [Q: 9:18 PM] [A: 5:02 AM]
                A: The parm in a vb.net script is not optional.
                A: ... but in a VBS script it is optional.

                Q: ConText is a free editor that supports loading different Code Templates (VBScript, VB.Net, HTML, etc.)[Emile Victory] [Q: 9:20 PM]

                Audience Question:
                Q: Any plans to support C#? I suppose I can write a VB.NET wrapper to call my C#...[Charles Harris] [Q: 9:19 PM] [A: 5:03 AM]
                A: Not a big demand for it, so no plans right now.

                Audience Question:
                Q: The vb.net scripts... where are they being compiled? Is HS actually firing the .net compiler before executing?[Tim Webb] [Q: 9:19 PM] [A: 5:03 AM]
                A: Yes, we call into .NET and have the JIT compiler compile it. It's only compiled once though, then it's just called as a function the next time it's needed.

                Audience Question:
                Q: will the IDE pick up hs.LogWrite as an error?[Graham Mitchell] [Q: 9:19 PM] [A: 5:03 AM]
                A: Yes.
                A: Clarification: If you have a reference to the HomeSeer interface, then it will - if hs is defined as an object because you are not using intellisense, then it will NOT pick up the error.

                Audience Question:
                Q: For complex scripts, do you recommend building routines into seperate files for reusability, or is there too much overhead with going into another script for subroutines?[Dave Delgado] [Q: 9:21 PM] [A: 5:05 AM]
                A: No overhead doing that.

                Audience Question:
                Q: Is HS written in .NET?[Tim Webb] [Q: 9:21 PM] [A: 5:05 AM]
                A: Yes.
                A: And C, as we have had to jump through many hoops to make everything work!

                Q: Is there a way to add the reference on a remote development laptop that does not have Homeseer installed on it? in order to do the programming of scripts via visual studio.[Steven Karl] [Q: 9:25 PM]
                A: No, but by simply installing the speaker client, you will get the file(s) you need to add that reference, even if you never use the speaker client.

                Audience Question:
                Q: Just curious...What language is HS written in... C#?[michael mcglinn] [Q: 9:24 PM] [A: 5:08 AM]
                A: vb.net and C#.

                Q: if you remove the scheduler.hsapplication, and revert back to "object", is there any way to reference a GENERIC homeSeer library, so the programmer has at least the base level objects?[nick spagnola] [Q: 9:26 PM]
                A: No, because the reference to Object is filled at runtime - the IDE does not know what you will put there when you are coding. It is only if you use the reference during coding that you can get ANY intellisense on the procedures.

                Audience Question:
                Q: which DLLs do we need to register if we dont develop on the HS machine?[Graham Mitchell] [Q: 9:21 PM] [A: 5:11 AM]
                A: HomeSeer2.dll and Scheduler.dll

                Q: tenholde's editor will allow development on a remote pc as well as testing on that PC IIRC[M K] [Q: 9:28 PM]
                A: Yes, he includes instructions that specify the installation of the speaker client on the remote computer so you can get the files to add the references to. Good idea!

                Audience Question:
                Q: Can you copy scheduler.dll to your development system so Visual Studio will work this way?[David Lilienthal] [Q: 9:25 PM] [A: 5:11 AM]
                A: Yes, along with HomeSeer2.dll

                Q: Can you script for UPB devices in HomeSeer?[Rodney Sharp] [Q: 9:29 PM]
                A: You can script to access any HomeSeer device. However, sending specific UPB commands would require some knowledge on how the UPB plug-in or interface interacts with the HomeSeer devices.

                Audience Question:
                Q: regsvr32 ?[Graham Mitchell] [Q: 9:26 PM] [A: 5:12 AM]
                A: Not needed.
                A: Pertaining to the files needed to do script editing with intellisense using an IDE - the reason regsvr32 is not needed is because HomeSeer is a .NET application - regsvr32 is to register a COM/ActiveX server.

                Audience Question:
                Q: Install speaker.exe for references[Ed Tenholder] [Q: 9:26 PM] [A: 5:12 AM]
                A: Thanks - that is correct.

                Audience Question:
                Q: will there be a webinar on developing plugins?[Derek Cowburn] [Q: 9:30 PM] [A: 5:14 AM]
                A: Yes, we will be doing one.

                Audience Question:
                Q: can you do regsvr32 homeseer2.dll and scheduler.dll??[Graham Mitchell] [Q: 9:28 PM] [A: 5:14 AM]
                A: Not needed

                Audience Question:
                Q: any problems with developing on an x64 machine?[Graham Mitchell] [Q: 9:32 PM] [A: 5:16 AM]
                A: Not that I am aware of.
                Regards,

                Rick Tinker (a.k.a. "Tink")

                Comment


                • #38
                  Session 3 Transcript - Part 2 of 2

                  Q: can you give examples of working with devices as an object reference? specifically, looking up a device by name and HC/UC.[Derek Cowburn] [Q: 9:35 PM]
                  A: Sure. First, there are two ways to access a device - directly, using its unique device reference number, or by its letter code/unit code address, or indirectly by enumerating (going through) all of the devices to find the one you want. Here is an example script that enumerates all of the devices - you can see where it does a WriteLog of the device name and location is where you can put code to determine if the device found is the one you want to make a change to or not:
                  Code:
                  Sub Main
                           dim en   
                           dim dv
                           dim ev
                      
                           set en = hs.GetDeviceEnumerator
                           if   IsObject(en)   then
                           else
                              hs.WriteLog   "Enumerator","The device enumerator is invalid."
                           end   if
                      
                      
                           Do   while    not en.Finished
                                 if en.CountChanged    then
                                  hs.WriteLog   "Enumeration","-------- The device count has changed -----------"
                                 end    if
                                 set dv = en.GetNext
                                 if    not dv   is   nothing    then
                                  hs.WriteLog   "Enumeration","Got device " & dv.location &    " " & dv.name
                                 end    if
                           Loop
                      
                               set en =    Nothing
                               set en = hs.GetEventEnumerator
                               if   IsObject(en)   then
                           else
                              hs.WriteLog   "Enumerator","The event enumerator is invalid."
                           end   if
                      
                           Do   while    not en.Finished
                                 if en.CountChanged    then
                                  hs.WriteLog   "Enumeration","-------- The event count has changed -----------"
                                 end    if
                                 set ev = en.GetNext
                                 if    not ev   is   nothing    then
                                  hs.WriteLog   "Enumeration","Got event " & ev.group &  " " & ev.name
                                 end    if
                           Loop
                              
                       End  Sub



                  The other way is through direct access - here are some example of that: (Again, VBS script, not VB.NET)

                  Code:
                  Sub Main()
                               Dim dv
                               Dim dvRef
                      
                               ' First, get the device reference number using the device name.       
                             dvRef = hs.GetDeviceRefByName("Family Room Light")
                               If dvRef >  0   Then
                                      ' Now get the actual device object
                                    Set dv = hs.GetDeviceByRef(dvRef)
                               Else
                                 hs.WriteLog    "Error",    "Could not find the device by name - perhaps it was renamed - will attempt by Address E10"
                                    ' Get the device reference using the device address.
                                 dvRef = hs.GetDeviceRef("E10")
                                    If dvRef >    0  Then
                                       ' Now get the actual device object
                                        Set dv = hs.GetDeviceByRef(dvRef)
                                    Else
                                     hs.WriteLog   "Error",   "Could not find the device by name or address."
                                        Exit    Sub
                                    End    If
                               End   If
                              
                               ' We have the device we want in the dv object if we got this far, so display the name.
                             hs.WriteLog  "Script",   "I found a reference to the device, it is named: " & dv.Name
                              
                     End  Sub



                  Audience Question:
                  Q: Is the hs.WaitEvents function still supported? If so how is the function interacting with HS scripts?[Dave Johnston] [Q: 9:33 PM] [A: 5:17 AM]
                  A: Yes, but you really should not write scripts that run forever, they should perform a task, then exit.

                  Audience Question:
                  Q: Is there a "Tips & Tricks" for converting a vbs to a .net vb script? That would be helpful in switching to the newer language. [steve ponnath] [Q: 9:35 PM] [A: 5:18 AM]
                  A: You should be able to find many docs on this on the net. Look for info dealing with converting vb6 apps to vb.net. That will explain it.

                  Audience Question:
                  Q: can you review object persistance in scripts. what's the best way to preserve variables between events in scripts?[Derek Cowburn] [Q: 9:32 PM] [A: 5:20 AM]
                  A: In VBScript, nothing persists. Save state in virtual devices or use the hs.CreateVar,hs.GetVar, etc. functions. Same for VB.Net.

                  Q: how do you pass a device ID from an event into a script? eg A15, or [5 ?[Graham Mitchell] [Q: 9:37 PM] [A: 5:21 AM]
                  A: In the event when you launch the script, you can pass a parameter, just put the A15 in there. The script will except this as the parameter.

                  Audience Question:
                  Q: will you be saving these samples for our later perusal ? It may be very helpful[Steven Karl] [Q: 9:38 PM] [A: 5:22 AM]
                  A: We'll see if we can post them.

                  Audience Question:
                  Q: For a relatively new script user (e.g., have written just a few WSH scripts for various tasks), would you recommend starting with VBS when learning to program HomeSeer and then moving to vb.net, or just go right to vb.net and not bother with the older scripting?[Stu Alden] [Q: 9:41 PM] [A: 5:24 AM]
                  A: Yes, start with VBS, it's much more forgiving.

                  Audience Question:
                  Q: If you were going to learn one of the script languages solely for HS which would you recommend? VBScrip to VB.Net?[Ken Johnson] [Q: 9:40 PM] [A: 5:25 AM]
                  A: I like VBScript, it works fine most basic scripting tasks and logic.

                  Q: is there something like hs.CurrentDevice?[Graham Mitchell] [Q: 9:40 PM] [A: 5:25 AM]
                  A: No, there is no concept of the current device.

                  Q: how do you pass in the current device, rather than hard coding it?[Graham Mitchell] [Q: 9:40 PM] [A: 5:26 AM]
                  A: Not sure what the current device would be. I think I need an example situation?

                  Q: calling a script on a device status change.. how can the script find out which device status changed? Either by a non hard coded parameter, or via a call?[Graham Mitchell] [Q: 9:45 PM]
                  A: This is not easy for a script - a plug-in has options to register a callback that can communicate this information, but not a script. Your only options (I believe) are to go through all of the devices and get the time of their last change and go by that. You can reduce the number of devices that you go through by only searching the ones you care about. The easiest is to pass a parameter, but you do not want to do that, so without a plug-in there are limitations.

                  Audience Question:
                  Q: Does RunEx() require a txt file? Or can you simply place the script in-line, as RunEx's parameter[Tim Webb] [Q: 9:49 PM] [A: 5:32 AM]
                  A: No - it can be .VB, .VBS, .JS - whatever.

                  Audience Question:
                  Q: Can you pass a script literal into RunEx()...[Tim Webb] [Q: 9:50 PM] [A: 5:34 AM]
                  A: No - only the script file name, procedure name, and parameters if any.

                  Audience Question:
                  Q: Can you guys emailthe Q & A ? Good questions... the sample code is very helpful[Alfred Richner] [Q: 9:51 PM] [A: 5:35 AM]
                  A: Yes - in the thread for the webinar sessions.

                  Audience Question:
                  Q: Kinda off topic.. Where are you guys HQ'd? Where do most of your developers punch a clock?[Tim Webb] [Q: 9:44 PM] [A: 5:35 AM]
                  A: Main HQ is in Bedford NH.

                  Q: do you have some simple scripting beginning examples, in a help file, such as "turn light on", or "make sound thorugh speaker", or "dim light"? simple exmples that would show the device reference, a 3- or 4- line type of examples[nick spagnola] [Q: 9:54 PM]
                  A: If you look at the scripting commands documentation in the HomeSeer help file, you will see that MOST of the commands do have a one or more line sample on usage with them. If some of the commands in the help file and their samples do not help, drop me an email with a couple of specific commands you want help with and I will see what I can do - you can also post in the scripting forum as there are always people helping with scripts there.

                  Q: You can tell people that they can save the visible QAs using the File...Save Questions Log from the menu if they want to save those by themselves.[Stu Alden] [Q: 9:53 PM] [A: 5:37 AM]
                  A: Thanks Stu.

                  Q: For Q&A in GoToMeeting, from within GoToMeeting, you can File --> Save Questions Log.[Emile Victory] [Q: 9:53 PM] [A: 5:37 AM]
                  A: Thank you also Emile.

                  Q: They can also do file save log[Leelan Greer] [Q: 9:52 PM] [A: 5:38 AM]
                  A: Thanks Leelan.

                  Q: Any other MAC users out there? How about Automator and Applescript as languages to use for home automation taks? Please see http://www.macosxautomation.com/automator/[Craig Wilson] [Q: 9:53 PM] [A: 5:40 AM]
                  A: You would need to make a network connection from the MAC to the HomeSeer computer, and I am not sure if there is any way to do that given that it is Microsoft technology used for the interface. Now in HS3 when we are (likely) using WCF, perhaps there will be possibilities, but as long as the script is running on the MAC, it would have to talk to HomeSeer at a programmatic interface level so I do not think it can be done right now.

                  Q: Would you mind referring people to tenScripting for development on remote system?[Ed Tenholder] [Q: 9:28 PM] [A: 5:40 AM]
                  A: Yes

                  Audience Question:
                  Q: I agree with the person that asked the question about "sub" we are not all programmers or coders, you should have started at the basics of scripting !![Frank Thornton] [Q: 9:21 PM] [A: 5:45 AM]
                  A: Yes, we will cover some of the basics after we get some questions answered, but teaching the language syntax would take much too long, so we can only provide some starting points and hope that the examples and other users can help more.

                  Audience Question:
                  Q: Can one add multiple commands in the $SCRIPT line? Would it be by separating with a colon? [Marcus Krumpholz] [Q: 9:59 PM] [A: 5:45 AM]
                  A: Yes, using the colon again.

                  Q: You're welcome - thanks for doing this webinar and for writing HomeSeer!!![Stu Alden] [Q: 10:01 PM] [A: 5:45 AM]
                  A: Thank you for supporting us!

                  Q: When you were on the stat page I saw an image of a person. Where can I find new motion images?[Jeff Morgan] [Q: 9:58 PM] [A: 5:46 AM]
                  A: HomeSeer delivers that image in the html/images/homeseer directory I believe as we use it with motion detectors.

                  Audience Question:
                  Q: Will the same ':' delimiter allow someone to add multiple script lines in HST [$script=...] as you can in event actions?[Bill Smith] [Q: 9:56 PM] [A: 5:46 AM]
                  A: Yes!

                  Audience Question:
                  Q: Is there an easily printable version of the HS scripting help information? Certainly would be a good reference guide.[steve ponnath] [Q: 8:54 PM] [A: 5:47 AM]
                  A: No, sorry.

                  Q: Can a script be used to alter runtime elements (button color properties, text, etc)?[Dane Maron] [Q: 10:06 PM]
                  A: Yes, to some degree. All of the elements of a device can be altered. Some of the display elements such as button colors are a part of the HTML style sheet, and that can technically be modified by a script, but normally you would not.

                  Audience Question:
                  Q: Are multiple parameters passed to a script via HsTouch differently then a normal HS script?[Ed Tenholder] [Q: 10:03 PM] [A: 5:49 AM]
                  A: Same way.

                  Audience Question:
                  Q: Pls explain the characters that get passed from a drop down box.[Don Stephens] [Q: 10:05 PM] [A: 5:50 AM]
                  A: The selected element is passed as a string (text) to the script.

                  Q: I'm looking specifcally for show/hide[Bill Smith] [Q: 10:09 PM]
                  A: You cannot change the show/hide flag except with the browser, but you can use a script to change which devices are hidden or visible when devices are hidden from view. It is the MISC property that has to be modified. If this is what you want, contact me and I will give you more info.

                  Audience Question:
                  Q: I noticed that you had an optoma_serial script in your directory. I just purchased an optoma projector and was thinking about trying to figure out how to interface it. Would you be willing to share your script?[Steven Karl] [Q: 10:05 PM] [A: 5:51 AM]
                  A: It is very simple, but I planned on showing it as part of sending data out a serial port - send me an email if you want a copy of it, but when you see it you will see how simple it is. My Optoma is very old too, and I think they fixed some of their RS-232 issues since my projector was built.

                  Q: Can you pass parameters between HSTouch objects in a script? For example, can a drop-down list change a camera image displayed on the screen? [Dave Delgado] [Q: 10:09 PM]
                  A: Yes - there is an HSTouch action to change the text on an HTML object (the URL), so you can populate a drop-down list with some URLs of images to be displayed, and then when you change the drop-down selection, have the selected item be set as the text on your HTML object. At least in my mind that would work - have not done it before personally.

                  Q: There seems to be a bug or issue with that (submitted a ticket following the last webinar) in which the values and strings aren't being fed back properly, which it sound like wouldn't work using these methods either.[Dane Maron] [Q: 10:10 PM] [A: 5:53 AM]
                  A: I'll double check, it may be fixed in the latest.

                  Q: How current do you keep the object/method library in the documentation? are they pretty-much up to date with each release?[Dave Delgado] [Q: 10:05 PM] [A: 5:54 AM]
                  A: Yes, they are up to date.

                  Audience Question:
                  Q: Can scripting control HST elements?[Bill Smith] [Q: 10:06 PM] [A: 5:54 AM]
                  A: Not directly, but it can simulate a control press/release, and so add hidden controls and execute them.

                  Q: can you show the OpenPort function? I want a way to recover from a port closing when a USB virtual port disconnects, then reconnects. Want the script to autmatically re-try the port.[Derek Cowburn] [Q: 10:28 PM] [A: 6:15 AM]
                  A: Not sure I have an answer on that one. I believe you can check for errors as Rick showed, and it you get an error, re-open the port. Check for errors on sending data.

                  Q: can you show how to access functions in a third party dll? Is this the same as you showed with scheduler.dll?[Joe Romanowski] [Q: 10:31 PM] [A: 6:15 AM]
                  A: If its a .NET dll, you only need to add the dll to the settings.ini file. Then you can call the functions in the dll.

                  Q: How about non .NET dlls such as ones written in Delphi or C?][Joe Romanowski] [Q: 10:33 PM] [A: 6:18 AM]
                  A: More complicated, but you can still do it. You need to use a different syntax. I don't have it off the top if my head.

                  Q: I know you have an extremely diverse audience....and can't please everyone, this has really been really useful for me & is motivating to get back into the coding[Dave Delgado] [Q: 10:35 PM] [A: 6:18 AM]
                  A: Thanks, glad it has helped. We will probably do more specific ones in the future.

                  Q: how do you use a script to create config items in the WebUI? (like weather warnings)[Graham Mitchell] [Q: 10:33 PM] [A: 6:19 AM]
                  A: You mean new devices?

                  Q: like actually create the buttons and fields that the user interacts with to configure the script[Graham Mitchell] [Q: 10:37 PM] [A: 6:22 AM]
                  A: I don't think scripting can help there. Scripting does not have access to the UI, other than creating devices and events.

                  Q: OT: Can the HomeTroller2 with the 8GB mem upgrade run better voices?[Derek Cowburn] [Q: 10:45 PM] [A: 6:30 AM]
                  A: Have you tried the Cepstral voices we sell? They are smaller and use much less resources.

                  Q: does one script anguage operate "faster' than other? .vbs, .vb, or .txt[Derek Cowburn] [Q: 10:47 PM] [A: 6:31 AM]
                  A: vbs and .txt are the same, and the fastest.

                  Audience Question:
                  Q: when a vb script becomes long running and causes issues, is there nowhere, including system event logs, that you can detect which vbscript is the culprit?[steve ponnath] [Q: 10:48 PM] [A: 6:33 AM]
                  A: Yes, using the threads page.

                  Audience Question:
                  Q: Any thoughts about adding a more comprehensive script editing within the HS web interface? Might be easier for some of the newer members of the group.[Marcus Krumpholz] [Q: 9:01 PM] [A: 6:35 AM]
                  A: It would be nice, but no plans.

                  Q: I may have missed this reply but is there a plugin tutorial webinar planned?[Derek Cowburn] [Q: 10:52 PM] [A: 6:35 AM]
                  A: yes

                  Audience Question:
                  Q: do scripts have to run from WITHIN HomeSeer, or can they be run independently?[nick spagnola] [Q: 9:06 PM] [A: 6:35 AM]
                  A: They can be run independantly, but they have to get their own reference to HomeSeer.

                  Q: Where are the past webinar's listed?[Kenneth Heinrich] [Q: 10:51 PM] [A: 6:35 AM]
                  A: In the Webinar forum on the message board.

                  Q: If .net scripts remain compiled in memory after the first run of the script are they faster than vbs?[Jonathan Smith] [Q: 10:51 PM] [A: 6:36 AM]
                  A: They can be, but not a big deal really.

                  Audience Question:
                  Q: splain again hot to access a remote hs instance?[Derek Cowburn] [Q: 9:28 PM] [A: 6:37 AM]
                  A: See "Controlling HomeSeer Remotely" in the help file.

                  Q: are there and device properties missing from the help file? ie: value, valueString, status?[Derek Cowburn] [Q: 10:57 PM] [A: 6:41 AM]
                  A: No, they should all be there.

                  Q: Is there any way to have homeseer listen to a .wav or .mp3 file and transcribe to text?[Matt Pigozzo] [Q: 10:54 PM] [A: 6:41 AM]
                  A: no.

                  Q: but which status change caused the script to be called?[Graham Mitchell] [Q: 10:59 PM]
                  A: When the trigger is a status change, then the status (On, Off, Dim) has to change. Even if On/Off/Dim is not displayed, the status is still maintained internally, so it can still be used as a trigger. If the trigger is a value change, then the value has to change - be aware that when the status is changed, the value is often changed at the same time. And lastly, a plug-in can register for notification when the string of a device changes, so you can even create string change triggers (with a plug-in) if you wanted. So keep in mind that there are 3 properties of information for each device (status, value, string) and so triggering an event off of one of them changing requires the proper event setup is all.

                  Q: Will do.. Whats your name rjh?[Tim Webb] [Q: 10:59 PM] [A: 6:42 AM]
                  A: Rich


                  Regards,

                  Rick Tinker (a.k.a. "Tink")

                  Comment

                  Working...
                  X