|
本帖最后由 linoul 于 2020-3-27 21:52 编辑
刷写固件,按下面连接的教程刷写,当前有两个固件可以刷,都不完善,只能局域网控制开关,后者在前者的基础上增加了云易连的接入
https://github.com/linlyv/TC1_A2
https://github.com/IoTDevice/phicomm_tc1_a2
监听UDP信息,然后作为MQTT信息发送,HA里再使用MQTT的方法加入插座开关,注意MAC要大写
使用Node red很简单就实现了 以下是导出的流程 3月27日更新 多TC1支持的流 直接使用不用改动
[{"id":"a61aa149.e899","type":"udp out","z":"9c894eb7.3e503","name":"发送UDP指令","addr":"255.255.255.255","iface":"","port":"10182","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":380,"y":60,"wires":[]},{"id":"86d4a70b.3ef518","type":"udp in","z":"9c894eb7.3e503","name":"监听UPD信息","iface":"","port":"10182","ipv":"udp4","multicast":"true","group":"255.255.255.255","datatype":"utf8","x":90,"y":120,"wires":[["246ba146.b6c9ae"]]},{"id":"eeb55119.e08a4","type":"debug","z":"9c894eb7.3e503","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":180,"wires":[]},{"id":"c0e61dd3.cd01e","type":"mqtt in","z":"9c894eb7.3e503","name":"监控MQTT","topic":"device/ztc1/+/set","qos":"2","datatype":"utf8","broker":"8345ab7e.a3f928","x":100,"y":60,"wires":[["a61aa149.e899"]]},{"id":"14e1cdce.97c5c2","type":"mqtt out","z":"9c894eb7.3e503","name":"发布到MQTT","topic":"","qos":"","retain":"","broker":"8345ab7e.a3f928","x":550,"y":120,"wires":[]},{"id":"246ba146.b6c9ae","type":"json","z":"9c894eb7.3e503","name":"","property":"payload","action":"","pretty":false,"x":250,"y":120,"wires":[["2ef942fb.64b2ee"]]},{"id":"2ef942fb.64b2ee","type":"function","z":"9c894eb7.3e503","name":"转换主题","func":"msg.topic = 'device/ztc1/'+ msg.payload.mac +'/state'\nreturn msg;\n","outputs":1,"noerr":0,"x":380,"y":120,"wires":[["14e1cdce.97c5c2","eeb55119.e08a4"]]},{"id":"8345ab7e.a3f928","type":"mqtt-broker","z":"","name":"hassio","broker":"192.168.2.19","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
HA配置
参考连接
https://github.com/a2633063/zTC1/wiki/homeassistant%E6%8E%A5%E5%85%A5
switch:
- platform: mqtt
name: 'ztc1_1_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_0":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_0":{"on":0}}'
value_template: '{{ value_json.plug_0.on }}'
state_on: '1'
state_off: '0'
- platform: mqtt
name: 'ztc1_2_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_1":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_1":{"on":0}}'
value_template: '{{ value_json.plug_1.on }}'
state_on: '1'
state_off: '0'
- platform: mqtt
name: 'ztc1_3_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_2":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_2":{"on":0}}'
value_template: '{{ value_json.plug_2.on }}'
state_on: '1'
state_off: '0'
- platform: mqtt
name: 'ztc1_4_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_3":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_3":{"on":0}}'
value_template: '{{ value_json.plug_3.on }}'
state_on: '1'
state_off: '0'
- platform: mqtt
name: 'ztc1_5_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_4":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_4":{"on":0}}'
value_template: '{{ value_json.plug_4.on }}'
state_on: '1'
state_off: '0'
- platform: mqtt
name: 'ztc1_6_MACMAC'
state_topic: 'device/ztc1/MACMAC/state'
command_topic: 'device/ztc1/MACMAC/set'
payload_on: '{"mac":"MACMAC","plug_5":{"on":1}}'
payload_off: '{"mac":"MACMAC","plug_5":{"on":0}}'
value_template: '{{ value_json.plug_5.on }}'
state_on: '1'
state_off: '0'
之后HA就能顺利操作开关了,有个问题就是如果按插座上的实体按钮来开关,貌似不会发送UDP信息,导致HA里设备获取不到状态,不知道有没有解决办法。
|
|