• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. phildunlap
    3. Best

    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
    • Profile
    • Following 0
    • Followers 9
    • Topics 17
    • Posts 3,433
    • Best 111
    • Controversial 1
    • Groups 0

    Best posts made by phildunlap

    • RE: kWh Consumption

      That one is intended to run every minute (.past(MINUTE, 1)) so for a meta point you could do Start of minute or 0 * * * * ? as your update event.

      posted in How-To
      phildunlapP
      phildunlap
    • RE: External IP

      That command will create the keystore file, yes. Had some weird formatting though, so I edited your post. You may want to use a different storepass than "changei" (or omit that argument to have it ask for that, first)

      posted in Mango General
      phildunlapP
      phildunlap
    • RE: ma-point-value: number formatting

      It's definitely good to contribute methods of doing stuff, but it's best if those methods work (insert links to the many times I've said "untested" next to code snippets here...)

      I think your parameters to the angular filter have a syntax error, they should be colon delimited, as,

      {{point.value | number:N}}
      

      where N is the number of decimal places, like,

      {{point.value*256 | number:1}}
      
      posted in How-To
      phildunlapP
      phildunlap
    • RE: Show Data Point Name as Column in Watch List CSV Download

      Hi chio,

      Currently this option does not exist, but it would be pretty easy to use a JSON export and a python script to rewrite the file something like...

      import json
      
      configFile = open("/path/to/config.json", encoding='utf-8')
      config = json.load(configFile)
      configFile.close()
      
      csvData = open("/path/to/data.csv", "r")
      xidLine = csvData.readline()
      
      # Assume no commas, quotes or newlines in the XIDs
      xids = xidLine.replace("\r", "").replace("\n", "").replace("\"", "").split(",")[1:]
      #print(xids)
      
      xidMap = {}
      for dp in config["dataPoints"] :
          xidMap[dp["xid"]] = dp
      	
      newFirstLine = "\"timestamp\""
      for xid in xids :
      	newFirstLine += ",\"" + xidMap[xid]["deviceName"] + " - " + xidMap[xid]["name"] + "\""
      newFirstLine += "\n"	
      
      #print(newFirstLine)
      outputFile = open("/path/to/output.csv", "w+")
      outputFile.writelines(newFirstLine)
      outputFile.writelines(csvData.readlines())
      outputFile.close()
      csvData.close()
      

      Definitely we see what you're saying and that you've added weight in the discussion that the available formats could be more flexible. I think the original XIDs as headers was done in anticipation of providing a multicolumn data upload, but no such feature exists currently.

      I have created a git issue about it: https://github.com/infiniteautomation/ma-core-public/issues/1436

      posted in User help
      phildunlapP
      phildunlap
    • RE: Cron pattern to copy over a USB drive

      Hi sky_watcher,

      You shouldn't have to worry about mounting the USB drive with fstab as Fox suggested - V3 Mango ES units have usbmount installed to facilitate the USB Utilities actions. It will mount the first USB stick plugged in at /media/usb0

      After that, your choices are

      1. Set Mango to backup directly to the USB drive instead of to the /opt/mango/backup folder. This is in the system settings
      2. Set up a cron pattern as Fox suggested and add that to a crontab either via crontab -e to invoke the script or simply add the script /etc/cron.daily/ (and then you don't need to generate the cron pattern but you have less control).
      3. Set a schedule in Mango and use event handlers to copy / move files as necessary.
      posted in How-To
      phildunlapP
      phildunlap
    • RE: Get Current and Historic Point Values Through REST API

      I'm largely a librarian of previously answered questions at this point :D

      posted in User help
      phildunlapP
      phildunlap
    • RE: How to setup and event on rate of change?

      Hi Dave,

      This is done through a meta point.

      Something like....

      var changeThreshhold = 5 //5 units per minute, let's say
      var data = p.past(MINUTE, 5)
      if( data.count == 0 ) {
        //Handle no data in period condition, raise event?
        return true;
      } else if ( data.count == 1 ) {
        //Handle only one piece of data in our range by getting another value
        var lv = p.lastValue(1);
        if ( lv == null ) //Only one data point, no cause for alarm. We may not need to check this
           return false
        return changeThreshhold > ( data.lastValue - lv.value )/((data.lastTime - lv.time)/60000);
      } else {
        return changeThreshhold > ( data.lastValue - data.firstValue )/((data.lastTime - data.firstTime)/60000);
      }
      

      Then having a state detector on the meta point checking for a "true" state. This isn't its own detector because the shrewd observer may see data sets where this logic is deeply flawed (specifically, data that isn't monotonic). For situations where your data varies in both directions, you may be more interested in changing the logic to sum the differences as you iterate the list, and alarm if you cross the threshhold, more like....

      var data = p.pointValuesSince(new Date().getTime() - 5*60*1000) //Five minutes in milliseconds
      if( data.length <= 1 ) //we have the same edge conditions for our range
         return false
      var sum = 0;
      var changeThreshhold = 5; //so, this would mean that if any point in the period it is more than
      for( var k = 0; k < data.length-1; k+=1 ) {
        sum += (data[k+1].value - data[k].value);
        if( sum < changeThreshhold || sum > changeThreshhold )
          return true;
      }
      return false;
      

      So, what it means to have changed over time can be funky depending on your data set. That second version should be equivalent to seeing if any values in a range are outside the acceptable rate of change... like,

      var data = p.pointValuesSince(new Date().getTime() - 5*60*1000) //Five minutes in milliseconds
      if( data.length <= 1 ) //we have the same edge conditions for our range
         return false
      var firstValue = data[0];
      var changeThreshhold = 5; //so, this would mean that if any point in the period it is more than
      for( var k = 1; k < data.length; k+=1 ) {
        if( firstValue.value - data[k].value > changeThreshhold || firstValue.value - data[k].value < changeThreshhold )
          return true;
      }
      return false;
      

      But this could still be flawed. If data[0].value == 0, data[1].value == -3, and data[2].value == 3, then none of these detectors would alarm, even though we experienced a change of 6 at one point. One would expect the next run of the point will have data[0] == -3, but having uniform data in time is an assumption we shouldn't rest our logic on!

      posted in Dashboard Designer & Custom AngularJS Pages
      phildunlapP
      phildunlap
    • RE: Mango in active-passive cluster

      Hi jae, welcome to the forum!

      The last time a question similar was posed was here: https://forum.infiniteautomation.com/topic/3910/mango-on-aws-with-ha-architecture and the answer hasn't changed that much.

      posted in Hardware
      phildunlapP
      phildunlap
    • RE: How to access Rest API Login Endpoint using VBA

      Hi Mok Kiew,

      I've never written any VBA and very little VB personally, but I think this stackoverflow thread does some general API type stuff, and it does contain some information about setting headers: http://stackoverflow.com/questions/19553476/how-to-make-rest-call-with-vba-in-excel

      You'll want to do a GET to /rest/v1/login/admin or another user with the password in a header named "password" which will get you a response with a Set-Cookie header if successful. You'll have to pass that header's value as the "Cookie" header in subsequent requests.

      You may need to include the XSRF-TOKEN portion of the Cookie under the X-Xsrf-Token header, as well. If this is required you'll have a 403 Forbidden response when using just the Cookie header.

      Someone else may chime in with an example script. Good luck!

      posted in How-To
      phildunlapP
      phildunlap
    • RE: Internet Explorer Public View icons

      Is there any output to the browser's console? You should be able to right click the page and select 'Inspect Element' then navigate to the console.

      posted in User help
      phildunlapP
      phildunlap
    • RE: any generic guide to REST API + python?

      Thanks for contributing what you got it working with!

      posted in Dashboard Designer & Custom AngularJS Pages
      phildunlapP
      phildunlap
    • RE: Configuring Mango to Send Emails

      Hi Silvia,

      It's a very good question! The answer is that as the UI is being redesigned, a fair bit of functionality hasn't migrated over yet. The "Data sources" menu item will link you back into the old UI, and you can navigate to the old system settings page using the icon bar. Or, you can navigate to the /system_settings.shtm URL.

      If you find there's a legacy page you visit especially often, you can link to it using a custom link menu item on the "Edit menu" page, linked to the full URL of the page.

      posted in Mango General
      phildunlapP
      phildunlap
    • RE: Email Title Format

      Hello!

      I think what you're looking for is probably...

      <@subject>Hey - Stuff is happening with the automation system and I think you should know</@subject>

      somewhere in your FTL. For a complete list of subject line options I'll have to refer you to the code a little, as the SubjectDirective class has some parameter options. Aliases override the default (but keep the Critical - and - id portions as you discovered probably), and the last SubjectDirective will probably have the final say.

      https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/email/SubjectDirective.java

      posted in How-To
      phildunlapP
      phildunlap
    • RE: Log out inactive users?

      Hi Dan,

      You're looking for the <session-timeout> tag in Mango/web/WEB-iNF/web.xml

      i believe the value is in minutes.

      posted in User help
      phildunlapP
      phildunlap
    • RE: Git Hooks

      Hi rshah,

      The pages created on the edit-pages or in the DashboardDesigner are stored in the jsonData table. You could definitely have something fetch it from git and update the entry in the table if you're using MySQL. It would probably take some developing, though.

      posted in Dashboard Designer & Custom AngularJS Pages
      phildunlapP
      phildunlap
    • RE: Run Hours

      Hi George,

      There is! Runtime information is available in the StartsAndRuntimes object returned from the past() and previous() functions on data points in scripts.

      So, i could have a meta point like,

      var stats = p.past(DAY); //p is the variable name of the binary point in the context
      for(var k = 0; k < stats.data.length; k+=1) {
          if(stats.data[k].value === true)
              return my.value + stats.data[k].runtime/3600000; //runtime given in milliseconds
      }
      return my.value;
      

      running on a cron like 59 59 23 * * ? and it'll totalize once a day the hours run that day. Then you can put a limit detector on the meta point.

      posted in Mango General
      phildunlapP
      phildunlap
    • RE: Email Title Format

      Hi George,

      <#assign message><@fmt message=evt.message/></#assign>
      <@subject>${message?replace("current undesired text", "desired text")}</@subject>
      

      You can find other built in methods to manipulate the string, here, http://freemarker.org/docs/ref_builtins_string.html

      Another possibility is overriding your i18n.properties file. Then you can change the rendered text to whatever you want globally.

      posted in How-To
      phildunlapP
      phildunlap
    • RE: How do I create a datasource using the Mango API?

      Hi Gary,

      I think the problem you're experiencing is probably that there was a bug preventing the HTTP Receiver from being created or saved through the API. I fixed this and released a new version of the module, 1.6.2.

      If you've got that version, the easiest / best way to get the JSON model is by doing a GET for a data source you've made through the UI. But, here's the JSON for a an HTTP Receiver from my testing:

      {
        "xid": "httpReceiver2",
        "name": "HTTP Receiver",
        "enabled": false,
        "modelType": "HTTP_RECEIVER",
        "validationMessages": [],
        "deviceIdWhiteList": [
          "*"
        ],
        "setPointUrl": "",
        "ipWhiteList": [
          "*.*.*.*"
        ],
        "editPermission": "",
        "purgeSettings": {
          "override": false,
          "frequency": {
            "periods": 1,
            "type": "YEARS"
          }
        },
        "alarmLevels": {
          "SET_POINT_FAILURE": "URGENT"
        }
      }
      

      One must use the POST /rest/v1/data-sources to create data sources, and the PUT /rest/v1/data-sources/[XID] to update existing data sources.

      Thanks for bringing that bug to our attention!

      posted in User help
      phildunlapP
      phildunlap
    • RE: Problem with Pie Chart

      ^ This

      which could be aided by printing what the values you're passing to the pie chart directive is, like,

      {{ P_Reativa_A.renderedValue.slice(0, P_Reativa_A.renderedValue.indexOf(' ')) }}
      

      somewhere on the page.

      posted in Dashboard Designer & Custom AngularJS Pages
      phildunlapP
      phildunlap
    • RE: Run Hours

      Have you let this run over night? With that cron pattern it should only run on the last second of the day to produce a value.

      posted in Mango General
      phildunlapP
      phildunlap