身边有一个Huntkey插座,是用小京鱼app控制的,想接入手机termux搭建的homeassistant,于是对其用android httpcanary进行了抓包分析,可以通过分享导出curl命令来进行控制。给需要的朋友一个参考,以后有类似的设备也可以用这种办法快速接入ha。就是不知道服务器的token校验是否有有效期,后面继续跟进看看!另外注意的是httpcanary导出的curl -d如果是json注意修改为单引号,请求的url也需要修改为httpcanary抓包显示的请求url,导出的可能被编码过了。可以在terumx终端里面验证curl执行结果,没问题的话再放到ha里面。
switch:
platform: command_line
switches:
jdchazuo:
friendly_name: 京东插座
command_on: curl -X POST -H "app_identity:WL" -H "Authorization:此处需要按照你的抓包结果来填写" -H "tgt:此处需要按照你的抓包结果来填写" -H "Content-Type:application/json; charset=utf-8" -H "Content-Length:123" -H "Host:gw.smart.jd.com" -H "Connection:Keep-Alive" -H "Accept-Encoding:gzip" -H "User-Agentkhttp/3.11.0" -d '{"json":"{\"feed_id\":347491659196802546,\"command\":[{\"stream_id\":\"Power\",\"current_value\":1}],\"version\":\"2.0\"}"}' "https://gw.smart.jd.com/c/service/integration/v1/controlDevice_v1?hard_platform=Redmi+Note+7&app_version=7.3.0&device_id=此处需要按照你的抓包结果来填写&plat_version=9&channel=jd&plat=Android"
command_off: curl -X POST -H "app_identity:WL" -H "Authorization:此处需要按照你的抓包结果来填写" -H "tgt此处需要按照你的抓包结果来填写" -H "Content-Type:application/json; charset=utf-8" -H "Content-Length:123" -H "Host:gw.smart.jd.com" -H "Connection:Keep-Alive" -H "Accept-Encoding:gzip" -H "User-Agentkhttp/3.11.0" -d '{"json":"{\"feed_id\":347491659196802546,\"command\":[{\"stream_id\":\"Power\",\"current_value\":0}],\"version\":\"2.0\"}"}' 'https://gw.smart.jd.com/c/service/integration/v1/controlDevice_v1?hard_platform=Redmi+Note+7&app_version=7.3.0&device_id=此处需要按照你的抓包结果来填写&plat_version=9&channel=jd&plat=Android'
|