• 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

    Script - Mimic No Update State

    Scripting general Discussion
    2
    14
    4.6k
    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.
    • phildunlapP
      phildunlap
      last edited by phildunlap

      I do not know why you are doing the double modulo for what appears to be days and hours. diffMins would be diffMs/60000 by itself. Also, be wary, JavaScript % operator is not a modulo that respects returning positive values only. Lots of people write their own modulo functions like

      function mod(number, modulo) {
         return ((number % modulo) + modulo) % modulo;
      

      To get around that problem. Also, it would seem to me you could have us do all the work for this with...

      var data = p.pointValuesSince(new Date().getTime() - 10*60*1000) //ten minutes in milliseconds
      if( data.length == 0 )
        return 1
      return 0
      

      Your logic should be fine (provided the samples aren't exactly a day apart, because of those modulo operations)

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

        Haha, no I am not interested in that logic I half baked with my google fu.

        Your code is so much nicer, I'll use that instead.

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

          Hey Phil,

          I don't think I tested your code last time, and now I'm realizing the code doesn't seem to be working. I'm always getting a return to zero, even though the boiler is OFF and cannot send data to update the time stamp.

          Any thoughts?

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Do you have the latest version of the Meta module installed?

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

              Looks like it: Meta 2.2.4.

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by

                Hmm. You could try adding a print(data); after the first line, see what the statistics object looks like. Is the boiler on interval logging?

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

                  The point I am monitoring has a logging type: "When point value changes".

                  I have set up a No Update event notification, on that same point, to email when triggered, and that does work.

                  The data prints out as "0.0"

                  1 Reply Last reply Reply Quote 0
                  • phildunlapP
                    phildunlap
                    last edited by

                    "print(data)" should print out an object, like {"count":0, "average":null, firstValue:PointValueTime@ABCDEF, lastValue:.... }

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

                      Oh, in that case I don't know where it print outs to. I tried looking around... I have no idea, sorry.

                      1 Reply Last reply Reply Quote 0
                      • phildunlapP
                        phildunlap
                        last edited by phildunlap

                        It would be right around where you are looking, above the return value. I would think the 0.0 you're seeing is the return value. Some of them have issues with the printstream getting eaten... you could try another browser perhaps. Or, you can just return data.toString() which would work to get its value returned in the error message saying it cannot be cast to a numeric.

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

                          Here ya go.

                          0_1476827250560_updateprint.png

                          PS: I was using Chrome.

                          1 Reply Last reply Reply Quote 0
                          • phildunlapP
                            phildunlap
                            last edited by phildunlap

                            It looks like it's still reading values! Also I got my expectation wrong, that's just a list of PointValueTimes! I was thinking about the structure of statistics objects, like one would get from p.past()

                            i betcha my mistake is testing 'data.count == 0' instead of 'data.length == 0'

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

                              Replacing data.count == 0 with data.length == 0 now works.

                              Thanks for your help Phil.

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