本帖最后由 xz0609 于 2018-12-31 10:34 编辑
前言
本文是是接上一篇[Sonoff RF Bridge刷入Tasmota固件教程](https://bbs.hassbian.com/thread-5384-1-1.html)来写的,
折腾了好几个晚上终于弄懂了一点,对于我这个新人来说不容易啊!
一、读取电机遥控器射频RF433码
向日葵KT82TN电动窗帘电机,遥控器logo写着DOOYA(杜亚)
下面开始:
读取RF433raw射频码的模式有好几种,测试下来常用的有3种:
1、
一般读取到的都是这种格式:
22:23:25 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfReceived":{"Sync":13140,"Low":470,"High":1400,"Data":"853511","RfKey":"None"}}
2、
读取到的是这种格式:
22:25:58 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA6040085351155"}}
3、
读取到的是这种格式:
22:26:46 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AA B1 03 05AA 01B8 3322 011010101001100110100101100110011010100110101001101010010110011012 55"}}
读取KT82TN电动窗帘电机,我用的是RfRaw 166 ,3个键都能够读取到码RfRaw 0读不到码,RfRaw 177能读取到开和关,但读不到暂停键。
浏览器进入Sonoff Bridge设备页面,选择Console(控制台)界面,在控制台输入:
回车
会显示下面内容
22:17:39 CMD: RfRaw 166
22:17:39 MQT: stat/sonoff_rf_bridge_kt/RESULT = {"RfRaw":"ON"}
22:17:39 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA055"}}
然后分别按杜亚遥控器上的按钮,读取到的码为:
22:35:35 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A11155"}}
22:35:35 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A11055"}}
22:35:35 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A11E55"}}
AAA606019C0B75A11155,AAA606019C0B75A11055,AAA606019C0B75A11E55,这3个是箭头上的码。
22:35:43 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A15555"}}
AAA606019C0B75A15555,是暂停键的码。
22:35:48 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A13355"}}
22:35:48 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A13255"}}
22:35:48 MQT: tele/sonoff_rf_bridge_kt/RESULT = {"RfRaw":{"Data":"AAA606019C0B75A13C55"}}
AAA606019C0B75A13355,AAA606019C0B75A13255,AAA606019C0B75A13255,这3个是箭头下的码。
读取到码后,把AAA606019C0B75A11155改成AAA806019C0B75A11155,就是把A6给改成A8
在EFM8BB1固件命令表中可以得知,A6是嗅探数据,A8是发送数据。
在控制台输入:
rfraw AAA806019C0B75A11155
看看电机是否转动,没转动,挨个试一下。记得把6改成8
根据我多次实践得出,一般控制台上读取到的第一个码都可以控制
我的2个遥控器读取到的码:
箭头上的码都是11155结尾
箭头上的码都是15555结尾
暂停键的码都是13355结尾
二、接入HA
在Ubuntu上装的hassio,版本:0.84.6
是用论坛里的HASSIO 安装一键脚本 ,感谢neroxps大神的脚本!
下面附上代码:
cover.yaml
- platform: mqtt
name: keting_cover
command_topic: "keting/cover/cmnd"
payload_open: "open"
payload_stop: "stop"
payload_close: "close"
把command_topic: "keting/cover/cmnd"中的keting/cover替换成你自己的订阅主题
automations.yaml
- alias: "keting cover"
hide_entity: true
trigger:
- platform: mqtt
topic: "keting/cover/cmnd"
action:
- service: mqtt.publish
data_template:
topic: "cmnd/sonoff_rf_bridge_kt/Backlog"
payload: >
{% if trigger.payload == "open" %}
RfRaw AAA806019C0B75A11155
{% elif trigger.payload == "stop" %}
RfRaw AAA806019C0B75A15555
{% elif trigger.payload == "close" %}
RfRaw AAA806019C0B75A13355
{% endif %}
- service: mqtt.publish
data:
topic: "cmnd/sonoff_rf_bridge_kt/Backlog"
payload: "RfRaw 177"
把topic: "keting/cover/cmnd"中的keting/cover替换成你自己的订阅主题
把topic: "cmnd/sonoff_rf_bridge_kt/Backlog"中的sonoff_rf_bridge_kt替换成你自己的Sonoff RF Bridge设备名称
payload中分别填入上面读到的3个raw码。
最后面的一个- service: mqtt.publish发送RfRaw 177是因为执行发送raw码后防止RF Bridge变回默认的RfRaw 0模式,我的双向门磁以及按钮开关都是直接读取raw码,为了不影响其他设备读取raw码而加的。
Sonoff Bridge 启动自动进入rfraw 177模式
浏览器进入Sonoff Bridge设备页面,选择Console(控制台)界面,输入:
rule1 on system#boot do RfRaw 1 endon on Mqtt#Connected do RfRaw 1 endon on on system#boot do RfRaw 177 endon on Mqtt#Connected do RfRaw 177 endon on
回车回车
然后重启RF Bridge试试。
Sonoff Bridge时区设置不正确的话,浏览器进入Sonoff Bridge设备页面,选择Console(控制台)界面,在控制台输入:
|