alexa-skills-kitalexa-voice-servicealexa-smapi

Query device state for Alexa SmartHome skill


I try to get the device states for my alexa smart home devices via the ask-smapi-sdk client (https://pypi.org/project/ask-smapi-sdk/). Idea is to use that information for automated testing.

I'm able to access to trigger the predefined Amazon on tests. (That are also avaiable under the developer console->skill->test section)

evaluate_sh_capability_payload = {
        "endpoint": {
            "endpointId": endpoint
        },
        "capabilityTestPlan": {
            "id": capability
        },
        "stage": self.stage
    }
 
    evaluation_response = self.skill_client.create_smarthome_capability_evaluation_v1(
        skill_id=self.skill_id,
        stage=self.stage,
        evaluate_sh_capability_payload=evaluate_sh_capability_payload)

My question is how can I trigger a device query against my skill using the sdk or REST? Basically the same what can be done via the developer console here. https://developer.amazon.com/alexa/console/ask/devices


Solution

  • Each Smart Home Test sends directives to your skill, and then compares the expected device state with the actual device state. And You can only see the results of your tests in the console. If you want to see the contents of each test, you can download them from the console or view them on GitHub at alexa/alexa-smarthome/capability_evaluations/test_plans/.

    In fact, the Smart Home Evaluation REST API can be used to start evaluations and get evaluation results on your smart home interface implemented. Smart home evaluations verify that you implemented the Alexa smart home interfaces in your skill correctly. And only operations provided by API seem to limit this to your smart home capability evaluation

    Please refer to API reference here Smart Home Skill Evaluation REST API Reference

    ASK-CLI's "create-smarthome-capability-evaluation" command also provide a way to create and start a capability evaluation.

    In short, triggering a device query against skill using the SDK or REST is not currently supported. If you want to run and view the Smart Home tests results I would recommend using Smart Home Test Tool and managing test results as described here