Show me an example
Here is one example of a script that runs every time a 12.0 battery is connected.
Chart

JSON
{
"StartAt": "Get User Info",
"Comment": "Read Cell Balance",
"MTSLLanguageVersion": "1.0",
"TimeoutSeconds": 30,
"States": {
"Get User Info": {
"Type": "Task",
"Resource": "User:GetInfo",
"ResultSelector": {
"IsASC.$": "States.Includes($.roles, 'Service App - ASC')"
},
"ResultPath": "$.UserInfo",
"Next": "Is User ASC?"
},
"Is User ASC?": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.UserInfo.IsASC",
"BooleanEquals": false,
"Next": "Read Cell Balance"
}
],
"Default": "Done"
},
"Read Cell Balance": {
"Type": "Task",
"Resource": "OpenLink:SendCommand",
"Parameters": {
"MessageType": "01",
"IsWrite": false,
"RouteType": "Tool",
"CommandBody": "400A0A"
},
"ResultSelector": {
"CellBalance.$": "$.OpenLinkCommandResponse.Payload"
},
"Next": "Calculate Cell Balance"
},
"Calculate Cell Balance": {
"Type": "Task",
"Resource": "Calculation:CellBalance",
"Parameters": {
"ComparatorValue": 100,
"isLittleEndian": false,
"Value.$": "$.CellBalance"
},
"ResultPath": "$.CellBalanceCalculation",
"Next": "In Balance?"
},
"In Balance?": {
"Type": "Choice",
"Choices": [
{
"And": [
{
"Variable": "$.CellBalanceCalculation.IsBalanced",
"StringEquals": "No"
}
],
"Next": "Display Battery Alert"
}
],
"Default": "Done"
},
"Display Battery Alert": {
"Type": "Task",
"Resource": "UI:Prompt",
"Parameters": {
"Title": "M18 HO HD12.0 Battery Alert",
"Message": "<div style='font-weight: bold;'>If the battery is both:</div> <div style='margin-bottom: 20px;'><ul style='list-style-type: disc; margin-left: 20px;'><li><span style='text-decoration: underline;'>OUT OF WARRANTY DATE</span> (Up to 5 years past mfg date)</li><li><span style='text-decoration: underline;'>UNBALANCED</span></li></ul></div><div style='font-weight: bold;'>Then:</div><div><ul style='list-style-type: disc; margin-left: 20px;'><li>Replace battery on goodwill (code ROG)</li></ul></div>",
"Sentiment": "Neutral"
},
"End": true
},
"Done": {
"Type": "Succeed"
}
}
}