Announcement

Collapse
No announcement yet.

Scripting - harder than it should be

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

    Scripting - harder than it should be

    So I've written my first script to control my new Homeseer switches. On a single tap it dims lights based on the time. Another tap will take you to a peak brightness for that time period. Taps after that toggle between the two. It's roughly based on rprade's event logic in https://board.homeseer.com/showthread.php?t=182447

    But wow did this take me a lot longer than it should have. I write code everyday for iOS/Android so I kinda know what I'm doing. But there's a lot to be desired in this runtime. Hoping someone can point out what I'm missing.

    But first off, I'm surprised of the version of VB.NET. If you query
    Code:
    Environment.Version.ToString()
    you'll get
    Code:
    4.0.30319.17020
    which translates to a PREVIEW version of 4.5. I have no idea who made the call to ship a PREVIEW version of a language, but damn that's a bold move.

    Next: compile errors. Holy crap is VB.NET an interesting language to script in. It could be worse, but the problem lies with the lack of any kind of useful description when you type something wrong. God only knows how many times I added a "{" after a function declaration and had to back out all my changes until I could pinpoint the line.
    Adding a line number to compilation errors would be a 1000% improvement.

    And the API is a bit quirky. Not sure if anyone has noticed the mis-spelling in CAPIControslHandler. That's really what it's called. But anyways, I can deal with an odd API, I guess my complaint really lies in the compiler and the shipping version of .NET

    So, does anyone know how to get useful compilation errors? I'm on a SEL with HS3 Standard Edition 3.0.0.297

    #2
    For real-time syntax checking and debugging, you should look at tenScripting. Note, the link is to the HS2 version. Make sure that you read the whole web site and download/install the HS3 version. Also, the docs were written before Visual Studio 2015 Community version was released, and I recommend using it in conjunction with tenScripting.

    Another useful tool if you are going to be scripting for HS is tenScriptAid.

    Let me know if I can be of assistance,

    tenholde
    tenholde

    Comment


      #3
      Originally posted by holmes View Post
      But first off, I'm surprised of the version of VB.NET. If you query
      Code:
      Environment.Version.ToString()
      you'll get
      Code:
      4.0.30319.17020
      which translates to a PREVIEW version of 4.5. I have no idea who made the call to ship a PREVIEW version of a language, but damn that's a bold move.

      Next: compile errors. Holy crap is VB.NET an interesting language to script in. It could be worse, but the problem lies with the lack of any kind of useful description when you type something wrong. God only knows how many times I added a "{" after a function declaration and had to back out all my changes until I could pinpoint the line.
      Adding a line number to compilation errors would be a 1000% improvement.

      And the API is a bit quirky. Not sure if anyone has noticed the mis-spelling in CAPIControslHandler. That's really what it's called. But anyways, I can deal with an odd API, I guess my complaint really lies in the compiler and the shipping version of .NET

      So, does anyone know how to get useful compilation errors? I'm on a SEL with HS3 Standard Edition 3.0.0.297
      The SEL uses Mono. Does this report the mono version under linux and do the version numbers match to .net?

      I use CAPIControlHandler in many of my scripts and have never needed an extra "s".

      +1 for tenscripting.

      Cheers
      Al
      HS 4.2.8.0: 2134 Devices 1252 Events
      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

      Comment


        #4
        Fun times.

        I just spent the better part of the morning trying to get tenscripting to work. Not so much tenscripting's fault, really just computers being difficult. Started w/ installing Visual Studio. I'm on a Mac so I was using the latest preview version. Got that installed, but opening up any .VB file displays only the first line in the editor. The line numbers for the rest of the file is there. The VC tabs show the file contents. But the editor only shows the first line. So that's pretty neat.

        Even tried creating a super simple VB.NET project and the same thing happened. Even with the default .VB files included in a new project. The Preview version of Visual Studio on OSX doesn't really seem to work.

        Looks like the SEL ships with "Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1)". I wouldn't expect that to match the .NET version. I imagine it just needs to implement system modules that .NET calls into.

        As to the extra "s" in running controls, that's the command to run multiple controls at the same time. It's mis-spelled. That's pretty great.

        Comment

        Working...
        X