Announcement

Collapse
No announcement yet.

Round up the decimal

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

    Round up the decimal

    What is the easiest approach to making the value of a sensor round up? ie: make a reading of 89.6 read 89.

    Thanks

    #2
    It depends upon your context, but the scripting Round function and the Cint function both round. The value stored in the DeviceValue in HS by mcsTemperature is a rounded integer value.

    RoundedTemp = cint(19.8)
    RoundedTemp = round(19.8)

    These will both yield 20

    Comment


      #3
      I guess I asked the wrong question! Is there anything in the plugin interface to handle this rounding for the value of a sensor?

      I'm trying to avoid having 2 hs devices for each sensor, one unrounded and the other rounded by a script.

      Comment


        #4
        The rounding is based upon the class of sensor. Temperature sensor rounding digits can be specified in the setup. Wind is always integer, rainfall is is always 2 significant digits, etc. The DeviceValue will always contain the integer-rounded value. This may be of use for some devices, but something like rainfall will be useless. With my ML plugin I put the conversion and formatting on the ML side since the reason it is being formatted is to satisfy the display preference with ML.

        Comment


          #5
          Originally posted by Michael McSharry
          Temperature sensor rounding digits can be specified in the setup.
          Where is this exactly? I've read the documentation and also looked extensively in the plugin setup but I'm not seeing it. I'm only concerned about temperature sensors.

          Comment


            #6
            Lower left of the Display Tab. You will want to enter 0 in the text box.

            If you are sending it to ML, then wouldn't you want the DeviceValue anyway since the DeviceString may contain HTML formatting?

            Comment


              #7
              Thanks Michael. Thats what I needed.

              Comment

              Working...
              X