Dashboards
Definiton
Dashboards
are used to monitor and analyze your fleet/Asset performance at various conditions, to increase the efficiency and report the factors, parameters responsible for the particular performance.
Payload
{
"name": dashboard.name,// String
"is_general": True
"is_template": False
"tags": tagNames,// Tag List
"assets": assetsSns,// EdisonGenericComponent
}
Class
class Dashboard:
"""
A class to handle ``Dashbaords``
"""
id: Optional[str] = None
created_by: Optional[str] = None
company: Optional[str] = None
updated_by: Optional[UpdatedBy] = None
projects: Optional[List[Project]] = None
tags: Optional[List[Tag]] = None
panels: Optional[List[Panel]] = None
name: Optional[str] = None
accessibility: Optional[str] = "COMPANY"
icon_properties: Optional[IconProperties] = IconProperties()
is_template: Optional[bool] = False
is_general: Optional[bool] = True
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
blueprint: Optional[Blueprint] = None
asset: Optional[Asset] = None
Setup
#Altergo parameters to connect with Client
ALTERGO_FACTORY_API= 'https://altergo.io/' #Default Factory API
ALTERGO_IOT_API= 'https://iot.altergo.io/' #Default IOT API
apiKey = "Your API KEY" #API key of the client
API keys are user bound
from altergo_sdk.models.v2 import Dashboard
altergoApiKey = apiKey
_client = {
"apiKey": altergoApiKey,
"factory_api": ALTERGO_FACTORY_API,
"iot_api":ALTERGO_IOT_API
}
altergoApi = Client(**_client)
Create
The createDashboard
method of Altergo SDK enables the user to create dashboards from a python environment
This example demonstrates the creation of an dashboard called KB_Dashboard
#Create Dashboard object
tagtoCreate = Tag()
tagtoCreate.name = "F1"
tagtoCreate.description = "This tag represents Fleet 1"
tagtoCreate.color = "success"
tagtoCreate = altergoApi.createTag(tagtoCreate)
altergoApi.linkTagToAssets(tagtoCreate, [asset])
dashboardtoCreate = Dashboard()
dashboardtoCreate.name = 'KB_Dashboard'
dashboardtoCreate.is_general = True
dashboardtoCreate.is_template = False
dashboardtoCreate.tags = [tagtoCreate]
# create dashboard
newDash = altergoApi.createDashboard(dashboardtoCreate))
Get dashboard
The user can bring an existing dashboard in the Altergo platform to a python environment. To facilitate this feature, Altergo SDK provides three different methods - getDashboardById
and getDashboards
Since the dashboard name can be similar for different dashboards, For the user to target a specific dashboard, Altergo SDK provides the getDashboardById
method.getDashboardById
takes in Altergo ID
(int) of dashboard as an argument and returns the corresponding activity.
altergoApi.getDashboardById("641dac52624a52a20de50920")
The user can bring all the dashboards defined on the Altergo platform to a python environment using the getdashboards
method. It returns a list of the dashboards.
altergoApi.getDashboards()
Add New Panel and Update
The user can leverage updateDashboard
method in Altergo SDK to add panels/widgets to an existing dashboard. The updateDashboard
requires an dashboard object as an argument and returns the updated dashboard.
In this article e.g. KB_Dashboard
(dashboard) is updated to add a new panel on the dashboard.
# Get the asset to be edited
dashboard=altergoApi.getDashboardById("641dac52624a52a20de50920")
#Updates
#we are using the tag we created above in the example
panel1 = Panel().initChartPanel(panelName="test_panel sensor" + str(i), description="eg")
panel1.addDatasource(entityType="tags", tags=[tagtoCreate], sensorCode=asset.blueprint.sensors[1].sensor_model.code, timespanStartDate=start_date, timespanEndDate=end_date, isDynamic=False, singleAssetAggregationMethod="sum", fleetAggregationMethod="sum")
panel1.addScatterLineTrace(label="test", datasource=panel1.template["dataSource"][0], lineColorHex="#000000" )
panel1.properties.height = 4
panel1.properties.width = 4
panel1.properties.x = 0 % 3 * 4
panel1.properties.y = 0 % 12
panel1 = altergoApi.createPanel(panel1)
dashboard.panels.append(panel1)
# update dashboard
updateddash = altergoApi.updateDashboard(dashboard)
Delete
The user can remove a dashboard defined on the Altergo platform with the deleteDashboard
method of Altergo SDK. deleteDashboard
takes in an Existing Dashboard object
to be removed as the argument.
#Get the dashboard to be removed
removeObj=altergoApi.getDashboardById("641dac52624a52a20de50920")
#Delete dashboard
altergoApi.deleteDashboard(removeObj)