Announcement

Collapse
No announcement yet.

How do I get the value out of the status field in vb script?

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

    How do I get the value out of the status field in vb script?

    Why is it so hard to access the status field in a device in vbscript? It is really easy to get the value and the string, but status for some reason is much harder? Admittedly I am not an expert vb scripter but the only code snippet I can find is here: https://help.homeseer.com/help/HS3/s....capigetstatus and I have no clue what that is doing?

    Assuming I have a device 1234, I can get to the value through hs.devicevalue(1234). Is there no simple equivalent to get the status for this device? Thanks.

    #2
    Device status is coupled to device value based on entries on the Status/Graphics tab.
    To retrieve the device status, you have to access the value status pairing.
    TenScriptAid is an excellent tool to determine the proper syntax. Try:
    hs.DeviceVSP_GetStatus(1234,hs.DeviceValue(1234),ePairStatus Control.Status)
    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


      #3
      Agreed with Uncle Michael ! I highly recommend tenScriptAid developed by the amazing tenholde !

      http://tenholder.net/tenWare2/tenScriptAid/default.aspx
      ---------------------------------------------------
      Jean-Marie G. Vaneskahian
      jean@vaneskahian.com
      ---------------------------------------------------

      Comment


        #4
        I have tenscript installed. I must admit it is floating just above my vb script knowledge area. I have found it useful to figure out some basic things but had trouble getting deeper into it - again my issue is that I am not proficient on vb script - nothing to do with tenscript.

        I am just curious why it is so easy to manipulate string and value and not status?

        Comment


          #5
          As Uncle Mike said, status is not a stored item, but computed from Device Value and the Status/Graphics pairs.
          tenholde

          Comment


            #6
            Just to be clear this tenScriptAid, not tenScripting3 or tenScripting4. just literally just gives you what to cut and paste into your scripts... could not be easier.

            Based on the screens below for example...

            To get the Device Status in a script using VB.Net:
            Code:
            hs.CAPIGetStatus([COLOR=#9b59b6]{Device Reference Integer}[/COLOR]).Status
            To get the Device String in a script using VB.Net:
            Code:
            hs.DeviceString([COLOR=#9b59b6]{Device Reference Integer}[/COLOR])

            Click image for larger version

Name:	Screenshot_2021-02-28_09-09-21.jpg
Views:	351
Size:	126.9 KB
ID:	1459627
            Click image for larger version

Name:	Screenshot_2021-02-28_09-09-43.jpg
Views:	324
Size:	40.5 KB
ID:	1459628
            Click image for larger version

Name:	Screenshot_2021-02-28_09-09-49.jpg
Views:	317
Size:	42.0 KB
ID:	1459629
            ---------------------------------------------------
            Jean-Marie G. Vaneskahian
            jean@vaneskahian.com
            ---------------------------------------------------

            Comment


              #7
              Moving to HS4 it gets even more confusing as both the old HS3 scripting functions are available as well as the new HS4 scripting functions. I've released the HS4 version tenScripting4 that allows you to test and deploy scripts using both the older and newer scripting functions. This will be even easier with the next release of HS4, as there are some changes coming to make tenScripting4 and the HS4 scripting environment more compatible (PluginSDK included as a reference, and a new hs4 object of type IHsController will be available).

              I am currently working on tenScriptAid4 that will show the values of both the HS3 and HS4 fields, and generate scripting calls for both hs (IHSApplication) and hs4 (IHsController). Eventually in both VB and C#. Testers always welcome.
              tenholde

              Comment


                #8
                One issue with hs.DeviceString or hs.DeviceStringByName is when you set the device string to someething explictly, Device String will return that other string instead of the string associated with the device's current value.

                I use the following function to return the string associated with the device value:

                Code:
                Private Function GetVirtual(ByVal sName As String) As String
                  Dim iRef As Integer = hs.GetDeviceRefByName(sName)
                  Dim CS As ICAPIStatus = hs.CAPIGetStatus(iRef)
                  Return CS.Status
                End Function

                Comment


                  #9
                  Thanks everyone, this was really helpful. Have tenScriptAid up and running. What threw me on this one is that I had copied some code from another script and had it working for my specific application to a degree then all of a sudden I fed some parameters to the script and it started to fail. For the life of me I couldn't figure out what was going on.

                  I am updating temperatures back and forth between my touchscreens - I use Sharptools so I am going through Hubitat - long story but touchscreens look awesome so worth the trouble.

                  I was using the following statement to set the Hubitat temp value:

                  Code:
                  Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(device_target, True, "(value)", False, False)
                  cc.ControlValue = device_source_value
                  Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                  I then tried to put the reverse code in place to update my Nest thermostats connected to homeseer through the Spud plugin and it didn't work. Went into tenScriptAid and noticed that one parameter was slightly different:

                  Code:
                  Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(device_target, True, "(value) °F", False, False)
                  cc.ControlValue = device_source_value
                  Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                  "(value) °F" instead of "(value)". I fixed that and the script is running.

                  Looking at tenScriptAid I see that this is the label of this field, so obviously this needs to match exactly for it to work. Using this as a learning experience. If I wanted to increase the value of this device would I use the following?

                  Code:
                  Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(device_target, True, "-", False, False)
                  cc.ControlValue = 1000
                  Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                  Click image for larger version

Name:	Screen Shot 2021-02-28 at 6.06.54 PM.png
Views:	362
Size:	11.6 KB
ID:	1459739

                  Comment

                  Working...
                  X