Skip to main content

Maintenance KPIs in Your Own View

Kanoa has a Maintenance Analytics screen, but it has no maintenance widgets for dashboards. The widget categories are Analytics, Downtime, Inputs, Inventory, Lots, Notifications and Selectors.

If a plant manager wants maintenance KPIs on their own dashboard, you build the widget. A widget is just a Perspective view, and the KPIs come from system.kanoa.cmms functions.

You will build a view that shows, for Machine 1:

  • Preventive maintenance completion and on-time percentages (for the whole plant).
  • MTBF in days.
  • The open backlog, by age.
  • MTBF by asset, in a table.

Explore the Data​

Look at what the functions return before you design the view.

Print the KPI datasets
  1. Open the Script Console and run this:

    asset = system.kanoa.asset.getAssets({'assetPath': 'CoreForge\\Philadelphia\\Machining\\Machine 1'})
    assetId = system.kanoa.utilities.getFieldValue('assetId', asset)

    params = {
    'assetId': assetId,
    'startDate': system.date.addDays(system.date.now(), -90),
    'endDate': system.date.now()
    }

    dates = {'startDate': params['startDate'], 'endDate': params['endDate']}

    summary = system.kanoa.cmms.getMaintenanceKPISummary(params)
    print list(summary.getColumnNames())
    print system.kanoa.utilities.convertDatasetToJSON(summary)

    pm = system.kanoa.cmms.getPreventiveMaintenanceCompliance(dates)
    print system.kanoa.utilities.convertDatasetToJSON(pm)

    mtbf = system.kanoa.cmms.getMaintenanceMTBFSummary(params)
    print system.kanoa.utilities.convertDatasetToJSON(mtbf)
  2. Read the output. getPreventiveMaintenanceCompliance filters by date only, not by asset. The summary holds the MTTA, MTTR and related KPIs. The PM compliance row has PM_CompletionPct, PM_OnTimePct and PM_OpenCount. The MTBF summary has MTBF_Days.

Machine 1 needs completed work orders in the period for these to show anything. Use the ones from Work Orders. Where there is no data, a dataset may have no rows, so the script below checks for that.

Reference Materials: getMaintenanceKPISummary

Returns maintenance KPI summary filtered by the given parameters


Parameters​

paramsDict Dictionary

- assetIdIntegerNot required
- assignedUserStringNot required
- endDateDateTimeEnd date
- maintenanceTypeNameStringNot required
- priorityNameStringNot required
- startDateDateTimeStart date

Returns​

kpiSummary pyDataset


Example​

# Get a filtered KPI summary for high-priority corrective work
paramsDict = {
"startDate": system.date.addDays(system.date.now(), -30),
"endDate:: system.date.now(),
"assetId": 4
}

data = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceKPISummary(paramsDict))

for i, row in enumerate(data):
print 'Row %i'%i
for k,v in row.items():
print k,v

break #Just limiting to returning the columns from the first record for display purposes
Reference Materials: getPreventiveMaintenanceCompliance

Returns preventive maintenance compliance metrics for the given period


Parameters​

paramsDict Dictionary

- endDateDateTimeEnd date
- startDateDateTimeStart date

Returns​

pmCompliance pyDataset


Example​

# Populate a PM compliance KPI tile with data from the last 180 days
paramsDict = {
'startDate': system.date.addDays(system.date.now(), -90),
'endDate': system.date.now()
}
data = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getPreventiveMaintenanceCompliance(paramsDict))

for i, row in enumerate(data):
print 'Row %i'%i
for k,v in row.items():
print k,v

break #Just limiting to returning the columns from the first record for display purposes
>>>
Row 0
PM_OnTimePct 0.0
PM_WorkOrderCount 103
PM_CompletedCount 2
PM_CompletionPct 1.94
PM_OpenCount 101
>>>

Write the Data Function​

A view should make one call and get everything it needs. Add a function to the trainingMaintenance library from the last lesson that gathers all the numbers into one dictionary.

Views need plain lists and numbers, so the function converts each dataset with convertDatasetToJSON.

Add getKpiTiles
  1. Open the trainingMaintenance script library.

  2. Add this function below the one you wrote before:

    def getKpiTiles(assetPath, days=90):
    """
    Gather the maintenance KPIs a view needs, for one asset, over the last N days.
    Returns a dictionary with simple values and lists that Perspective can bind to.
    """
    assetId = system.kanoa.utilities.getFieldValue('assetId', system.kanoa.asset.getAssets({'assetPath': assetPath}))
    params = {
    'assetId': assetId,
    'startDate': system.date.addDays(system.date.now(), -days),
    'endDate': system.date.now()
    }

    # Preventive maintenance compliance (one row). It takes dates only, so it covers every asset
    dates = {'startDate': params['startDate'], 'endDate': params['endDate']}
    pmRows = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getPreventiveMaintenanceCompliance(dates))
    pm = pmRows[0] if pmRows else {}

    # MTBF for the asset (one row)
    mtbfRows = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceMTBFSummary(params))
    mtbf = mtbfRows[0] if mtbfRows else {}

    # MTBF for each asset, trimmed to the columns the table shows
    byAsset = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceMTBFByAsset(params))
    mtbfByAsset = []
    for row in byAsset:
    mtbfByAsset.append({
    'assetName': row['assetName'],
    'failureCount': row['failureCount'],
    'MTBF_Days': row['MTBF_Days']
    })

    # Open backlog, counted by age bucket
    backlogParams = {'assetPath': assetPath, 'startDate': system.date.addDays(system.date.now(), -days)}
    backlog = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceBacklogAging(backlogParams))
    buckets = {'0-7': 0, '8-30': 0, '31-60': 0, '60+': 0}
    for row in backlog:
    bucket = row['ageBucket']
    buckets[bucket] = buckets.get(bucket, 0) + 1

    return {
    'pmCompletionPct': pm.get('PM_CompletionPct'),
    'pmOnTimePct': pm.get('PM_OnTimePct'),
    'pmOpenCount': pm.get('PM_OpenCount'),
    'mtbfDays': mtbf.get('MTBF_Days'),
    'failureCount': mtbf.get('failureCount'),
    'backlogTotal': len(backlog),
    'backlogBuckets': buckets,
    'mtbfByAsset': mtbfByAsset
    }
  3. In the Script Console, test it:

    print trainingMaintenance.getKpiTiles('CoreForge\\Philadelphia\\Machining\\Machine 1')
note

getMaintenanceBacklogAging filters by assetPath, and assetPath matches every asset whose path starts with that text. A path ending in Machine 1 would also match Machine 10. That is fine for training, but check it when you reuse the function.

Reference Materials: getMaintenanceBacklogAging

Returns open maintenance backlog aging filtered by the given parameters


Parameters​

paramsDict Dictionary

- assetPathStringNot required
- maintenanceTypeNameStringNot required
- startDateDateTimeNot required

Returns​

backlogAging pyDataset


Example​

# Show open backlog aging for the last 90 days, across all assets and maintenance types
paramsDict = {'startDate': system.date.addDays(system.date.now(), -90)}
data = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceBacklogAging(paramsDict))

for i, row in enumerate(data):
print 'Row %i'%i
for k,v in row.items():
print k,v

break
>>>
Row 0
workOrderEventName MWO00047
workOrderPriorityName Low
dueDate 2026-03-14 14:00:01.848
title jjj
ageBucket 31-60
createdDate 2026-03-14 14:01:55.163
assetId None
assetName None
ageDays 46
workOrderEventId 4
maintenanceTypeName Corrective
>>>
Reference Materials: getMaintenanceMTBFByAsset

Returns MTBF grouped by asset filtered by the given parameters


Parameters​

paramsDict Dictionary

- assetIdIntegerNot required
- endDateDateTimeEnd date
- startDateDateTimeStart date

Returns​

mtbfByAsset pyDataset


Example​

# Compute MTBF by asset for the previous calendar month
paramsDict = {
'startDate': system.date.addDays(system.date.now(), -90),
'endDate': system.date.now()
}
data = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.cmms.getMaintenanceMTBFByAsset(paramsDict))

for i, row in enumerate(data):
print 'Row %i'%i
for k,v in row.items():
print k,v

break #Just limiting to returning the columns from the first record for display purposes
>>>
Row 0
MTBF_Days 14.0
MTBF_Minutes 20242.0
lastFailureDate 2026-05-11 18:51:30.73
firstFailureDate 2026-05-11 18:51:30.73
assetId 901
assetPath Kanoa Box Co\Box Plant\Packaging\Box Line 1
intervalCount 1
assetName Box Line 1
failureCount 1
>>>

Build the View​

The Kanoa dashboard guide says a widget view must have a view parameter called value, and that value must be a dictionary. Follow that now, so the view works as a widget later.

Create the view
  1. In the Designer Project Browser, create a new Perspective view named MaintenanceKpis in a folder such as widgets/maintenance.

  2. Set the root container to a Flex Container with the direction set to column, as the dashboard guide recommends flex containers.

  3. On the Params tab, add an Input parameter called value, type Object, with this default:

    {
    "assetPath": "CoreForge\\Philadelphia\\Machining\\Machine 1",
    "days": 90
    }
  4. On the Custom tab, add a property called kpis.

  5. Bind view.custom.kpis with an Expression binding:

    runScript("trainingMaintenance.getKpiTiles", 60000, {view.params.value.assetPath}, {view.params.value.days})

    The 60000 refreshes the numbers every minute.

Now add the display. Everything reads from view.custom.kpis.

Add the tiles and table
  1. Add four Label components in a row. Bind each label's props.text as shown:

    LabelExpression binding for props.text
    PM completion"PM completed (plant): " + {view.custom.kpis.pmCompletionPct} + "%"
    PM on time"PM on time (plant): " + {view.custom.kpis.pmOnTimePct} + "%"
    MTBF"MTBF: " + {view.custom.kpis.mtbfDays} + " days"
    Open backlog"Open work orders: " + {view.custom.kpis.backlogTotal}
  2. Add a Table component below them. Bind props.data to view.custom.kpis.mtbfByAsset with a Property binding.

  3. Add a second Table. Bind its props.data with an Expression binding:

    runScript("trainingMaintenance.getBacklogRows", 60000, {view.custom.kpis})

    You'll write that function in a moment.

The backlog is a dictionary of counts, and a table wants a list of rows. A small helper turns one into the other.

Add getBacklogRows
  1. Add this to the trainingMaintenance library:

    def getBacklogRows(kpis):
    """Turn the backlog bucket counts into table rows, oldest last."""
    rows = []
    for bucket in ['0-7', '8-30', '31-60', '60+']:
    rows.append({'Age (days)': bucket, 'Open work orders': kpis['backlogBuckets'].get(bucket, 0)})
    return rows
  2. Return to the view. It should now show tiles, an MTBF table and a backlog table for Machine 1.

Preview the view in the Designer, then open it in a Perspective session. If a tile is empty, the matching dataset has no rows in the period. Complete a few work orders and check again.

Add the View to a Dashboard​

Kanoa dashboards are made of widgets, and any view can become a widget. You register it, then add it to a dashboard.

Reference Materials: All About Dashboards

In 2020 Inductive Automation released the perspective dashboard component. With this addition to the component palette, users now have the ability to create their own analysis and operational screens from the browser without having to touch the designer.

KanoaMES extends this component to provide a self-serve user dashboard and marquee implementation.

dashboards

The Home page now points to the Dashboard Viewer. Users that have GatewayAdmin rights can setup the default dashboard that will be displayed.

dashboards

Users can can select a different dashboard and set that to be their default dashboard.

Dashboards can be grouped together in Marquees that can rotate through each dashboard on Andon boards and Big TV's around your plant.


The Dashboard Editor​

Dashboards can be created by selecting 'Dashboard Editor' in the navigation menu. A dashboard consists of a number of widgets that are positioned within a dashboard.

dashboards

To create a new dashboard, click the + button. To edit an existing dashboard, select the dashboard.

Dashboard Info Panel​

  • Name - Give a name to your dashboard. The dashboardId will be shown on the right.
  • Description - A description of what this dashboard does.
  • Folder - Dashboards can be grouped by folder. To edit folders, select the dashboards
  • Private - A dashboard can be made private to the user who created it by enabling the 'private' checkbox. Public dashboards can be viewed by everyone.
  • Enabled - A dashboard must be enabled to show up in the dashboard selector.
  • Debug - Show Header - When enabled, each widget will display the widgetId, widgetName and dashboardWidgetId in the header
  • Debug - Show Dimensions - When enabled and in view mode dashboards, an icon displaying the identified breakpoint with a tooltip will be displayed next to the icon detailing which breakpoint is being shown.

Breakpoints​

Breakpoints allow you to change up what is displayed based on screen size and orientation. We have created three breakpoints, 'Desktop', 'Tablet' and 'Mobile'. If only one breakpoint is configured for a dashboard, that is what will be shown regardless of screen size and aspect ratio.

dashboards

Creating Widgets​

From within the Ignition Designer, any view can effectively be turned into a widget. How well it responds to a mobile responsive environment is entirely in your hands and will be dependent upon how you have constructed your view. We recommend using flex containers almost exclusively as that is the standard container for web design.

We'll use the assetDowntimeBarChart widget as an example. Widgets views can be created under any folder. We are creating ours in the kanoa\core\dbp\widgets folder in the kanoaAPP project. Yours will be somewhere in your project.

dashboards

The only requirements for a widget is that the view parameters start off with a dictionary called 'value'. This is a common practice of ours here at Kanoa. For one it enables a view to be used as a sub-view in a table, it also makes it simple to copy and paste view parameters between views in the designer when testing and debugging.

To make a widget respond to the asset selector and date selector widgets, take a look at how we implemented our view custom property filters binding.

dashboards

The function kanoa.dbp.widget.getWidgetFilters() checks the view parameters and the custom session properties to build up a set of filters that can then be applied to the widget.

To turn a view into a widget or edit an existing widget, click the dashboards button.

dashboards

Widget Info Panel​

  • Name - Give your widget a name. The widgetId will be shown on the right.
  • Description - A description of what this widget does.
  • Category - Select or create a new category for this widget. When adding a widget to a dashboard, this widget will be displayed within this category.
  • View Path - Copy the view path of your widget from within the Ignition designer.
  • View Params - Copy the view params from this view. As mentioned above, the only requirements for a widget is that the view parameters start off with a dictionary called 'value'.

View parameters may be edited directly by editing the object string in the text area, or they may be edited by the table interface below.

Parameter variable types may be specified in the Type dropdown. A default value may also be configured by editing the Default column cell.

Parameters may be configured to have preset options, by editing the Options column cell. The Options cell value should be a comma separated list of string options.

Adding Widgets to a Dashboard​

In the right hand pane, select and drag an area to add a widget. We provide some widgets out of the box for you. Custom widgets can also be added.

We have provided a couple of selector widgets, Asset Selector and Date Range Selector. These are special widgets in that there are no user settable parameters and are only used to effect the behavior of other widgets. With these widgets, a user can select a specific asset and date range to be applied to all other widgets on that dashboard, achieved through the use of custom session properties.


Editing Dashboard Widgets​

Once a widget is added to a dashboard, its specific view parameters may be configured. Parameter values may be typed out in the text-field, or selected from a dropdown if options for that parameter were configured.

dashboards

In the previous example, options were configured for 'downtimeBy', so now it has a dropdown selector to pick options from.

dashboards

From Dashboards →

Register the view as a widget
  1. Navigate to Dashboards → Dashboard Editor and select the widget icon to add a widget.

  2. Fill in the Widget Info panel:

    FieldValue
    NameMaintenance KPIs
    DescriptionPM compliance, MTBF and open backlog for one asset.
    CategoryCreate a new category called Maintenance
    View PathThe path of your MaintenanceKpis view, copied from the Designer
    View ParamsCopy the value parameter from the view
  3. Save the widget.

Add it to a dashboard
  1. Create a dashboard called Maintenance Overview, or open an existing one.
  2. Select an area of the canvas. In the add widget popup, choose Maintenance/Maintenance KPIs.
  3. Click the widget and look at its View Params. Change days to 30. The tiles recalculate.
warning

This widget does not react to the Asset Selector and Date Range Selector widgets. Kanoa widgets do that by building filters from the view parameters and the session properties. Your view takes a fixed assetPath and days instead.

What You Built​

You built a maintenance KPI widget. One script function gathers PM compliance, MTBF and backlog aging from the system.kanoa.cmms functions. A Perspective view refreshes that data every minute and shows it as tiles and tables. Registered under a new Maintenance category, it now sits on a dashboard next to the built-in widgets.