• 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

    Send multiple point value in alarm text

    Mango General
    4
    27
    10.9k
    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.
    • S
      sky_watcher @CraigWeb
      last edited by

      @craigweb Thank you for your reply, I made an example like one from the link that you suggested and I have some problems.

      Below is my example:
      0_1546536543743_2019-01-03_19-27-10.jpg

      And this is what I get in my email:

      0_1546536554564_2019-01-03_19-27-52.jpg

      But the values that are showed there aren't for T0 and T1, are for the point that trigger the alarm.

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

        Hi sky_watcher,

        That is because the list you are iterating in the FTL is the renderedHtmlPointValues which is included in the model for the point that triggered the event. Instead, you would want to iterate over the lists you added to the model (and probably separately), so

        <#if pressureValues??>
          <#list pressureValues as index,value>
          ${additionalContext.pressure.deviceName} - ${additionalContext.pressure.name} - ${value.value} - ${value.time}<br/>
          </#list>
        </#if>
        

        We have to <#list> over index, value because a JavaScript list is backed by a Map with the natural numbers as the keys, so it's more like looping over a map.

        S 1 Reply Last reply Reply Quote 1
        • S
          sky_watcher @phildunlap
          last edited by

          @phildunlap Thank you Phil, your example works but it is a way to format the value?
          For value I have to many decimals and for time it in a wired format.

          0_1546540613156_2019-01-03_20-32-38.jpg

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

            You'll have to manually get the values rendered as desired. Presumably that'll be the point's text renderer, so you could have a function like this, perhaps in a global script:

            function getRenderedValues(variableName, limit) {
                var renderedValues = [];
                var textRenderer = CONTEXT_POINTS[variableName].getVO().getTextRenderer();
                if(textRenderer === null || textRenderer === undefined)
                    return renderedValues;
            
                var rawValues = p.last(10);
                for(var k = 0; k < rawValues.length; k+=1) {
                    //See com.serotonin.m2m2.view.text.TextRenderer 
                    //  for understanding the second argument
                    renderedValues.push(textRenderer.getText(rawValues[k], 2));
                }
                return renderedValues;
            }
            //Remove the print portion if a global script, or after testing
            print(getRenderedValues("p", 10));
            
            S 1 Reply Last reply Reply Quote 1
            • Jared WiltshireJ
              Jared Wiltshire
              last edited by

              Alternatively look into Freemarkers format options
              https://freemarker.apache.org/docs/ref_builtins_date.html
              https://freemarker.apache.org/docs/ref_builtins_number.html

              Developer at Radix IoT

              S 1 Reply Last reply Reply Quote 0
              • S
                sky_watcher @phildunlap
                last edited by

                @phildunlap Thanks Phil, I see that the script works grate but I'm not quite sure how to transfer the result of the function to the model.put("temperatureValues", temperature.last(5));

                0_1546544387778_2019-01-03_21-35-21.jpg

                And how can I render the time?

                Thank you!

                1 Reply Last reply Reply Quote 0
                • S
                  sky_watcher @Jared Wiltshire
                  last edited by

                  @jared-wiltshire I've seen your post after writing to Phil...

                  I'll look into the docs and come with an answer.

                  Thank you Jared!

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

                    Remove the print statement and do,

                    model.put("temperatureValues", getRenderedValues("temperature", 5));
                    S 1 Reply Last reply Reply Quote 0
                    • S
                      sky_watcher @phildunlap
                      last edited by

                      @phildunlap I tried this before, but without removing print statement and did not worked. I tried again now after I've removed the print statement and is not working.

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

                        My mistake! The function probably should be doing,

                        function getRenderedValues(variableName, limit) {
                            var renderedValues = [];
                            var textRenderer = CONTEXT_POINTS[variableName].getVO().getTextRenderer();
                            if(textRenderer === null || textRenderer === undefined)
                                return renderedValues;
                        
                            var rawValues = p.last(10);
                            for(var k = 0; k < rawValues.length; k+=1) {
                                //See com.serotonin.m2m2.view.text.TextRenderer 
                                //  for understanding the second argument in getText
                                renderedValues.push( {"value": textRenderer.getText(rawValues[k], 2), 
                                    "time": rawValues[k].time} );
                            }
                            return renderedValues;
                        }
                        

                        It was making rendered values as a list of strings, so there was not a .value or .time property for the FTL to refer to. Instead will make it a list of objects with those properties.

                        S 1 Reply Last reply Reply Quote 0
                        • S
                          sky_watcher @phildunlap
                          last edited by

                          @phildunlap Still doesn't work, I don't receive any email after this modification.

                          0_1546546860524_ddddd.jpg

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

                            Whoops, FTL issues,

                            <#if pressureValues??>
                              <#list pressureValues as index, value>
                              ${additionalContext.pressure.deviceName} - ${additionalContext.pressure.name} - ${value.value} - ${value.time}<br/>
                              </#list>
                            </#if>
                            

                            There were related messages in the log file.

                            S 1 Reply Last reply Reply Quote 1
                            • S
                              sky_watcher @phildunlap
                              last edited by

                              @phildunlap Yes, now work perfect for value, but the time is still in that weird format.

                              0_1546548324807_asdf.jpg

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

                                Maybe you can try ${value.time?number_to_datetime} in the FTL or you could use a SimpleDateFormatter in the script to store it in the format you want.

                                S 2 Replies Last reply Reply Quote 1
                                • S
                                  sky_watcher @phildunlap
                                  last edited by sky_watcher

                                  @phildunlap Yes, is working now.

                                  Thank you a lot! Have a great day!

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    sky_watcher @phildunlap
                                    last edited by sky_watcher

                                    @phildunlap Hi Phil, I have to reopen this discussion, today when I played around with the email feature, I was trying to customize the email and I've noticed that the time when the alarm was triggered is not the same with the time for the values, and this make sense because I record that values in the database every minute.

                                    So I have a question, can I print there the instant value, not a recorded value from my data base? Because when the alarm is triggered that point can have another value that the one that is last recorded in my database.

                                    0_1546614058426_11sadf.jpg

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

                                      I think what you're looking for could be found in the Mango/ftl/ files. The eventData.ftl files shows you can do

                                      ${evt.prettyActiveTimestamp}
                                      

                                      evt is a https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/event/EventInstance.java so you can use those getter functions in the FTL, as prettyActiveTimestamp does.

                                      S 1 Reply Last reply Reply Quote 0
                                      • S
                                        sky_watcher @phildunlap
                                        last edited by

                                        @phildunlap Thank's, if I put this line I get the same time for all the points.

                                        ${evt.prettyActiveTimestamp}
                                        

                                        But my question is the value in real time or is last value from my database?

                                        0_1546626888445_1111fdsfgr.jpg

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

                                          Are you saying you put that in the loop?

                                          But my question is the value in real time or is last value from my database?

                                          I don't understand what you're asking.

                                          S 1 Reply Last reply Reply Quote 0
                                          • S
                                            sky_watcher @phildunlap
                                            last edited by

                                            @phildunlap Ok, let say that my temperature point is recorded in my database every 3 minutes, but my point is updated form PLC at every 5 seconds, (the record at every 3 minutes is made by an average off all readings between those 3 minutes, correct?).

                                            If my alarm point occurs somewhere between those 3 minutes intervals which value is displayed for T0? Instant value or the last value recorded?

                                            I came with this problem when I saw that the timestamp for the alarm trigger point and T0 are different.

                                            I hope I was clear enough :)

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