Announcement

Collapse
No announcement yet.

tenScripting Now Available for HS3

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

    Originally posted by randman View Post
    Hi,

    I'm stuck on a Visual Basic script issue, and hope someone can help.
    The script runs fine from within tenScripting3, but fails with a compilation error when I run it directly in HomeSeer.

    In tenScripting3, I have an UpdateSensorColor.vb script which contains (at a high level):

    Class UpdateSensorColor

    Class AlertDevice
    ...
    Public Sub Dump()
    hs.WriteLog("Info", "This statement causes a compilation error.")
    End Sub
    End Class

    Public Sub Main(ByVal param As Object)
    hs.WriteLog("Info", "This statement does not cause any trouble.")
    ... use Class AlertDevice...
    End Sub

    End Class

    This script works just fine within tenScripting3. However, if I export to HomeSeer and run it directly from HomeSeer, every call to hs.<member>" (such as hs.WriteLog) from within Class AlertDevice results in the error:

    Compiling script... Reference to a non-shared member requires an object reference

    Why can't I call hs functions from within Class AlertDevice? If I run the script from tenScripting3, it works just fine.

    Thanks,
    I took a look at the sample ScriptWithEmbeddedClassDefinition.vb. Apparently, I have to pass in hs from Main to the AlertDevice Class. I did this via:

    Class AlertDevice
    ...
    Private Shared _hs As HomeSeerAPI.IHSApplication
    ...
    ' Important: AssignHs Shared Sub must be called before creating instances of this class.
    Public Shared Sub AssignHs(hs As HomeSeerAPI.IHSApplication)
    _hs = hs
    End Sub
    ... Use _hs.WriteLog, etc. ...
    End Class

    Then, from Main, I had to:

    Public Sub Main(ByVal param As Object)
    ...
    AlertDevice.AssignHs(hs)
    ...
    End Sub


    So, it's important that AlertDevice.AssignHs(hs) is called before any instances of the AlertDevice class are created.

    Is there a more elegant way to do this?

    Thanks.

    Comment


      Could you describe what you are trying to do? Why define a separate class in your script. Could it not just be a function?
      tenholde

      Comment


        Originally posted by tenholde View Post
        Could you describe what you are trying to do? Why define a separate class in your script. Could it not just be a function?
        I need a list of certain devices, so creating a List of AlertDevice instances was a nice way of doing it. I just didn’t know that the class couldn’t access ha directly. Apparently hs has to be passed from Main or non-class function to a Class.

        Comment


          Does tenScripting only run on windzoes?
          HomeSeer Version: HS3 Standard Edition 3.0.0.548
          Linux version: Linux auto 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
          Number of Devices: 484 | Number of Events: 776

          Enabled Plug-Ins: 3.0.0.13: AirplaySpeak | 2.0.61.0: BLBackup
          3.0.0.70: EasyTrigger | 1.3.7006.42100: LiftMaster MyQ
          4.2.3.0: mcsMQTT | 3.0.0.53: PHLocation2 | 0.0.0.47: Pushover 3P
          3.0.0.16: RaspberryIO | 3.0.1.262: Z-Wave

          Z-Net version: 1.0.23 for Inclusion Nodes
          SmartStick+: 6.04 (ZDK 6.81.3) on Server

          Comment


            tenScripting runs under MS Visual Studio. It will connect to HS3 on whatever platform it is running.
            tenholde

            Comment


              So if it runs under MS Visual Studio I think that means it won't run under Linux as I didn't think MS Visual Studio runs under Mono but I'm in no way sure about that.
              HomeSeer Version: HS3 Standard Edition 3.0.0.548
              Linux version: Linux auto 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
              Number of Devices: 484 | Number of Events: 776

              Enabled Plug-Ins: 3.0.0.13: AirplaySpeak | 2.0.61.0: BLBackup
              3.0.0.70: EasyTrigger | 1.3.7006.42100: LiftMaster MyQ
              4.2.3.0: mcsMQTT | 3.0.0.53: PHLocation2 | 0.0.0.47: Pushover 3P
              3.0.0.16: RaspberryIO | 3.0.1.262: Z-Wave

              Z-Net version: 1.0.23 for Inclusion Nodes
              SmartStick+: 6.04 (ZDK 6.81.3) on Server

              Comment


                I think that is right but I have no Linux experience
                tenholde

                Comment


                  Originally posted by SQLGOD View Post
                  Device Values Change In UI But Not In Reality

                  Figured it out this morning. I thought the HS3 TenScripting Project's examples were using the new CAPI, but the toggle example wasn't. I'm just getting used to the new commands and didn't realize it. The example set the 'value' of the Insteon objects just fine, but didn't actually change the physical device's status/value (on/off/dim...). I inserted a one-liner CAPI and all works like a charm. My bad.

                  Thanks for the quick reply, and thank you for the interface -- it will make converting my automation to HS3 scripts significantly faster and more fun.

                  An automated house is a happy house!
                  Can you give me an example of the CAPI one line you added? I am just starting out with tenScripting and was playing with the example on/off script. I noticed the same thing as you. The device status changes in HS but the actual device does not.
                  Marty
                  iCore5 Win 10 Pro x64 SSD

                  HS3 Pro Edition 3.0.0.435 Windows

                  BLOccupied:,Device History:,Yamaha:,UltraMon3:,mcsXap:,Restart:,UltraNetatmo3:, UltraM1G3:,Ultra1Wire3:,BLBackup:,Harmony Hub:,DoorBird:,UltraECM3:,Nanoleaf 3P:,UltraRachio3:,Z-Wave:,SDJ-Health:,BLGarbage:,Blue-Iris:,Chromecast:,Pushover 3P:,EasyTrigger:

                  Comment


                    Originally posted by mminehan View Post
                    I am just starting out with tenScripting and was playing with the example on/off script. I noticed the same thing as you. The device status changes in HS but the actual device does not.
                    Are you using TenScriptAid? If not, you should definitely give it a try. I found it to be extremely valuable in understanding how to implement CAPI scripting calls.

                    Mike____________________________________________________________ __________________
                    HS3 Pro Edition 3.0.0.548, NUC i3

                    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                    Comment


                      Originally posted by Uncle Michael View Post
                      Are you using TenScriptAid? If not, you should definitely give it a try. I found it to be extremely valuable in understanding how to implement CAPI scripting calls.
                      Yesterday I discovered the script aid. You are right, it's very useful and it makes scripting so much easier.
                      Thanks for the suggestiion.
                      iCore5 Win 10 Pro x64 SSD

                      HS3 Pro Edition 3.0.0.435 Windows

                      BLOccupied:,Device History:,Yamaha:,UltraMon3:,mcsXap:,Restart:,UltraNetatmo3:, UltraM1G3:,Ultra1Wire3:,BLBackup:,Harmony Hub:,DoorBird:,UltraECM3:,Nanoleaf 3P:,UltraRachio3:,Z-Wave:,SDJ-Health:,BLGarbage:,Blue-Iris:,Chromecast:,Pushover 3P:,EasyTrigger:

                      Comment


                        Hello,

                        Thanks for the utulity; I am looking forward to using it.

                        I am having a problem compliling the applicaon for the first use. I keep getting the error even though I have mapped the three HomeSeer DLL references to VS. Any idea how to fix this?

                        Code:
                        Error    BC30002    Type 'Scheduler.Classes.DeviceClass' is not defined.
                        Thanks

                        Comment


                          Could you post your code
                          tenholde

                          Comment


                            Thanks for the reply. I do not have any code yet, this is the first install of the TenScripting. The issue happens when I try to compile the solution file for the first time. I was following the videos from your website page.

                            Comment


                              Can you determine which statement is generating the error?
                              tenholde

                              Comment


                                In the solution explorer, usually on the right hand side of the screen, expand the node References and make sure that Scheduler.dll is there. Where does it point to? File location?
                                tenholde

                                Comment

                                Working...
                                X