简体   繁体   中英

Detail about google smart home “mode” trait

I have a question about the device.trait "Modes"

I create a washer machine with traits Modes and the SYNC.response look like this

{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"agentUserId": "1836.15267389",
"devices": [
    {
        "id": "311_washer_1",
        "type": "action.devices.types.WASHER",
        "traits": ["action.devices.traits.Modes","action.devices.traits.OnOff"],
        "name": {
            "name": "Laboratory Washer 1",
            "nicknames": ["Laboratory Washer"]
        },
        "willReportState": false,
        "attributes":{
            "availableModes":[{
                "name": "speed",
                "name_values": [{
                    "name_synonym": ["speed"],
                    "lang": "en"
                }],
                "settings": [{
                        "setting_name": "fast",
                        "setting_values": [{
                            "setting_synonym": ["fast"],
                            "lang": "en"
                        }]
                    },{
                        "setting_name": "medium",
                        "setting_values":[{
                            "setting_synonym":["medium"],
                            "lang": "en"
                        }]
                    },{
                        "setting_name": "slow",
                        "setting_values":[{
                            "setting_synonym":["slow"],
                            "lang": "en"
                        }]
                    }
                ],
                "ordered": true
            }]
        }
    }
]
}

}

I have a mode call "speed"

but when I talk to the assistant, it just replay my that "That mode isn't available for it"

Can somebody tell me where is wrong or is it related to

Currently, you must use the names in the example JSON; custom names are not yet supported.

in the instruction page

Thank you~~

For incorporating modes, there are only a specific set of available mode values and settings that you are able to use. Custom names and settings are currently not supported, so you need to stick to a specific list.

If you would like to get a new mode or settings added, you can file an issue on the GitHub sample and I'll add the specific values that you want.

In the meantime, here's an example that should work using current modes.

"availableModes":[{
    "name": "Cleaning Mode",
    "name_values": [{
        "name_synonym": ["cleaning mode"],
        "lang": "en"
    }],
    "settings": [{
        "setting_name": "High",
        "setting_values": [{
            "setting_synonym": ["high"],
            "lang": "en"
        }]
    },{
        "setting_name": "Medium",
        "setting_values":[{
            "setting_synonym":["medium"],
            "lang": "en"
        }]
    },{
        "setting_name": "Low",
        "setting_values":[{
            "setting_synonym":["low"],
            "lang": "en"
        }]
    }],
    "ordered": true
}]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM