• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Need Javascript help for metadata point

    User help
    2
    5
    11.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mhradom
      last edited by

      I have 1-wire DS2450 A/D numerical data available I would like to convert to binary for simple on/off notification. Can someone please give me some direction as to the proper script to do this for a metadata point?

      For example:

      If the input is <= 0.5 then output 0 binary
      If the input is >0.5 then output 1 binary

      I am not familiar with JS programming and syntax (last programming I did was 30 years ago in FORTRAN) and have tried several things with no success.

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        Hi Mike,

        Try this (assuming "x" is the var name you give the point):

        
        if (x.value &lt= 0.5)
            return false;
        return true;
        
        

        ... and set the meta point to be a binary. That ought to do it.

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • M
          mhradom
          last edited by

          Thanks Matthew.

          I actually got it figured out by myself like this:

          if (p33.value<=0.5)
             {
          return false 
             }
          else 
             {
          return true
              }
          

          I see so many different styles of coding for JavaScript on the web, I don't know what is actually required and what is personal preference. Do you know a good resource to learn more?

          Anyway if works perfectly. I continue to be amazed at the flexibility and capability of Mango! Now I just need to get my 1-wire network more stable.

          1 Reply Last reply Reply Quote 0
          • M
            mlohbihler
            last edited by

            Thanks. Re Javascript, just ask Google. There's a ton of resources around.

            Best regards,
            Matthew

            1 Reply Last reply Reply Quote 0
            • First post
              Last post