With Smart Home Skills, developers can enable proactive and predictive experiences to help customers save energy, save time and money, and feel more secure in their home. Features such as Hunches are one of the proactive experiences that lets Alexa change the state of a connected smart home device when it is not in its usual state. Saying “Alexa, goodnight” while the front door is unlocked? Alexa will lock it for you. Some of your home lights on at bedtime? Alexa will turn off the ones you don't usually leave on overnight. To take advantage of such experiences on behalf of your customers, you need to proactively report the state of endpoints. Accurate device states are the foundation of all ambient, proactive technology Alexa brings to customers.
For developers participating in the Works With Alexa program, proactively reporting endpoint states is mandatory to maintain the certification. Below are 12 recommendations to help you improve your accuracy score.
There are several steps that you need to take in order to send events: enable events, then implement the Alexa.Authorization interface, request permission to send events to the Alexa event gateway, and obtain authentication tokens for each customer. Finally, you will need to update your discovery response.
1. Enable Alexa Events in the Developer Console
To send reports to the Alexa event gateway, you must enable Alexa events in your skill. Once events are enabled, your skill will be able to share state information in your responses, and also proactively send state events. When you enable Alexa Events, your skill will have to go through a new certification cycle in order for the change to be effective.
To enable Alexa events, go to the Permissions tab in the Alexa Developer Console.
Smart Home skills:
Multi-capability skills:
Note both your Client Id and Client Secret in the permission tab, as you will need these values to request an access token for a customer.
To learn more: https://developer.amazon.com/en-US/docs/alexa/smarthome/authenticate-a-customer-permissions.html
2. Enable Asynchronous Messages to be Sent to the Alexa Event Gateway
Alexa.Authorization interface is a critical piece, as it allows your skill to send asynchronous messages, such as change reports and state reports (if you chose to send state reports asynchronously), to the Alexa event gateway.
Once implemented, Alexa will send you an AcceptGrant directive every time a user goes through the account linking process.
If you have an existing skill and looking to enable proactive reporting, Alexa will also send you an AcceptGrant directive: there is a backfill process, during which you will receive an AcceptGrant directive for every customer that have previously enabled your skill. You must handle the AcceptGrant messages and go through the authentication process.
Should an issue arise and you lose access and refresh tokens associated with your customer(s), you will need to request new ones through an off-cycle backfill process. Amazon will repeat the process of resending AcceptGrant directives for each customer.
To learn more about the backfill process: https://developer.amazon.com/en-US/docs/alexa/smarthome/authenticate-a-customer-permissions.html#requesting-new-authorization-codes
To learn more about Alexa.Authorization Interface: https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-authorization.html
Each Smart Home device must implement EndpointHealth, which reports the connectivity of a device. See the rules about when to send a report in the following sections.
2. Update Your Discovery Response
Verify that all the capabilities that you have implemented support State and Change reporting.
You must indicate that you support State and Change reporting for each interface, in your discovery response. You indicate this by setting both retrievable and proactivelyReported to true. This is an important point as it affects our ability to deliver the best proactive experiences for your customers.
While a few endpoints cannot support State and Change reporting, such as infrared transmitters or low-energy devices, most devices should support state, and therefore should be set to both retrievable = true and proactivelyReported = true.
To learn more: https://developer.amazon.com/en-US/docs/alexa/smarthome/state-reporting-for-a-smart-home-skill.html
3. When to Send a Report
Below are the use cases describing when you need to send a report, and its type:
For example: Developer LightBulb Inc. supports EndpointHealth and PowerController on their Smart Home Skill, which controls light bulbs. A customer possesses a light bulb from LightBulb Inc., which is connected to the Internet and controllable by Alexa.
At 10 am, the customer asks “Alexa, turn on the light." Developer LightBulb Inc. sends a ChangeReport with the following values:
{
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "<message id>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "<endpoint id>",
"cookie": {
"path": "path/for/this/endpoint"
}
},
"payload": {
"change": {
"cause": {
"type": "VOICE_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2021-06-03T16:00:50Z",
"uncertaintyInMilliseconds": 60000
}
]
}
}
},
"context": {
"properties": [
{
"namespace": "Alexa.EndpointHealth",
"name": "connectivity",
"value": {
"value": "OK"
},
"timeOfSample": "2021-06-03T16:00:50Z ",
"uncertaintyInMilliseconds": 0
}
]
}
}
The connectivity status did not change, however the bulb went from off to on.
State must be accurately reported, and rapidly sent.
1. Maintain a Low State Update Latency
ChangeReport events must be received within 3 seconds, from the instant a directive is sent to your Cloud to change the state of a device.
State must also be accurate, as a failure to report an event impacts the performances of proactive Smart Home features. When Alexa sends a ReportState directive about an endpoint, and you respond with a StateReport, Amazon will compare the value reported in the StateReport with the values you shared in the last ChangeReport (see accuracy score below).
A few recommendations to help you send events faster:
2. Review Your Accuracy Score on the Developer Portal
On the developer console, select your live skill to access metrics. Under “Operational Metrics”, select “Change Report”. The page contains metrics for all the controllers for which we are receiving Change and State reports:
Below find common issues with State and Change reporting and solutions.
1. If your controller average is consistently below that baseline: you may be missing state updates events on your devices and not reporting them.
2. If a controller chart does not appear in the Change Report dashboard: you may not be sending any state events