• 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

    HTTP Sender Single Message

    Scheduled Pinned Locked Moved User help
    19 Posts 2 Posters 2.5k Views 3 Watching
    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.
    • MattFoxM Offline
      MattFox
      last edited by

      No, combine your values into a alphanumeric metapoint value, thus allowing you to format your text how you'd like then fire that out as your publisher point instead rather than two individual points.
      If that's a bit confusing I'll help you with a script when I am near my computer tomorrow.

      Fox

      Do not follow where the path may lead; go instead where there is no path.
      And leave a trail - Muriel Strode

      1 Reply Last reply Reply Quote 0
      • R Offline
        Robmalone
        last edited by

        Thanks @MattFox. Im not sure if that will work. I am working with a 3rd party on a project, the 2 data points above are for testing how the 3rd party server receives and parses the data from Mango.
        The plan is to install a number of MangoGTs and publish that data to their server. They want all data points in one message. Some of the sites may have 30-40 data points. Would I have to combine all 30-40 points?

        1 Reply Last reply Reply Quote 0
        • MattFoxM Offline
          MattFox
          last edited by MattFox

          Would I have to combine all 30-40 points?

          Not necessarily as context points!
          If you know what points they are and are able to tag them or if you know they have a distinct deviceName/name pattern then we can utilise an rql query, pull them in, get their latest pointvalues (ie pointvaluebefore current context runtime) sort them how you would like them to be formatted then simply return it to the metaPoint. From there that will trigger as a context point in your publisher and allow you to send the whole batch in one go. Use a timer to make it fire every fifteen minutes and you're away!

          Fox

          Do not follow where the path may lead; go instead where there is no path.
          And leave a trail - Muriel Strode

          1 Reply Last reply Reply Quote 0
          • R Offline
            Robmalone
            last edited by

            Thanks @MattFox. Sounds good but I don't have much experience in scripting, would very much appreciate some help with it.
            I could give all points a common device name for each MangoGT. Hopefully that should make things a bit easier.

            MattFoxM 1 Reply Last reply Reply Quote 0
            • MattFoxM Offline
              MattFox @Robmalone
              last edited by MattFox

              @robmalone said in HTTP Sender Single Message:

              I could give all points a common device name for each MangoGT. Hopefully that should make things a bit easier.

              Sure let's get this sorted. Give what information you can and I'll teach you how to piece it together. I'd recommend learning to tag points though as it gives you more control over your point queries...

              Fox

              Do not follow where the path may lead; go instead where there is no path.
              And leave a trail - Muriel Strode

              1 Reply Last reply Reply Quote 0
              • R Offline
                Robmalone
                last edited by

                Great @MattFox. Thank you.
                I have tagged both points with a Tag Key of "Sender" and Tag Value of "EETest"

                Point 1 - device name: Powerpoint Main Incomer, point name: Active Energy, Tag - Sender: EETest
                Point 2- device name: Powerpoint Main Incomer, point name: Active Power, Tag - Sender: EETest
                Alphanumeric Meta Data Point - device name:HTTPSenderTest, point name:SenderPoints
                Added the 2 points above as external context points. Keys are
                Point 1 Active Energy - PPAE
                Point 2 Active Power - PPKW

                Do you need any more info?

                1 Reply Last reply Reply Quote 0
                • MattFoxM Offline
                  MattFox
                  last edited by

                  Nope that's good. I'll come back to you soon. I've got a busy day ahead!

                  Hope it's not too urgent!

                  Fox

                  Do not follow where the path may lead; go instead where there is no path.
                  And leave a trail - Muriel Strode

                  1 Reply Last reply Reply Quote 0
                  • MattFoxM Offline
                    MattFox
                    last edited by MattFox

                    OK! For your query/script:

                    //First we need the correct format:
                        function pad(number) {
                          if (number < 10) {
                            return '0' + number;
                          }
                          return number;
                        }
                    
                       var toISOString = function(d) {
                          return d.getUTCFullYear() +
                            '-' + pad(d.getUTCMonth() + 1) +
                            '-' + pad(d.getUTCDate()) +
                            'T' + pad(d.getUTCHours()) +
                            ':' + pad(d.getUTCMinutes()) +
                            ':' + pad(d) +
                            '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
                            'Z';
                        };
                    
                    //Make your RQL query up:
                    var ts = Number(CONTEXT.timestamp);
                    var d = new Date();
                    d.setTime(ts);
                    var RQL = "eq(tags.Sender,EETest)&sort(deviceName,name)&limit(2)";
                    var allPoints = DataPointQuery.query(RQL);
                    var body = "Source: 83.147.156.26<br>";
                    body += "Device ID: -<br>";
                    body += "Time: " + d.toString() + "<br><br>"; //Two newlines
                    
                    //print(DataPointQuery);
                    print(allPoints)
                    for(var i=0; i<allPoints.length;i++)
                    {
                        var value = -99; //if there's an error we'll know
                       var dp = allPoints[ i ];
                           print(dp)
                        d.setTime(dp.runtime.time);
                        value = dp.runtime.last(1,true); //or pointValueAt(ts,true)
                        if(value[0]){value = value[0].value;}
                       body+= dp.xid+":"+value+" - "+toISOString(d)+"<br>";
                    }
                    return body;//Send as post 
                    

                    Hope this gives you something to build from. Might be beneficial if you can fire a test post into https://webhook.site so you can check the format of your message. If you can do that, you can share the post link so others can see the format you want to achieve and how it comes from mango.

                    Do not follow where the path may lead; go instead where there is no path.
                    And leave a trail - Muriel Strode

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      Robmalone
                      last edited by

                      @MattFox Thanks for the help but I'm a bit confused. Do I use this script in the Meta data point? I'm not seeing any points/point values?

                      1 Reply Last reply Reply Quote 0
                      • MattFoxM Offline
                        MattFox
                        last edited by MattFox

                        Yes inside the meta data point. Then when you return the value, it sets that as the point's value to be fired out of the publisher

                        Fox

                        Do not follow where the path may lead; go instead where there is no path.
                        And leave a trail - Muriel Strode

                        1 Reply Last reply Reply Quote 0
                        • R Offline
                          Robmalone
                          last edited by

                          Should I see the point values when I validate the script? What I get is -
                          "Script result: Source: 83.147.156.26<br>Device ID: -<br>Time: Tue Jun 23 2020 10:06:04 GMT+0100 (BST)<br><br>"

                          1 Reply Last reply Reply Quote 0
                          • MattFoxM Offline
                            MattFox
                            last edited by MattFox

                            put a print( allPoints ) under the query call. There's a chance my tag query doesn't agree with your tags and how you set them.

                            EDIT: If you check the other post as I mentioned, you can check my query by pasting it into the RQL query builder in the watchlist builder page.

                            Do not follow where the path may lead; go instead where there is no path.
                            And leave a trail - Muriel Strode

                            1 Reply Last reply Reply Quote 0
                            • R Offline
                              Robmalone
                              last edited by

                              Still no luck with that. The RQL query is working fine in the watchlist builder, giving the correct 2 points back but still no data points or values when I validate the script, even after including print( allPoints ) at the end.

                              1 Reply Last reply Reply Quote 0
                              • MattFoxM Offline
                                MattFox
                                last edited by

                                I can't remember if 3.7 lets you validate a script like 3.5 and earlier could... Thing is, that loop should be looping twice for those two data points. There has to be an error... Turn on logging and see what you can find.
                                I'll do a quick test for you in the morning. It's 10:15pm here and I'm not much help right at this moment!

                                Fox

                                Do not follow where the path may lead; go instead where there is no path.
                                And leave a trail - Muriel Strode

                                1 Reply Last reply Reply Quote 0
                                • R Offline
                                  Robmalone
                                  last edited by

                                  No problem. Thanks.

                                  1 Reply Last reply Reply Quote 0
                                  • MattFoxM Offline
                                    MattFox
                                    last edited by MattFox

                                    I've made some amendments (copy from above) - sure enough the data we needed was inside the runtime property. BUT I found the solution!
                                    The sodding datapoint query doesn't work in 3.7 without setting the script permissions.
                                    Normally these were populated by default, but this is no longer the case. In this case, make the script permission run as superuser to get your points through, or at least the user allowed to read those points.

                                    Once you've done that you'll be away!

                                    Fox

                                    Do not follow where the path may lead; go instead where there is no path.
                                    And leave a trail - Muriel Strode

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