Hướng dẫn về thiết bị phát trực tuyến trong nhà thông minh

action.devices.types.STREAMING_STICK – Thiết bị này có kiểu dáng nhỏ, hình gậy, thường chạy bằng cáp USB hoặc HDMI kết nối với màn hình như TV.

Loại này cho biết thiết bị sẽ nhận được biểu tượng Thanh phát trực tuyến cùng một số từ đồng nghĩa và biệt hiệu có liên quan.

Khả năng của thiết bị

Hãy tham khảo tài liệu về đặc điểm tương ứng để biết thông tin chi tiết về cách triển khai, chẳng hạn như các thuộc tính và trạng thái mà dịch vụ của bạn cần hỗ trợ cũng như cách tạo các phản hồi EXECUTE và QUERY.

Trait bắt buộc

Những đặc điểm và lệnh này là bắt buộc, nếu áp dụng cho thiết bị của bạn. Nếu thiết bị của bạn không hỗ trợ các trait này, hãy nhập mã lỗi functionNotSupported vào phản hồi QUERY hoặc EXECUTE. Hãy xem phần Lỗi và ngoại lệ để biết thêm thông tin.

Bạn nên sử dụng những đặc điểm này (nếu phù hợp với thiết bị của mình). Tuy nhiên, bạn có thể tuỳ ý kết hợp và so khớp từ tất cả các đặc điểm có sẵn sao cho phù hợp nhất với chức năng sản phẩm hiện có.

Yêu cầu về chất lượng

  • Độ trễ: phải nhỏ hơn hoặc bằng 3000 mili giây.
  • Độ tin cậy: phải lớn hơn hoặc bằng 97%.

Thiết bị ví dụ: Thanh phát trực tuyến đơn giản

Phần này chứa các tải trọng ý định mẫu đại diện cho một "Thiết bị truyền trực tuyến" phổ biến, dựa trên loại thiết bị và đặc điểm ở trên. Nếu bạn thêm hoặc xoá đặc điểm trong quá trình triển khai, hãy sửa đổi các phản hồi cho phù hợp để phản ánh những thay đổi đó.

Phản hồi SYNC mẫu

Yêu cầu
{
  "requestId": "6894439706274654512",
  "inputs": [
    {
      "intent": "action.devices.SYNC"
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654512",
  "payload": {
    "agentUserId": "user123",
    "devices": [
      {
        "id": "123",
        "type": "action.devices.types.STREAMING_STICK",
        "traits": [
          "action.devices.traits.AppSelector",
          "action.devices.traits.MediaState",
          "action.devices.traits.TransportControl",
          "action.devices.traits.Volume"
        ],
        "name": {
          "name": "Simple streaming stick"
        },
        "willReportState": true,
        "attributes": {
          "availableApplications": [
            {
              "key": "youtube",
              "names": [
                {
                  "name_synonym": [
                    "YouTube"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "transportControlSupportedCommands": [
            "NEXT",
            "PREVIOUS",
            "PAUSE",
            "STOP",
            "RESUME"
          ],
          "volumeMaxLevel": 11,
          "volumeCanMuteAndUnmute": true,
          "supportActivityState": true,
          "supportPlaybackState": true
        },
        "deviceInfo": {
          "manufacturer": "smart-home-inc",
          "model": "hs1234",
          "hwVersion": "3.2",
          "swVersion": "11.4"
        }
      }
    ]
  }
}

Phản hồi QUERY mẫu

Yêu cầu
{
  "requestId": "6894439706274654514",
  "inputs": [
    {
      "intent": "action.devices.QUERY",
      "payload": {
        "devices": [
          {
            "id": "123"
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654514",
  "payload": {
    "devices": {
      "123": {
        "status": "SUCCESS",
        "online": true,
        "currentApplication": "youtube",
        "currentVolume": 10,
        "isMuted": false,
        "activityState": "ACTIVE",
        "playbackState": "PAUSED"
      }
    }
  }
}

Lệnh EXECUTE mẫu

appInstall

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.AppSelector.

Yêu cầu
{
  "requestId": "6894439706274654516",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.appInstall",
                "params": {
                  "newApplication": "youtube"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654516",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "currentApplication": "youtube"
        }
      }
    ]
  }
}

appSearch

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.AppSelector.

Yêu cầu
{
  "requestId": "6894439706274654518",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.appSearch",
                "params": {
                  "newApplication": "youtube"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654518",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "currentApplication": "youtube"
        }
      }
    ]
  }
}

appSelect

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.AppSelector.

Yêu cầu
{
  "requestId": "6894439706274654520",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.appSelect",
                "params": {
                  "newApplication": "youtube"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654520",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "currentApplication": "youtube"
        }
      }
    ]
  }
}

mediaClosedCaptioningOff

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654522",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaClosedCaptioningOff"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654522",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "PLAYING"
        }
      }
    ]
  }
}

mediaClosedCaptioningOn

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654524",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaClosedCaptioningOn",
                "params": {
                  "closedCaptioningLanguage": "en"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654524",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "PLAYING"
        }
      }
    ]
  }
}

mediaNext

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654526",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaNext"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654526",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "FAST_FORWARDING"
        }
      }
    ]
  }
}

mediaPause

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654528",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaPause"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654528",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "PAUSED"
        }
      }
    ]
  }
}

mediaPrevious

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654530",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaPrevious"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654530",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "REWINDING"
        }
      }
    ]
  }
}

mediaResume

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654532",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaResume"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654532",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "PLAYING"
        }
      }
    ]
  }
}

mediaStop

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.TransportControl.

Yêu cầu
{
  "requestId": "6894439706274654534",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mediaStop"
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654534",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "playbackState": "STOPPED"
        }
      }
    ]
  }
}

tắt tiếng

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.Volume.

Yêu cầu
{
  "requestId": "6894439706274654538",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.mute",
                "params": {
                  "mute": true
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654538",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "currentVolume": 10,
          "isMuted": true
        }
      }
    ]
  }
}

setVolume

Để biết thêm thông tin chi tiết về các tham số lệnh, hãy xem tài liệu tham khảo về action.devices.traits.Volume.

Yêu cầu
{
  "requestId": "6894439706274654536",
  "inputs": [
    {
      "intent": "action.devices.EXECUTE",
      "payload": {
        "commands": [
          {
            "devices": [
              {
                "id": "123"
              }
            ],
            "execution": [
              {
                "command": "action.devices.commands.setVolume",
                "params": {
                  "volumeLevel": 11
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
Câu trả lời
{
  "requestId": "6894439706274654536",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "online": true,
          "currentVolume": 11,
          "isMuted": false
        }
      }
    ]
  }
}

Thiết bị LỖI

Xem danh sách toàn bộ lỗi và ngoại lệ.