Announcement

Collapse
No announcement yet.

Help needed to perform math functions on a stored value

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

    Help needed to perform math functions on a stored value

    I'm hoping someone might have a simple solution to little problem I have. Currently, I have my weather station information stored in virtual devices. e.g., "_7" contains the value 0.29, for the year to date rain fall. The problem is that when I have a script that reads the various weather conditions, HS/2 only speaks the integer component of the value contained within the device.

    Is there a simple way to take the value of a device and multiply it by 100 (in my case) and store it in another variable I create? Then that way, I can parse the integer component and the decimal amounts so that I can then incorporate it better into a HS.Speak command.

    Thank you in advance for any suggestions and help!
    -Todd

    ____________________________________________________________ ________________
    HS2Pro: 2.5.0.81 :: HS3Pro (beta) || Plugins:| SmartHome PowerLinc USB, Global Cache, BLBackup, DooCPU Monitor, DooMotion, BLOutlook, BLIcon, BLOutgoingCalls, OutgoingCalls, ROC-Rnd, HSTouch iPhone, UPS Monitor, DooMenuBar, BLSpeech, HSTouch Server, WAF AB8SS, mcsTemperature, VWS, BLChart, RFXCOM, ISY Insteon, iAutomate RFID, iTunes, NetCAM, DSC Security, Nest

    #2
    Todd,
    Clarification needed. Is HS not speaking 0.29?
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      Thanks for the question. Here's the specific script that is run:


      Sub Main()

      Dim Rain
      Rain=hs.DeviceValue ("_7")
      hs.speak "It has rained " &Rain & ", inches so far this year"

      End sub

      Consequently, HS will say "It has rained zero inches so far this year", when in fact the value of "_7" as of yesterday was only 0.29. When the value exceeds .99 then HS will say "It has rained seven inches so far this year" when the value of "_7" is 7.24.
      -Todd

      ____________________________________________________________ ________________
      HS2Pro: 2.5.0.81 :: HS3Pro (beta) || Plugins:| SmartHome PowerLinc USB, Global Cache, BLBackup, DooCPU Monitor, DooMotion, BLOutlook, BLIcon, BLOutgoingCalls, OutgoingCalls, ROC-Rnd, HSTouch iPhone, UPS Monitor, DooMenuBar, BLSpeech, HSTouch Server, WAF AB8SS, mcsTemperature, VWS, BLChart, RFXCOM, ISY Insteon, iAutomate RFID, iTunes, NetCAM, DSC Security, Nest

      Comment


        #4
        Syntax of this may not be 100% I am not in front of a vbscript reference at the moment - but it sounds like you need to speak both halves


        So something like

        dim string1
        dim myarray(2)

        string1=hs.devicevalue("_7")

        myarray = split (string1,".")

        hs.speak "It has rained " & myarray(0) & "point" & myarray(1) & "inches so far today"

        ' bear in mind I live in England - we measure rainfull in feet!

        HTH

        Malarcy

        Comment


          #5
          Todd,

          HS stores 'DeviceValues' as a long integers, so only the integer portion of your decimal value is being stored and it will always return a long. According to the docs, this is the same for both HS1 & HS2.

          You might consider using the 'device string' instead of the 'device value' to store your decimal values. This way you can store any value (in string format) and hs.Speak will read it back correctly.

          Here's an example to demonstrate the difference:
          Code:
          sub Main()
            dim j, k
          
            hs.SetDeviceValue "A1", 7.25
            hs.SetDeviceString "A1", "7.25"
          
            j = hs.DeviceValue("A1")
            k = hs.DeviceString("A1")
          
            hs.Speak "Device value is" & j & ". Device string is" & k
          end sub
          Do you have the ability to change the way that the values are stored in HS by your weather system?
          Last edited by mfisher; January 8, 2006, 02:09 PM.
          Best regards,
          -Mark-

          If you're not out on the edge, you're taking up too much room!
          Interested in 3D maps? Check out my company site: Solid Terrain Modeling

          Comment


            #6
            Mark,

            Your suggestion worked! I just needed to use the DeviceString command instead of the DeviceValue command. Now HS speaks the amount of rainfall as "zero point two nine" just like I wanted it to.

            Thanks!
            -Todd

            ____________________________________________________________ ________________
            HS2Pro: 2.5.0.81 :: HS3Pro (beta) || Plugins:| SmartHome PowerLinc USB, Global Cache, BLBackup, DooCPU Monitor, DooMotion, BLOutlook, BLIcon, BLOutgoingCalls, OutgoingCalls, ROC-Rnd, HSTouch iPhone, UPS Monitor, DooMenuBar, BLSpeech, HSTouch Server, WAF AB8SS, mcsTemperature, VWS, BLChart, RFXCOM, ISY Insteon, iAutomate RFID, iTunes, NetCAM, DSC Security, Nest

            Comment


              #7
              MFisher in January said:

              "You might consider using the 'device string' instead of the 'device value' to store your decimal values. This way you can store any value (in string format) and hs.Speak will read it back correctly."

              Thanks, that worked for me!

              I was trying to get the air temperature from a device and 0 just didn't seem right!!!

              Bill

              Comment

              Working...
              X