本帖最后由 scry 于 2024-9-14 15:11 编辑
cmcc x11插座的app不能用了,分享一下免刷机的插座初始化方案
插座完成初始化后,可以使用mqtt控制插座
我太懒了,接入ha的教程或者封装成插件就留给好心人吧
Untitled.zip
(1.65 KB, 下载次数: 18)
下载附件
server.py是用于设备注册,会给插座mqtt相关的配置默认使用broker-cn.emqx.io这个公共服务器
ez_config.py用于返回注册服务器相关信息
注意修改ez_config.py中IP变量,修改为运行server.py脚本设备的IP
如果使用自己搭建的mqtt服务器,请修改server.py中的 USERNAME SECRET BROKER这三个变量
运行server.py和ez_config.py
重置插座,指示灯进入快闪(smart config模式,慢闪为ap config)
下载esptouch,将手机连接至2.4gwifi,打开esptouch,输入wifi密码然后点击确认
esptouch会弹出一个提示框,为插座ip地址,同时ez_config.py输出设备sn,此时配网成功
/sys/2dGkWmko/此处为sn/thing/event/property/post
/sys/2dGkWmko/此处为sn/thing/event/property/post_reply (插座订阅)
当按下插座开关时,插座会主动向改主题发送消息,包含了插座状态
/sys/2dGkWmko/此处为sn/thing/service/property/get (插座订阅)
/sys/2dGkWmko/此处为sn/thing/service/property/get_reply
主动获取插座状态,消息模板如下,id值无所谓,插座会以相同值回复消息
{"id":137555423,"method":"thing.service.property.get","params":["switch","countDown","order","networkStatus"],"timestamp":1681501944612,"version":"2.0.0"}
/sys/2dGkWmko/此处为sn/thing/service/property/set (插座订阅)
/sys/2dGkWmko/此处为sn/thing/service/property/set_reply
控制插座开关,消息模板如下,0为关,1为开
{"id":137555513,"method":"thing.service.property.set","params":{"switch":0},"timestamp":1681502670027,"version":"2.0.0"}
最后关于ota的,希望有人能研究出来ota刷机
/sys/2dGkWmko/此处为sn/ota/device/check_reply
/sys/2dGkWmko/此处为sn/ota/device/progress_reply
/sys/2dGkWmko/此处为sn/ota/device/upgrade
这是由/sys/2dGkWmko/此处为sn/ota/device/check_reply 返回的内容
{
"code": 200,
"data": {
"extConfigs": null,
"firmwareVersion": "1.2.1",
"hardwareVersion": "1.0.1",
"manufacturer": "tuya",
"md5": "08883453F0C6569A87F4497FE6098AE7",
"mode": 2,
"productKey": "2dGkWmko",
"silence": 1,
"size": 962152,
"strategy": "静默升级插座到1.2.1",
"type": "",
"url": "https://static.cxzx10086.cn/iotplat/ehome/fota/1617097908659_SWOTA.bin"
},
"id": 1,
"method": "ota.device.check_reply",
"ok": true,
"timestamp": 1693890430462
}
|