Announcement

Collapse
No announcement yet.

How to store a Temp reading into a vrtual device

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

    How to store a Temp reading into a vrtual device

    Hi Michael,

    I would like to store one of my temperature readings into a vertiual device in the format of a number only (as 70 instead of 70 degrees). I would like to be able to use the hs.SetDeviceValue function to store the value.

    I have a device setup with the code of "/4" and if I try to use this command I get an error. I have tried hs.SetDeviceValue "y1", "/4" but this does not seem to work.

    Thanks in advance, Judd

    #2
    Originally posted by jpape
    Hi Michael,

    I would like to store one of my temperature readings into a vertiual device in the format of a number only (as 70 instead of 70 degrees). I would like to be able to use the hs.SetDeviceValue function to store the value.

    I have a device setup with the code of "/4" and if I try to use this command I get an error. I have tried hs.SetDeviceValue "y1", "/4" but this does not seem to work.

    Thanks in advance, Judd
    Judd,
    If your wanting to take a reading from one device and store it in anothers try this:
    Code:
    '  Grab the device string from /4 which is 70 degrees
    strDesiredValue = hs.deviceString("/4")
    '  Split the value and text ....
    splValue(strDesiredValue)
    '  Assign the 70 to the device value ...
    hs.setDeviceValue "y1",cint(splValue(0))
    '  Also assign the 70 to the device string ...
    hs.setDeviceString "y1",splValue(0)
    I didn't test this code but it should work...
    -Rupp
    sigpic

    Comment


      #3
      Rupp,

      I get the following error when I try your code.

      Script error in file: Enviromental Controls.Vbs: 500:Variable is undefined: strDesiredValue in line 20

      Judd

      Comment


        #4
        Judd,
        The script I posted is designed to be a stand alone script to be run in an event. I'm not sure about including it in Enviromental Controls.Vbs. I would need that file in order to look at the layout to see where to include it in that file.
        -Rupp
        sigpic

        Comment


          #5
          Judd, on your original post...

          mcsTemperature stores temperature in formatted deviceStrings. It stores the numeric portion in deviceValue scaled by 100. A 70.5 degree reading would show up in the deviceValue as 7050.

          The parameters of a hs.SetDeviceValue are devicecode and numeric value.
          If the mcsTemperature device is /4 and you only want the integer portion of the temperature then

          hs.SetDeviceValue "y1", hs.DeviceValue("/4") / 100.

          Comment


            #6
            Michael,

            Thanks for your help. I used your example and it worked fine. The only thing I needed to do was remove the /100 as the correct value seems to already be assigned to the \4 code.

            This is what I'm using

            hs.setDeviceValue "y1",hs.deviceValue("\4")

            Thanks again....

            Judd

            Comment


              #7
              I thought I put the scaled value in the virtual device. Maybe I only put it in the database. You figured it out in any case.

              Comment

              Working...
              X