|
用小米人体探测器,发现延迟挺严重。以前家里有套315射频安防系统,就想着怎么接入ha。
试用过openmqttgateway,发现接收模块用了几天后就没反应了,要断电重新启动。
现在使用esp8266挺好,一直很稳定。
原理:
315接收模块接收后通过esp01透传到node-red监听端口,数据处理后,发送到mqtt,ha接收。
探测是老的315mhz
接收模块我用的是输出是串口的,比较稳定,8266用的是esp01
整个系统上电后的状态
首先设置esp01为透传模式
AT+CWMODE_DEF=1
AT+CWDHCP_DEF=1,1
AT+CWJAP_DEF="ssid","passwd"
AT+UART_DEF=9600,8,1,0,0
AT+SAVETRANSLINK=1,"node-red地址",33135,"TCP"
就是设置模块为station,dhcp开,wifi的ssid和密码,串口为9600,透传到nodered,端口我写的是33135
接着设置node-red
[{"id":"7881cc89.a6e3c4","type":"tcp in","z":"b9db1fa.2a0c5e","name":"","server":"server","host":"","port":"3315","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":100,"y":40,"wires":[["30c5a1c0.d228ee"]]},{"id":"30c5a1c0.d228ee","type":"function","z":"b9db1fa.2a0c5e","name":"","func":"var code=msg.payload[1]*65536+ msg.payload[2]*256 + msg.payload[3];\nmsg.topic="home/OpenMQTTGateway2/315toMQTT/" +code;\nmsg.payload="ON";\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":40,"wires":[["52c3a5e5.4ece44"]]},{"id":"52c3a5e5.4ece44","type":"mqtt out","z":"b9db1fa.2a0c5e","name":"","topic":"","qos":"","retain":"","broker":"ece826df.d63718","x":390,"y":40,"wires":[]},{"id":"ece826df.d63718","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
接着看下探测器激活后,mqtt有没有数据输出,我的是这样的
然后编辑ha
binary_sensor:
- platform: mqtt
name: "Reading Room 315Mhz Motion Sensor"
# state_topic: "/Home/RF315/6124892"
state_topic: "home/OpenMQTTGateway2/315toMQTT/6124892"
payload_on: "ON"
payload_off: "OFF"
off_delay: 10
device_class: motion
- platform: mqtt
name: "Living Room 315Mhz Motion Sensor"
# state_topic: "/Home/RF315/1865052"
state_topic: "home/OpenMQTTGateway2/315toMQTT/1865052"
payload_on: "ON"
payload_off: "OFF"
off_delay: 10
device_class: motion
处女贴,不周之处,请原谅
|
评分
-
参与人数 1 | 金钱 +20 |
HASS币 +20 |
收起
理由
|
囧
| + 20 |
+ 20 |
楼主有点6,处女贴就被加精! |
查看全部评分
|