[
{
"id": "ae8f6ee1.4f4d",
"type": "tab",
"label": "门锁",
"disabled": false,
"info": ""
},
{
"id": "703fd0c.9239f3",
"type": "mqtt in",
"z": "ae8f6ee1.4f4d",
"name": "HA-MQTT",
"topic": "mqttl/#",
"qos": "2",
"datatype": "auto",
"broker": "630cffdb.b6934",
"x": 80,
"y": 300,
"wires": [
[
"4aad887.af91c78"
]
]
},
{
"id": "5682ddf1.12e694",
"type": "debug",
"z": "ae8f6ee1.4f4d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 730,
"y": 20,
"wires": []
},
{
"id": "4aad887.af91c78",
"type": "switch",
"z": "ae8f6ee1.4f4d",
"name": "门锁",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "mqttl/1011415348",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 230,
"y": 300,
"wires": [
[
"ed581fd9.73fe5"
]
]
},
{
"id": "ed581fd9.73fe5",
"type": "function",
"z": "ae8f6ee1.4f4d",
"name": "",
"func": "const topic = msg.topic\nconst val = msg.payload\nconst val2 = parseInt(val,16)\n\nif(topic.indexOf("4110",topic.length - 4) != -1 ){\n msg.type = "shuoshe"\n switch(val2){\n case 0:\n msg.payload = "门未关"\n break;\n case 4:\n msg.payload = "已关,未上锁"\n break;\n case 5:\n msg.payload = "已上锁"\n break;\n case 6:\n msg.payload = "已反锁"\n break;\n case 7:\n msg.payload = "已上锁和反锁"\n break;\n }\n}\n\nif(topic.indexOf("7",topic.length - 1) != -1 ){\n msg.type = "status"\n var temp = val.substring(9,10)\n temp = parseInt(temp,16)\n switch(temp){\n case 0:\n msg.payload = "门开了"\n break;\n case 1:\n msg.payload = "门关了"\n break;\n case 2:\n msg.payload = "门超时未关"\n break;\n case 3:\n msg.payload = "敲门"\n break;\n case 4:\n msg.payload = "撬门"\n break;\n case 5:\n msg.payload = "门卡住"\n break;\n }\n}\n\nif(topic.indexOf("11",topic.length - 2) != -1 ){\n msg.type = "way"\n var keyID = val.substring(8,16)\n switch(keyID){\n case "c0de0000":\n msg.payload = "错误密码频繁开锁"\n break;\n case "c0de0001":\n msg.payload = "错误指纹频繁开锁"\n break;\n case "c0de0002":\n msg.payload = "操作超时(密码输入超时)"\n break;\n case "c0de0003":\n msg.payload = "撬锁"\n break;\n case "c0de0004":\n msg.payload = "重置按键按下"\n break;\n case "c0de0005":\n msg.payload = "错误钥匙频繁开锁"\n break;\n case "c0de0006":\n msg.payload = "钥匙孔异物"\n break;\n case "c0de0007":\n msg.payload = "钥匙未取出"\n break;\n case "c0de0008":\n msg.payload = "错误NFC频繁开锁"\n break;\n case "c0de0009":\n msg.payload = "超时未按要求上锁"\n break;\n case "c0de0010":\n msg.payload = "电量低于10%"\n break;\n case "c0de0011":\n msg.payload = "电量低于5%"\n break;\n case "c0de0012":\n msg.payload = "指纹传感器"\n break;\n case "ffffffff":\n msg.payload = ""\n break;\n case "00000000":\n msg.payload = "管理员"\n break;\n case "80010000":\n msg.payload = "指纹0"\n break;\n case "80010001":\n msg.payload = "指纹1"\n break;\n }\n var way = val.substring(16,17)\n way = parseInt(way,16)\n switch(way){\n case 0:\n msg.payload += "蓝牙"\n break;\n case 1:\n msg.payload += "密码"\n break;\n case 2:\n msg.payload += "指纹"\n break;\n case 3:\n msg.payload += "应急钥匙"\n break;\n case 4:\n msg.payload += "转盘方式"\n break;\n case 5:\n msg.payload += "NFC"\n break;\n case 6:\n msg.payload += "一次性密码"\n break;\n case 7:\n msg.payload += "双重验证"\n break;\n case 10:\n msg.payload += "手动"\n break;\n case 11:\n msg.payload += "自动"\n break;\n }\n var action = val.substring(17,18)\n action = parseInt(action,16)\n switch(action){\n case 0:\n msg.payload += "门外开锁"\n break;\n case 1:\n msg.payload += "上提把手锁门"\n break;\n case 2:\n msg.payload += "门内反锁"\n break;\n case 3:\n msg.payload += "解除反锁"\n break;\n case 4:\n msg.payload += "门内开锁"\n break;\n case 5:\n msg.payload += "门内上锁"\n break;\n case 6:\n msg.payload += "开启童锁"\n break;\n case 7:\n msg.payload += "关闭童锁"\n break;\n case 15:\n msg.payload += "异常"\n break;\n }\n}\n\nif(topic.indexOf("4106",topic.length - 4) != -1 ){\n msg.type = "battery"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 370,
"y": 300,
"wires": [
[
"5682ddf1.12e694",
"a621be17.82d97"
]
]
},
{
"id": "a621be17.82d97",
"type": "switch",
"z": "ae8f6ee1.4f4d",
"name": "",
"property": "type",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "status",
"vt": "str"
},
{
"t": "eq",
"v": "way",
"vt": "str"
},
{
"t": "eq",
"v": "battery",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 530,
"y": 300,
"wires": [
[
"5638e5bc.515f9c"
],
[
"3a254e37.1cd942"
],
[
"2f5ee3bf.60212c"
]
]
},
{
"id": "5638e5bc.515f9c",
"type": "ha-entity",
"z": "ae8f6ee1.4f4d",
"name": "门锁状态",
"server": "8ed410d3.e4c06",
"version": 1,
"debugenabled": false,
"outputs": 1,
"entityType": "sensor",
"config": [
{
"property": "name",
"value": "door_status"
},
{
"property": "device_class",
"value": ""
},
{
"property": "icon",
"value": "mdi:door-closed-lock"
},
{
"property": "unit_of_measurement",
"value": ""
}
],
"state": "payload",
"stateType": "msg",
"attributes": [],
"resend": true,
"outputLocation": "",
"outputLocationType": "none",
"inputOverride": "allow",
"x": 720,
"y": 220,
"wires": [
[]
]
},
{
"id": "2f5ee3bf.60212c",
"type": "ha-entity",
"z": "ae8f6ee1.4f4d",
"name": "门锁电量",
"server": "8ed410d3.e4c06",
"version": 1,
"debugenabled": false,
"outputs": 1,
"entityType": "sensor",
"config": [
{
"property": "name",
"value": "door_battery"
},
{
"property": "device_class",
"value": ""
},
{
"property": "icon",
"value": "mdi:battery-charging"
},
{
"property": "unit_of_measurement",
"value": ""
}
],
"state": "payload",
"stateType": "msg",
"attributes": [],
"resend": true,
"outputLocation": "",
"outputLocationType": "none",
"inputOverride": "allow",
"x": 720,
"y": 360,
"wires": [
[]
]
},
{
"id": "3a254e37.1cd942",
"type": "ha-entity",
"z": "ae8f6ee1.4f4d",
"name": "门锁操作记录",
"server": "8ed410d3.e4c06",
"version": 1,
"debugenabled": false,
"outputs": 1,
"entityType": "sensor",
"config": [
{
"property": "name",
"value": "door_use"
},
{
"property": "device_class",
"value": ""
},
{
"property": "icon",
"value": "mdi:door"
},
{
"property": "unit_of_measurement",
"value": ""
}
],
"state": "payload",
"stateType": "msg",
"attributes": [],
"resend": true,
"outputLocation": "",
"outputLocationType": "none",
"inputOverride": "allow",
"x": 740,
"y": 300,
"wires": [
[]
]
},
{
"id": "630cffdb.b6934",
"type": "mqtt-broker",
"name": "",
"broker": "172.30.32.1",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "uuid",
"birthQos": "1",
"birthRetain": "true",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "8ed410d3.e4c06",
"type": "server",
"name": "Home Assistant",
"addon": true
}
]
感谢