Announcement

Collapse
No announcement yet.

Convert 1550 to 15.5 How

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

    Convert 1550 to 15.5 How

    The title says it all.

    In a script (HS2) how can a take a device value of 1550 and convert it to 15.5?

    I know how to read the value into a script, just not how to move the decimal point.
    sigpic
    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

    #2
    Code:
    Dim NewVal As Double = 0
    
    NewVal = hs.devicevalue("A2") / 100
    
    hs.writelog("", NewVal)
    Should do it...

    Comment


      #3
      Originally posted by mrhappy View Post
      Code:
      Dim NewVal As Double = 0
      
      NewVal = hs.devicevalue("A2") / 100
      
      hs.writelog("", NewVal)
      Should do it...
      Thanks for quick reply.

      Errors on line three (expect end of statement) and line 3 is "Dim NewVal As Double = 0"

      Here is my entire script
      Code:
      Sub Main
      dim x
      Dim NewVal As Double = 0
      x=hs.DeviceValue ("O42")
      x=x+50
      hs.setdevicevalue "O42", x
      NewVal = hs.devicevalue("O42") / 100
      hs.setdevicestring "O42", NewVal
      
      End Sub
      sigpic
      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

      Comment


        #4
        Originally posted by Gogs View Post
        Thanks for quick reply.

        Errors on line three (expect end of statement) and line 3 is "Dim NewVal As Double = 0"

        Here is my entire script
        Code:
        Sub Main
        dim x
        Dim NewVal As Double = 0
        x=hs.DeviceValue ("O42")
        x=x+50
        hs.setdevicevalue "O42", x
        NewVal = hs.devicevalue("O42") / 100
        hs.setdevicestring "O42", NewVal
        
        End Sub
        ah right thats a VBScript rather than a .net bit of stuff I posted I should have said...

        Just remove the As Double = 0 bit, just put Dim NewVal

        Comment


          #5
          Originally posted by mrhappy View Post
          ah right thats a VBScript rather than a .net bit of stuff I posted I should have said...

          Just remove the As Double = 0 bit, just put Dim NewVal
          Erm, even I should have noticed it was VB.

          Thanks it works perfectly, and now you have shown how to do it in both VB and .net
          sigpic
          A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

          Comment


            #6
            Hi Gogs

            This may also help make things smaller

            Sub Main
            hs.setdevicevalue "O42", (hs.DeviceValue("O42") +50)
            hs.setdevicestring "O42", (hs.devicevalue("O42") / 100)
            End Sub

            Greig.
            Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
            X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
            Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
            Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
            Scripts =
            Various

            Comment

            Working...
            X