Announcement

Collapse
No announcement yet.

Converting Excel VBA script for HS3?

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

  • Converting Excel VBA script for HS3?

    I have a VBA script running in Excel with HS2. It uses a single line to create an HS Object that I use in the script. In HS2 that was:
    Set hs = CreateObject("Homeseer.Application")

    With HS3 this does not work. Is there a new method to create the HS3 Object in VBA(visual basic)???
    Thanks for the help,
    BobSpen

  • #2
    hi bob

    check here , maybe this topic helps
    http://board.homeseer.com/showthread.php?t=172178

    kind regards


    Originally posted by BobSpen View Post
    I have a VBA script running in Excel with HS2. It uses a single line to create an HS Object that I use in the script. In HS2 that was:
    Set hs = CreateObject("Homeseer.Application")

    With HS3 this does not work. Is there a new method to create the HS3 Object in VBA(visual basic)???
    Thanks for the help,
    BobSpen
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

    Comment


    • #3
      Bob, I use Excel to analyze lots of my data from Homeseer. I don't understand what you mean by "a VBA script running in Excel". I have lots of Macros (based on VB) that run in Excel, and I have HS events that start And run Excel spreadsheets. They all work in both Hs2 and HS3.

      Can you be more specific about what you are trying to do.

      Steve Q


      Sent from my iPad using Tapatalk HD
      HomeSeer Version: HS3 Pro Edition 3.0.0.368, Operating System: Microsoft Windows 10 - Home, Number of Devices: 373, Number of Events: 666, Enabled Plug-Ins
      2.0.83.0: BLRF, 2.0.10.0: BLUSBUIRT, 3.0.0.75: HSTouch Server, 3.0.0.58: mcsXap, 3.0.0.11: NetCAM, 3.0.0.36: X10, 3.0.1.25: Z-Wave,Alexa,HomeKit

      Comment


      • #4
        Malosa,
        Thanks I will take a look.

        Steve Q,
        With HS2, I also ran VB scripts in Excel that instantiated a HomeSeer Object which I set equal to hs; then I could access device states and values in Excel with hs.DeviceValue..... and the like. I used a line in my Excel VB which did this: Set hs = CreateObject("Homeseer.Application")

        Now this line gives me an exception.

        What are you using in your Excel script(running with and HS3 system) to give you access to the Object?

        Thanks,
        BobSpen

        Comment


        • #5
          I've never tried to get Homeseer device values directly from Excel. I don't have a need to do that. I use excel to analyze data over time. Primarily temperature and power usage data. I use vb scripts to create text file logs of my HS data. I have several Excel spreadsheets that are run by HS. They have auto start macros that load the text file data then create graphs. The graphs are stored in my Homeseer HTML folder and automatically appear in HSTouch. All automated.

          Steve Q


          Sent from my iPad using Tapatalk HD
          HomeSeer Version: HS3 Pro Edition 3.0.0.368, Operating System: Microsoft Windows 10 - Home, Number of Devices: 373, Number of Events: 666, Enabled Plug-Ins
          2.0.83.0: BLRF, 2.0.10.0: BLUSBUIRT, 3.0.0.75: HSTouch Server, 3.0.0.58: mcsXap, 3.0.0.11: NetCAM, 3.0.0.36: X10, 3.0.1.25: Z-Wave,Alexa,HomeKit

          Comment


          • #6
            Anyone using the
            Set hs = CreateObject("Homeseer.Application")
            inside an Office App????

            It worked great in system with HS2, but I get a "cannot create object.........." when use on system with HS3.
            Thanks for any help,
            BobSpen

            Comment


            • #7
              In HS2 I also had to instantiate the object but since HS3 I have found I don't need to; it may be that that's because it runs in the HS environment.

              E.G. this runs without any CreateObject method...

              Sub Main()
              Sunrise = hs.Sunrise
              YesterdaySunrise = hs.DeviceString(406)
              Delta = dateDiff("n", Sunrise, YesterdaySunrise)
              HS.SetDeviceValueByRef 413,Delta, True
              HS.SetDeviceString 413, Delta, True
              End Sub

              Try it without the Create method & see if it works....
              (this is using VBS but its much the same

              Scott

              Comment


              • #8
                Scott,
                I believe you are running that script "from within" Homeseer, so the HS Object is already available. I'm running a VB script essentially in Windows so I have to create the Object before I can have access to it.
                BobSpen

                Is no one using the HS3 Object in Windows or Window App????

                Comment


                • #9
                  I can't tell you exactly because I am running on Linux, and I don't use office at home BUT.....having said that.

                  Try this....In excel, in the VBA editor-go to Tools|References.
                  Find HomeSeer (or whatever they call themselves -HS3, HS or whatever....and check it)

                  Next while still in the VBA Editor go to the object browser and filter by HomeSeer (or whatever you set that reference to). I think that - that name...that appears in the Object Browser will be what you set your object reference to.

                  I haven't done this stuff in a long while so I don't recall all the details but maybe this will help.

                  If it does work....if you add that reference and you properly "DIM" the object and instantiate it with the explicit reference then you may also get the benefit of having the "." assist work so when you use the object and type "." then the properties and methods will be revealed.

                  Consider also the some of the HS(2) functions were deprecated in HS3 so the old code may still need to be updated to function correctly.

                  Good Luck
                  I hope this helps.

                  Comment


                  • #10
                    The way I understand it (disclaimer: sometimes incorrect) is that CreateObject is for COM interfaces, the new HomeSeer application is pure .net so is not a COM interface so you can't create it this way. The way you now interface with it is using the HS Communications Framework and creating connections to HS, you need a couple of DLL files and then some additional programming to establish the connection and create the HomeSeer object. It is not a particularly simple connection anymore like it was in HS2.
                    My Plugins:

                    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
                    Yeelight 3P | Nanoleaf 3P

                    Comment


                    • #11
                      Have you looked at the new JSON commands or ascii commands?

                      Details available at http://homeseer.com/support/homeseer..._with_json.htm) and http://homeseer.com/support/homeseer...nk/default.htm

                      Comment


                      • #12
                        Originally posted by BobSpen View Post
                        Anyone using the
                        Set hs = CreateObject("Homeseer.Application")
                        inside an Office App????

                        It worked great in system with HS2, but I get a "cannot create object.........." when use on system with HS3.
                        Thanks for any help,
                        BobSpen
                        Bob,

                        Did you ever get this working?

                        Comment


                        • #13
                          Does NOT work in HS3.....
                          Bobspen

                          Comment

                          Working...
                          X