Announcement

Collapse
No announcement yet.

Example using GetDeviceRef and DeviceValue in HS3 scripts

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

  • Example using GetDeviceRef and DeviceValue in HS3 scripts

    Hope this helps others who are converting HS2 scripts to HS3 scripts.

    The DeviceValue() has changed in HS3 to take an integer Device Reference as an argument (instead of a device code string in HS2). Here is a quick example for an HSM-100 multisensor to illustrate the difference (using vb syntax):

    HS2:
    Dim DevTempi AsInteger
    Dim DevTempd AsDouble
    DevTempi = hs.DeviceValue("Q5")
    DevTempd = DevTempi / 100

    In the above case, my device named "Q5" is the temperature for a HSM100 Multi-sensor. For example,
    The DevTempi has a value of 6850
    The DevTempd has a value of 68.5

    HS3:
    Dim DevTempi AsInteger
    Dim DevTempd AsDouble

    Dim DevRef AsInteger

    Dim ZTrollerCode AsString = "003D3517-"
    Dim ZWaveNode AsString = "004-"
    Dim MyDeviceCode AsString = "Q5"

    Dim DevAddress AsString = ZTrollerCode & ZwaveNode & MyDeviceCode

    Note: The DevAddress string is displayed in the HS3 "Address" Column on the HS3 "Device Management" screen. In this case, "003D3517-004-Q5"
    I broke out the formulation of the DevAddress to better illustrate how this string seems to be formed in HS3 when using a Z-wave interface device.

    DevRef = hs.GetDeviceRef(DevAddress)
    DevTempi = hs.DeviceValue(DevRef)
    DevTempd = hs.DeviceValueEx(DevRef)

    In the above case, my ZwaveNode 004 is a HSM100 Multi-sensor, and the Q5 device is its temperature.
    The DevTempi has a value of 68
    The DevTempd has a value of 68.5
    Note: There is no need to divide the temperature by 100 as was needed in HS2.

    Below is a reference to another (sticky) post I found on the board that provides more general detail about device references: "Regarding Getting A Device Reference" http://board.homeseer.com/showthread...t=getdeviceref

    -- Ernie

  • #2
    More Example scripts to set/get device values for HS3

    Here are some additional example scripts.
    These functions and subroutines mostly set and get values of devices given the address string on my Z-wave based system.


    '-------------------------------------------------------------------
    ' Helper subroutines and functions to set and get device values for HS3
    '
    ' This file contains the following subroutines and functions to get and set device values:
    ' dGetDevValByAddr: returns a device's value as a double
    ' setDevStringByAddr: sets a device's string value
    ' setDevValueByAddr: sets a device's string value
    ' iGetDevValByAddr: returns a device's value as an integer
    ' dGetDevLastChgByAddr: returns a device's value as a Date
    ' ControlDevByAddr: sends a command to the address-named device.
    ' dumpCAPI: prints the contents of a device's control object. (copied from another message on this board)
    ' This may help to better understand how to control a particular
    ' device type and perhaps modify ControlDevByAddr.

    ' XivelyPost: post a comma separated set of values to Xively.com
    ' UploadToCloud: Upload data to Thingspeak.com Internet of Things Cloud Data service

    (Put the attached file in your script directory and change the .txt suffix to .vb suffix - the message board would not allow me to upload a *.vb file?!?)
    Attached Files

    Comment


    • #3
      Thanks for this although I am not sure on how I would use this exactly.

      Could you post some examples of how I would turn on or off a zwave device using this?

      Comment


      • #4
        Thanks, this is very helpful. I think your comments in the code regarding setting a device's value versus setting it's string needs to be modified...

        Comment

        Working...
        X