【问题标题】:Hue API can't turning light on over browser command lineHue API 无法通过浏览器命令行打开灯
【发布时间】:2015-10-16 18:16:11
【问题描述】:

我尝试使用 Clip API 调试工具打开我的 Hue Lamp(如下所述:http://www.developers.meethue.com/documentation/getting-started),一切正常。

现在我想在浏览器命令行上做同样的事情,但我不知道如何编写 url。我尝试了一些变化,但都没有奏效......

网址应如下所示: http://192.168.0.18/api/MyHashcode/lights/2/state{"on":true}&mode=put

问题是消息正文中显示的 json 代码(上面的链接),我不知道如何将其嵌入 url。正确的语法如何使它工作?

提前致谢, 姬

【问题讨论】:

    标签: json url philips-hue


    【解决方案1】:

    为了修改灯光状态,您必须使用 PUT 方法,其中 JSON 有效负载位于 HTML 请求的 BODY 中。您不能将 JSON 放入 URL 查询字符串中。

    但是,您可以以多种语言将 JSON 发送到网桥。这是一个使用 AppleScript 的示例:

    -- define baseUrl to point to your Hue hub address and one of the keys in your whitelist
    set baseUrl to " http://YOUR-HUB-IP/api/YOUR-WHITELIST-ENTRY"
    
    -- define some JSON to set a light state
    set lightStateOn to the quoted form of " {\"on\": true,\"bri\": 254,\"hue\": 8000,\"sat\": 254} "
    
    -- send the JSON to set a light state (on and with specified hue, saturation, and brightness)
    do shell script "curl --request PUT --data " & lightStateOn & baseUrl & "/lights/1/state/"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2023-03-29
      相关资源
      最近更新 更多