This configuration sets up the default actions when device recovers from some situation(network/power abnormality)
Required Attribute:
supportDefaultActions
supportDefaultActions{
"name": "supportDefaultActions",
"value": {
"1": { "cmdNames": ["OnOff"], "situations": ["power", "network"] },
"2": { "cmdNames": ["OnOff"], "situations": ["power", "network"] }
}
}Device Model Example
{
"1": {
"type": "SWITCH",
"traits": ["OnOff"],
"disabled": false,
"attrs": [
{ "name": "intermittent" , "value": true },
{ "name": "timeStepRange", "value": {"max": 86400, "min": 0.1, "step": 0.1} }
]
},
"2": {
"type": "SWITCH",
"traits": ["OnOff"],
"disabled": false,
"attrs": [
{ "name": "intermittent" , "value": true },
{ "name": "timeStepRange", "value": {"max": 86400, "min": 0.1, "step": 0.1} }
]
},
"Ultron Device": {
"type": "ULTRON",
"traits": ["UltronCommand", "ReportState", "UltronConfig"],
"disabled": false,
"attrs": [
{"name": "rebootTime", "value": 20},
{"name": "fwUpgradeTime", "value": 60},
{"name": "iotConfigurableIntervals", "value": true},
{
"name": "schedulable",
"value": { "OUTLET1": ["OnOff"] }
},
{"name": "schedulableVersion", "value": 1},
{"name": "periodicity", "value": true},
{"name": "aperiodicity", "value": true},
{
"name": "supportDefaultActions",
"value": {
"1": { "cmdNames": ["OnOff"], "situations": ["power", "network"] },
"2": { "cmdNames": ["OnOff"], "situations": ["power", "network"] }
}
}
]
}
}
Config Item Attributes
| Field Name | Type | Note |
|---|---|---|
dev | Array[String] | Array of device names/IDs this action applies to. |
act | Array[Object] | Array of actions (commands) that can be triggered by events. |
behaviors | Array[Object] | Definition of command for each situation. |
Object of behaviors (behavior)
| Field Name | Type | Note |
|---|---|---|
disabled | Boolean | |
defaultAction | String | Defines what situation and actions should execute. Format: "[situations]:[IotDevs]:actIdx" See example. |
Example
{
"config": "DefaultActions",
"items": {
"dev": ["1", "2"],
"act": [
{
"cmds": [
{ "command": "OnOff", "params": {"on": true} }
]
},
{
"cmds": [
{ "command": "OnOff", "params": {"on": false} }
]
}
],
"behaviors": [ {"defaultAction": "network:0,1:-1"}, {"defaultAction": "power:0,1:-1"} ]
}
}The format of "defaultAction" = "[situations]:[IotDevs]:actIdx"
when actIdx = -1, means remain previous state.
API Example: /usr/v5/SetDeviceConfigs
{
"sn": "UT3M10-6JXXXXX",
"configs": [
{
"config": "DefaultActions",
"items": {
"dev": ["1","2"],
"act": [
{
"cmds": [
{ "command": "OnOff", "params": {"on": true} }
]
},
{
"cmds": [
{ "command": "OnOff", "params": {"on": false} }
]
}
],
"behaviors": [ {"defaultAction": "network:0,1:-1"}, {"defaultAction": "power:0,1:-1"} ]
}
}
]
}