智慧型住宅照明指南

action.devices.types.LIGHT - 可開啟和關閉的燈具裝置。這些裝置可能具有其他功能,例如調光和變色。

這個類型表示裝置會取得「Light」圖示和一些相關的近義字和別名。

裝置功能

請參閱對應特徵的說明文件,瞭解實作詳細資訊,例如服務應支援的屬性和狀態,以及如何建構 EXECUTE 和 QUERY 回應。

必要特徵

這些特徵和指令 (如果適用於您的裝置) 是必要的。如果裝置不支援這些特徵,請在 QUERY 或 EXECUTE 回應中輸入 functionNotSupported 的錯誤代碼。詳情請參閱「錯誤和例外狀況」一文。

如果這些特徵適用於您的裝置,建議您使用這些特徵。不過,您可以自由混搭所有可用的特徵,以便配合現有產品功能。

品質規定

  • 延遲時間:必須小於或等於 700 毫秒
  • 可靠度:必須大於或等於 99%

裝置範例:簡易燈具

本節包含意圖酬載的範例,這些意圖酬載代表根據上述裝置類型和特徵的常見「燈具」。如果您在實作中新增或移除特徵,請據此修改回應,以反映這些變更。

SYNC 回應範例

要求回覆
{
  "requestId": "6894439706274654512",
  "inputs": [
    {
      "intent": "action.devices.SYNC"
    }
  ]
}
{
  "requestId": "6894439706274654512",
  "payload": {
    "agentUserId": "user123",
    "devices": [
      {
        "id": "123",
        "type": "action.devices.types.LIGHT",
        "traits": [
          "action.devices.traits.ColorSetting",
          "action.devices.traits.Brightness",
          "action.devices.traits.OnOff"
        ],
        "name": {
          "name": "Simple light"
        },
        "willReportState": true,
        "attributes": {
          "colorTemperatureRange": {
            "temperatureMinK": 2000,
            "temperatureMaxK": 6500
          }
        },
        "deviceInfo": {
          "manufacturer": "smart-home-inc",
          "model": "hs1234",
          "hwVersion": "3.2",
          "swVersion": "11.4"
        }
      }
    ]
  }
}

範例 QUERY 回應

要求回覆
{
  "requestId": "6894439706274654514",
  "inputs": [
    {
      "intent": "action.devices.QUERY",
      "payload": {
        "devices": [
          {
            "id": "123"
          }
        ]
      }
    }
  ]
}
{
  "requestId": "6894439706274654514",
  "payload": {
    "devices": {
      "123": {
        "status": "SUCCESS",
        "online": true,
        "on": true,
        "brightness": 65,
        "color": {
          "temperatureK": 4000
        }
      }
    }
  }
}

EXECUTE 指令範例

ColorAbsolute

如要進一步瞭解指令參數,請參閱 action.devices.traits.ColorSetting 參考資料。

要求回覆
{
  "requestId": "6894439706274654520",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.ColorAbsolute",
                "params": {
                  "color": {
                    "name": "Warm White",
                    "temperature": 3000
                  }
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
{
  "requestId": "6894439706274654520",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "color": {
            "temperatureK": 3000
          }
        }
      }
    ]
  }
}

BrightnessAbsolute

如要進一步瞭解指令參數,請參閱 action.devices.traits.Brightness 參考資料。

要求回覆
{
  "requestId": "6894439706274654518",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.BrightnessAbsolute",
                "params": {
                  "brightness": 65
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
{
  "requestId": "6894439706274654518",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "brightness": 65
        }
      }
    ]
  }
}

OnOff

如要進一步瞭解指令參數,請參閱 action.devices.traits.OnOff 參考資料。

要求回覆
{
  "requestId": "6894439706274654516",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.OnOff",
                "params": {
                  "on": true
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
{
  "requestId": "6894439706274654516",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "on": true
        }
      }
    ]
  }
}

裝置錯誤

請參閱錯誤和例外狀況的完整清單。