Smart Home StatusReport Trait Schema
action.devices.traits.StatusReport - This trait reports the current status or state of a specific device or a connected group of devices.
A group of devices could be a security system.
A specific device can report its current status as well as the status of any individual sensors connected to that device. StatusReport serves as an aggregation for reporting collective status, but does not replace individual addressing, as any device that can be reported to the Google Assistant should be queryable by the Assistant.
Device ATTRIBUTES
None.
Sample SYNC Request and Response
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"inputs": [{
"intent": "action.devices.SYNC"
}]
}
Node.js
'use strict';
const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');
const app = smarthome();
app.onSync((body, headers) => {
return {
requestId: body.requestId,
payload: {
agentUserId: '1836.15267389',
devices: [{
id: '123',
type: 'action.devices.types.SECURITYSYSTEM',
traits: [
'action.devices.traits.StatusReport'
],
name: {
defaultNames: ['Sirius Cybernetics Corp Security System'],
name: 'Security system',
nicknames: ['Security system']
},
willReportState: true,
attributes: {},
deviceInfo: {
manufacturer: 'Sirius Cybernetics Corporation',
model: '442',
hwVersion: '3.2',
swVersion: '11.4'
},
customData: {
fooValue: 74,
barValue: true,
bazValue: 'lambtwirl'
}
}]
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public SyncResponse onSync(@NotNull SyncRequest syncRequest, @Nullable Map<?, ?> headers) {
Payload payload = new Payload();
payload.setAgentUserId("1836.15267389");
payload.setDevices(new Device[] {
new Device.Builder()
.setId("123")
.setType("action.devices.types.SECURITYSYSTEM")
.addTrait("action.devices.traits.ArmDisarm")
.setName(
Collections.singletonList("Sirius Cybernetics Corp Security System"),
"Security system",
Collections.singletonList("Security System")
)
.setWillReportState(true)
.setAttributes(new JSONObject()
.put("availableArmLevels", new JSONObject()
.put("levels", new JSONObject[] {
new JSONObject()
.put("level_name", "L1")
.put("level_values", new JSONObject[] {
new JSONObject()
.put("level_synonym", new String[] {"home and guarding", "SL1"})
.put("lang", "en"),
new JSONObject()
.put("level_synonym", new String[] {
"zuhause und bewachen",
"SL1"
})
.put("lang", "de")
}),
new JSONObject()
.put("level_name", "L2")
.put("level_values", new JSONObject[] {
new JSONObject()
.put("level_synonym", new String[] {"away and guarding", "SL2"})
.put("lang", "en"),
new JSONObject()
.put("level_synonym", new String[] {"weg und bewachen", "SL2"})
.put("lang", "de")
})
})
.put("ordered", true)
)
)
.setDeviceInfo("sirius", "442", "3.2", "11.4")
.setCustomData(new JSONObject()
.put("fooValue", 74)
.put("barValue", true)
.put("bazValue", "lambtwirl")
.toString()
)
.build()
});
return new SyncResponse(syncRequest.getRequestId(), payload);
}
JSON
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"agentUserId": "1836.15267389",
"devices": [
{
"id": "123",
"type": "action.devices.types.SECURITYSYSTEM",
"traits": [
"action.devices.traits.StatusReport"
],
"name": {
"defaultNames": [
"Sirius Cybernetics Corp Security System"
],
"name": "Security system",
"nicknames": [
"Security system"
]
},
"willReportState": true,
"attributes": {},
"deviceInfo": {
"manufacturer": "Sirius Cybernetics Corporation",
"model": "442",
"hwVersion": "3.2",
"swVersion": "11.4"
},
"customData": {
"fooValue": 74,
"barValue": true,
"bazValue": "lambtwirl"
}
}
]
}
}
Device STATES
| State | Definition |
|---|---|
currentStatusReport |
Object. Contains the current status of the device and status of any individual sensors of that device.
|
Sample QUERY Request and Response
| User | Is my security system ok? |
| Google Assistant | The security system has low battery. The front window and back window are open. |
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"inputs": [{
"intent": 'action.devices.QUERY',
"payload": {
"devices": [{
"id": "123",
"customData": {
"fooValue": 74,
"barValue": true,
"bazValue": "foo"
}
}]
}
}]
}
Node.js
'use strict';
const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');
const app = smarthome();
app.onQuery((body, headers) => {
return {
requestId: body.requestId,
payload: {
devices: {
123: {
on: true,
online: true,
currentStatusReport: [{
blocking: false,
deviceTarget: '123',
priority: 0,
statusCode: 'lowBattery'
}, {
blocking: false,
deviceTarget: 'front_window_id',
priority: 1,
statusCode: 'deviceOpen'
}, {
blocking: false,
deviceTarget: 'back_window_id',
priority: 1,
statusCode: 'deviceOpen'
}]
},
status: 'SUCCESS'
}
}
};
});
// ...
exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public QueryResponse onQuery(@NotNull QueryRequest queryRequest, @Nullable Map<?, ?> map) {
QueryResponse.Payload payload = new QueryResponse.Payload();
payload.setDevices(new HashMap<String, Map<String, Object>>() {{ put("123", new HashMap<String, Object>() {{ put("on", true);
put("online", true);
put("currentStatusReport", new Map[] {
new HashMap<String, Object>() {{ put("blocking", false);
put("deviceTarget", "123");
put("priority", 0);
put("statusCode", "lowBattery");
}},
new HashMap<String, Object>() {{ put("blocking", false);
put("deviceTarget", "front_window_id");
put("priority", 1);
put("statusCode", "deviceOpen");
}},
new HashMap<String, Object>() {{ put("blocking", false);
put("deviceTarget", "back_window_id");
put("priority", 1);
put("statusCode", "deviceOpen");
}} });
}});
}});
return new QueryResponse(queryRequest.getRequestId(), payload);
}
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"devices": {
"123": {
"on": true,
"online": true,
"currentStatusReport": [
{
"blocking": false,
"deviceTarget": "123",
"priority": 0,
"statusCode": "lowBattery"
},
{
"blocking": false,
"deviceTarget": "front_window_id",
"priority": 1,
"statusCode": "deviceOpen"
},
{
"blocking": false,
"deviceTarget": "back_window_id",
"priority": 1,
"statusCode": "deviceOpen"
}
]
},
"status": "SUCCESS"
}
}
}
Device COMMANDS
None.