如何使用smartthings POST请求正文

时间:2019-08-12 13:58:49

标签: post postman smartthings

我正在尝试通过smartthings和POSTMAN来控制philips色调灯泡。我可以打开和关闭灯光,但是很难理解如何使用其他功能(例如更改颜色)。似乎没有针对此类特定案例的任何文档(我可以找到)。以下是我对我要控制的特定灯泡上的GET请求的回复:

{
    "components": {
        "main": {
            "colorControl": {
                "saturation": {
                    "value": 100
                },
                "color": {
                    "value": "#000000"
                },
                "hue": {
                    "value": 15
                }
            },
            "actuator": {},
            "light": {
                "switch": {
                    "value": "on"
                }
            },
            "healthCheck": {
                "checkInterval": {
                    "value": null
                },
                "DeviceWatch-Enroll": {
                    "value": {
                        "protocol": "LAN",
                        "scheme": "untracked",
                        "hubHardwareId": "XXXX"
                    }
                },
                "healthStatus": {
                    "value": null
                },
                "DeviceWatch-DeviceStatus": {
                    "value": "online",
                    "data": {}
                }
            },
            "refresh": {},
            "switchLevel": {
                "level": {
                    "value": 100,
                    "unit": "%"
                }
            },
            "sensor": {},
            "colorTemperature": {
                "colorTemperature": {
                    "value": 2398,
                    "unit": "K"
                }
            },
            "switch": {
                "switch": {
                    "value": "on"
                }
            }
        }
    }
}

这是POST请求的示例,该请求将打开和关闭灯泡:

{
"commands": [
{
"component": "main",
"capability":  "switch",
"command": "on"
}
]
}

但是,如果我尝试这样的事情:

{
"commands": [
{
"component": "main",
"capability":  "colorControl",
"command": "#000000"
}
]
}

我找回此错误:

{
    "requestId": "XXXX",
    "error": {
        "code": "ConstraintViolationError",
        "message": "The request is malformed.",
        "details": [
            {
                "code": "NotValidValue",
                "target": "[0].command",
                "message": "#000000 is not a valid value.",
                "details": []
            }
        ]
    }
}

我想这是因为colourControl中有多个键值对,而且我不知何故需要调用正确的键对,例如“ color”:{                     “值”:“#000000”                 }。有没有人有使用智能事物和POSTMAN的经验。我认为这将是一个简单的解决方案(希望如此),我似乎无法弄清楚。

谢谢。

0 个答案:

没有答案