-1

我正在尝试使该action.devices.traits.Modes特征起作用。根据action.devices.SYNC要求,我返​​回以下响应:

{
   "payload":{
      "devices":[
         {
            "id":"12345",
            "type":"action.devices.types.SWITCH",
            "traits":[
               "action.devices.traits.OnOff",
               "action.devices.traits.StartStop",
               "action.devices.traits.Modes"
            ],
            "name":{
               "defaultNames":null,
               "name":"David",
               "nicknames":null
            },
            "willReportState":false,
            "roomHint":"living room",
            "attributes":{
               "pausable":true,
               "availableModes":[
                  {
                     "name":"speed",
                     "name_values":[
                        {
                           "name_synonym":[
                              "speed"
                           ],
                           "lang":"en"
                        }
                     ],
                     "settings":[
                        {
                           "setting_name":"slow",
                           "setting_values":[
                              {
                                 "setting_synonym":[
                                    "slow"
                                 ],
                                 "lang":"en"
                              }
                           ]
                        },
                        {
                           "setting_name":"normal",
                           "setting_values":[
                              {
                                 "setting_synonym":[
                                    "normal"
                                 ],
                                 "lang":"en"
                              }
                           ]
                        },
                        {
                           "setting_name":"fast",
                           "setting_values":[
                              {
                                 "setting_synonym":[
                                    "fast"
                                 ],
                                 "lang":"en"
                              }
                           ]
                        }
                     ],
                     "ordered":true
                  }
               ]
            }
         }
      ]
   }
}

我在https://developers.google.com/actions/smarthome/tools/validator/上验证了这个回复,并得到了很好的反馈。

现在,当我在智能手机上的控制台或助手中键入以下短语之一时,不会调用履行服务:

What mode is David in?
What speed is David in?
What is the David's speed?
Set the speed of David to normal.
Set David's speed to normal.
Set David to normal speed.
...

所有这些都简单地回退到谷歌搜索。

这些特征action.devices.traits.OnOffaction.devices.traits.StartStop但是工作正常。以下短语按预期工作:

Turn David on
Resume David.
...

我不知道出了什么问题以及我应该做些什么来调试它。AFAIK,智能家居服务或多或少是一个黑匣子,所以我不确定这里发生了什么/错误。

4

1 回答 1

2

正如Modes 特征的文档中所述availableModes

目前,您必须使用示例 JSON 中的名称;尚不支持自定义名称。

可以通过在GitHub 示例上提交问题来手动创建名称。

但是,在您的特定速度情况下,您应该查看FanSpeed特征。它提供了相同的功能,您可以在其中定义多种速度模式,然后在它们之间切换。您可以更新您的设备 JSON 使其看起来更像这样:

{
 "payload":{
   "devices":[
     {
        "id":"12345",
        "type":"action.devices.types.SWITCH",
        "traits":[
           "action.devices.traits.OnOff",
           "action.devices.traits.StartStop",
           "action.devices.traits.FanSpeed"
        ],
        "name":{
           "defaultNames":null,
           "name":"David",
           "nicknames":null
        },
        "willReportState":false,
        "roomHint":"living room",
        "attributes":{
           "pausable":true,
           "availableFanSpeeds": {
             "speeds": [{
               "speed_name": "Low",
               "speed_values": [{
                 "speed_synonym": ["low", "slow"],
                 "lang": "en"
               },
               {
                 "speed_synonym": ["low", "slow"],
                 "lang": "de"
               }]
             },
             {
               "speed_name": "High",
               "speed_values": [{
                 "speed_synonym": ["high"],
                 "lang": "en"
               },
               {
                 "speed_synonym": ["high"],
                 "lang": "de"
               }]
           }],
           "ordered": true
         },
         "reversible": true
        }
     }
  ]}
}
于 2018-07-18T17:12:32.700 回答